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
This commit is contained in:
Eric Seidel
2015-07-29 17:48:47 -07:00
parent e0c7dab4c6
commit cc491e94b0
2 changed files with 28 additions and 13 deletions
+27 -12
View File
@@ -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())
{
}
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
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) {
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());
#if !TARGET_OS_IPHONE
g_service_provider.Get()->AddService(&TestRunner::Shared());
#endif
new PlatformServiceProvider(request.Pass());
}
mojo::ServiceProviderPtr CreateServiceProvider(
+1 -1
View File
@@ -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;