提交 cc491e94 编写于 作者: E Eric Seidel

Fix CreatePlatformServiceProvider to allow calling more than once.

The previous implementation would (silently) delete any previous
ServiceProviderImpl which would close all open mojo pipes.
This would manfiest in the mojo:network_service never
responding to Dart's request for loads.

This mostly fixes issue #256, however there still appears to be
a separate display-only race, which may be related to issue #52.

R=abarth@google.com
上级 e0c7dab4
......@@ -7,7 +7,7 @@
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "sky/engine/wtf/Assertions.h"
#include "sky/services/ns_net/network_service_impl.h"
#include "sky/shell/service_provider.h"
......@@ -18,20 +18,35 @@
namespace sky {
namespace shell {
// FIXME(csg): Put this in an application owned context
base::LazyInstance<scoped_ptr<mojo::ServiceProviderImpl>> g_service_provider =
LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<scoped_ptr<mojo::NetworkServiceFactory>>
g_network_service_factory = LAZY_INSTANCE_INITIALIZER;
class PlatformServiceProvider : public mojo::ServiceProvider {
public:
PlatformServiceProvider(mojo::InterfaceRequest<mojo::ServiceProvider> request)
: binding_(this, request.Pass())
{
}
static void CreatePlatformServiceProvider(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
g_service_provider.Get().reset(new mojo::ServiceProviderImpl(request.Pass()));
g_network_service_factory.Get().reset(new mojo::NetworkServiceFactory());
g_service_provider.Get()->AddService(g_network_service_factory.Get().get());
void ConnectToService(const mojo::String& service_name,
mojo::ScopedMessagePipeHandle client_handle) override {
if (service_name == mojo::NetworkService::Name_) {
network_.Create(nullptr,
mojo::MakeRequest<mojo::NetworkService>(client_handle.Pass()));
}
#if !TARGET_OS_IPHONE
g_service_provider.Get()->AddService(&TestRunner::Shared());
if (service_name == TestHarness::Name_) {
TestRunner::Shared().Create(nullptr,
mojo::MakeRequest<TestHarness>(client_handle.Pass()));
}
#endif
}
private:
mojo::StrongBinding<mojo::ServiceProvider> binding_;
mojo::NetworkServiceFactory network_;
};
static void CreatePlatformServiceProvider(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
new PlatformServiceProvider(request.Pass());
}
mojo::ServiceProviderPtr CreateServiceProvider(
......
......@@ -34,11 +34,11 @@ class TestRunner : public mojo::InterfaceFactory<TestHarness>,
void Start(scoped_ptr<SingleTest> single_test);
private:
// mojo::InterfaceFactory<TestHarness> implementation:
void Create(mojo::ApplicationConnection* app,
mojo::InterfaceRequest<TestHarness> request) override;
private:
// TestHarness implementation:
void OnTestComplete(const mojo::String& test_result,
const mojo::Array<uint8_t> pixels) override;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册