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 #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | |
6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "build/build_config.h" | |
13 #include "content/common/application_setup.mojom.h" | |
14 #include "content/common/mojo/service_registry_impl.h" | |
15 | |
16 #if defined(OS_ANDROID) | |
17 #include "content/public/browser/android/service_registry_android.h" | |
18 #endif | |
19 | |
20 namespace IPC { | |
21 class Sender; | |
22 } | |
23 | |
24 namespace content { | |
25 | |
26 // MojoApplicationHost represents the code needed on the browser side to setup | |
27 // a child process as a Mojo application. The child process should use the token | |
28 // from GetToken() to initialize its MojoApplication. MojoApplicationHost makes | |
29 // the ServiceRegistry interface available so that child-provided services can | |
30 // be invoked. | |
31 class CONTENT_EXPORT MojoApplicationHost { | |
32 public: | |
33 explicit MojoApplicationHost(const std::string& child_token); | |
34 ~MojoApplicationHost(); | |
35 | |
36 // Returns a token to pass to the child process to initialize its | |
37 // MojoApplication. | |
38 const std::string& GetToken() { return token_; } | |
39 | |
40 ServiceRegistry* service_registry() { return &service_registry_; } | |
41 | |
42 #if defined(OS_ANDROID) | |
43 ServiceRegistryAndroid* service_registry_android() { | |
44 return service_registry_android_.get(); | |
45 } | |
46 #endif | |
47 | |
48 private: | |
49 const std::string token_; | |
50 | |
51 std::unique_ptr<mojom::ApplicationSetup> application_setup_; | |
52 ServiceRegistryImpl service_registry_; | |
53 | |
54 #if defined(OS_ANDROID) | |
55 std::unique_ptr<ServiceRegistryAndroid> service_registry_android_; | |
56 #endif | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost); | |
59 }; | |
60 | |
61 } // namespace content | |
62 | |
63 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | |
OLD | NEW |