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 #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ |
6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | 6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/application_setup.mojom.h" | 12 #include "content/common/application_setup.mojom.h" |
13 #include "content/common/mojo/channel_init.h" | 13 #include "content/common/mojo/channel_init.h" |
14 #include "content/common/mojo/service_registry_impl.h" | 14 #include "content/common/mojo/service_registry_impl.h" |
15 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" | 15 #include "mojo/edk/embedder/scoped_platform_handle.h" |
16 | 16 |
17 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
18 #include "content/browser/mojo/service_registry_android.h" | 18 #include "content/browser/mojo/service_registry_android.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace IPC { | 21 namespace IPC { |
22 class Sender; | 22 class Sender; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 // MojoApplicationHost represents the code needed on the browser side to setup | 27 // MojoApplicationHost represents the code needed on the browser side to setup |
28 // a child process as a Mojo application via Chrome IPC. The child process | 28 // a child process as a Mojo application via Chrome IPC. The child process |
29 // should use MojoApplication to handle messages generated by an instance of | 29 // should use MojoApplication to handle messages generated by an instance of |
30 // MojoApplicationHost. MojoApplicationHost makes the ServiceRegistry interface | 30 // MojoApplicationHost. MojoApplicationHost makes the ServiceRegistry interface |
31 // available so that child-provided services can be invoked. | 31 // available so that child-provided services can be invoked. |
32 class CONTENT_EXPORT MojoApplicationHost { | 32 class CONTENT_EXPORT MojoApplicationHost { |
33 public: | 33 public: |
34 MojoApplicationHost(); | 34 MojoApplicationHost(); |
35 ~MojoApplicationHost(); | 35 ~MojoApplicationHost(); |
36 | 36 |
37 // Two-phase initialization: | 37 // Two-phase initialization: |
38 // 1- Init makes service_registry() available synchronously. | 38 // 1- Init makes service_registry() available synchronously. |
39 // 2- Activate establishes the actual connection to the peer process. | 39 // 2- Activate establishes the actual connection to the peer process. |
40 bool Init(); | 40 bool Init(); |
41 void Activate(IPC::Sender* sender, base::ProcessHandle process_handle); | 41 void Activate(IPC::Sender* sender, base::ProcessHandle process_handle); |
42 | 42 |
43 void WillDestroySoon(); | |
44 | |
45 ServiceRegistry* service_registry() { return &service_registry_; } | 43 ServiceRegistry* service_registry() { return &service_registry_; } |
46 | 44 |
47 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
48 ServiceRegistryAndroid* service_registry_android() { | 46 ServiceRegistryAndroid* service_registry_android() { |
49 return service_registry_android_.get(); | 47 return service_registry_android_.get(); |
50 } | 48 } |
51 #endif | 49 #endif |
52 | 50 |
53 void OverrideIOTaskRunnerForTest( | 51 void OverrideIOTaskRunnerForTest( |
54 scoped_refptr<base::TaskRunner> io_task_runner); | 52 scoped_refptr<base::TaskRunner> io_task_runner); |
55 | 53 |
56 private: | 54 private: |
57 ChannelInit channel_init_; | 55 ChannelInit channel_init_; |
58 mojo::embedder::ScopedPlatformHandle client_handle_; | 56 mojo::edk::ScopedPlatformHandle client_handle_; |
59 | 57 |
60 bool did_activate_; | 58 bool did_activate_; |
61 | 59 |
62 scoped_ptr<ApplicationSetup> application_setup_; | 60 scoped_ptr<ApplicationSetup> application_setup_; |
63 ServiceRegistryImpl service_registry_; | 61 ServiceRegistryImpl service_registry_; |
64 | 62 |
65 scoped_refptr<base::TaskRunner> io_task_runner_override_; | 63 scoped_refptr<base::TaskRunner> io_task_runner_override_; |
66 | 64 |
67 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
68 scoped_ptr<ServiceRegistryAndroid> service_registry_android_; | 66 scoped_ptr<ServiceRegistryAndroid> service_registry_android_; |
69 #endif | 67 #endif |
70 | 68 |
71 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost); | 69 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost); |
72 }; | 70 }; |
73 | 71 |
74 } // namespace content | 72 } // namespace content |
75 | 73 |
76 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ | 74 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_ |
OLD | NEW |