| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/mojo/mojo_application_host.h" | 5 #include "content/browser/mojo/mojo_application_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class ApplicationSetupImpl : public mojom::ApplicationSetup { | 16 class ApplicationSetupImpl : public mojom::ApplicationSetup { |
| 17 public: | 17 public: |
| 18 ApplicationSetupImpl(ServiceRegistryImpl* service_registry, | 18 ApplicationSetupImpl(ServiceRegistryImpl* service_registry, |
| 19 mojo::InterfaceRequest<mojom::ApplicationSetup> request) | 19 mojo::InterfaceRequest<mojom::ApplicationSetup> request) |
| 20 : binding_(this, std::move(request)), | 20 : binding_(this, std::move(request)), |
| 21 service_registry_(service_registry) {} | 21 service_registry_(service_registry) {} |
| 22 | 22 |
| 23 ~ApplicationSetupImpl() override { | 23 ~ApplicationSetupImpl() override { |
| 24 } | 24 } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 // mojom::ApplicationSetup implementation. | 27 // mojom::ApplicationSetup implementation. |
| 28 void ExchangeInterfaceProviders( | 28 void ExchangeInterfaceProviders( |
| 29 mojo::shell::mojom::InterfaceProviderRequest services, | 29 shell::mojom::InterfaceProviderRequest services, |
| 30 mojo::shell::mojom::InterfaceProviderPtr exposed_services) override { | 30 shell::mojom::InterfaceProviderPtr exposed_services) override { |
| 31 service_registry_->Bind(std::move(services)); | 31 service_registry_->Bind(std::move(services)); |
| 32 service_registry_->BindRemoteServiceProvider(std::move(exposed_services)); | 32 service_registry_->BindRemoteServiceProvider(std::move(exposed_services)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 mojo::Binding<mojom::ApplicationSetup> binding_; | 35 mojo::Binding<mojom::ApplicationSetup> binding_; |
| 36 ServiceRegistryImpl* service_registry_; | 36 ServiceRegistryImpl* service_registry_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 MojoApplicationHost::MojoApplicationHost() | 41 MojoApplicationHost::MojoApplicationHost() |
| 42 : token_(mojo::edk::GenerateRandomToken()) { | 42 : token_(mojo::edk::GenerateRandomToken()) { |
| 43 #if defined(OS_ANDROID) | 43 #if defined(OS_ANDROID) |
| 44 service_registry_android_ = | 44 service_registry_android_ = |
| 45 ServiceRegistryAndroid::Create(&service_registry_); | 45 ServiceRegistryAndroid::Create(&service_registry_); |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 mojo::ScopedMessagePipeHandle pipe = | 48 mojo::ScopedMessagePipeHandle pipe = |
| 49 mojo::edk::CreateParentMessagePipe(token_); | 49 mojo::edk::CreateParentMessagePipe(token_); |
| 50 DCHECK(pipe.is_valid()); | 50 DCHECK(pipe.is_valid()); |
| 51 application_setup_.reset(new ApplicationSetupImpl( | 51 application_setup_.reset(new ApplicationSetupImpl( |
| 52 &service_registry_, | 52 &service_registry_, |
| 53 mojo::MakeRequest<mojom::ApplicationSetup>(std::move(pipe)))); | 53 mojo::MakeRequest<mojom::ApplicationSetup>(std::move(pipe)))); |
| 54 } | 54 } |
| 55 | 55 |
| 56 MojoApplicationHost::~MojoApplicationHost() { | 56 MojoApplicationHost::~MojoApplicationHost() { |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace content | 59 } // namespace content |
| OLD | NEW |