Index: sky/shell/ios/platform_service_provider_ios.cc |
diff --git a/sky/shell/ios/platform_service_provider_ios.cc b/sky/shell/ios/platform_service_provider_ios.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..558006123d0292227b2dc20b01f1012b5172113a |
--- /dev/null |
+++ b/sky/shell/ios/platform_service_provider_ios.cc |
@@ -0,0 +1,45 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "sky/engine/config.h" |
+#include "sky/engine/wtf/Assertions.h" |
abarth-chromium
2015/06/05 22:56:09
You shouldn't need to include any of these headers
|
+#include "sky/shell/service_provider.h" |
+#include "base/single_thread_task_runner.h" |
+#include "base/bind.h" |
+#include "base/bind_helpers.h" |
+#include "base/lazy_instance.h" |
+#include "base/location.h" |
+#include "mojo/public/cpp/application/service_provider_impl.h" |
+#include "sky/services/ns_net/network_service_impl.h" |
+ |
+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; |
+ |
+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()); |
+} |
+ |
+mojo::ServiceProviderPtr CreateServiceProvider( |
+ ServiceProviderContext* context) { |
+ DCHECK(context); |
+ mojo::MessagePipe pipe; |
abarth-chromium
2015/06/05 22:56:09
I suspect there's a fancier way do this without me
|
+ auto request = mojo::MakeRequest<mojo::ServiceProvider>(pipe.handle1.Pass()); |
+ context->ios_task_runner->PostTask( |
+ FROM_HERE, |
+ base::Bind(CreatePlatformServiceProvider, base::Passed(request.Pass()))); |
+ return mojo::MakeProxy( |
+ mojo::InterfacePtrInfo<mojo::ServiceProvider>(pipe.handle0.Pass(), 0u)); |
+} |
+ |
+} // namespace shell |
+} // namespace sky |