OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/mojo/mojo_application_host.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/logging.h" | |
10 #include "build/build_config.h" | |
11 #include "mojo/edk/embedder/embedder.h" | |
12 | |
13 namespace content { | |
14 namespace { | |
15 | |
16 // TODO(beng): remove this in favor of just using shell APIs directly. | |
17 // http://crbug.com/2072603002 | |
18 class ApplicationSetupImpl : public mojom::ApplicationSetup { | |
19 public: | |
20 ApplicationSetupImpl(ServiceRegistryImpl* service_registry, | |
21 mojo::InterfaceRequest<mojom::ApplicationSetup> request) | |
22 : binding_(this, std::move(request)), | |
23 service_registry_(service_registry) {} | |
24 | |
25 ~ApplicationSetupImpl() override { | |
26 } | |
27 | |
28 private: | |
29 // mojom::ApplicationSetup implementation. | |
30 void ExchangeInterfaceProviders( | |
31 shell::mojom::InterfaceProviderRequest services, | |
32 shell::mojom::InterfaceProviderPtr exposed_services) override { | |
33 service_registry_->Bind(std::move(services)); | |
34 mojo::FuseInterface(service_registry_->TakeRemoteRequest(), | |
35 exposed_services.PassInterface()); | |
36 } | |
37 | |
38 mojo::Binding<mojom::ApplicationSetup> binding_; | |
39 ServiceRegistryImpl* service_registry_; | |
40 }; | |
41 | |
42 } // namespace | |
43 | |
44 MojoApplicationHost::MojoApplicationHost(const std::string& child_token) | |
45 : token_(mojo::edk::GenerateRandomToken()) { | |
46 #if defined(OS_ANDROID) | |
47 service_registry_android_ = | |
48 ServiceRegistryAndroid::Create(&service_registry_); | |
49 #endif | |
50 | |
51 mojo::ScopedMessagePipeHandle pipe = | |
52 mojo::edk::CreateParentMessagePipe(token_, child_token); | |
53 DCHECK(pipe.is_valid()); | |
54 application_setup_.reset(new ApplicationSetupImpl( | |
55 &service_registry_, | |
56 mojo::MakeRequest<mojom::ApplicationSetup>(std::move(pipe)))); | |
57 } | |
58 | |
59 MojoApplicationHost::~MojoApplicationHost() { | |
60 } | |
61 | |
62 } // namespace content | |
OLD | NEW |