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_CHILD_MOJO_MOJO_APPLICATION_H_ | 5 #ifndef CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_ |
6 #define CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_ | 6 #define CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "content/common/mojo/channel_init.h" | 11 #include "content/common/mojo/channel_init.h" |
10 #include "content/common/mojo/service_registry_impl.h" | 12 #include "content/common/mojo/service_registry_impl.h" |
11 #include "ipc/ipc_platform_file.h" | 13 #include "ipc/ipc_platform_file.h" |
| 14 #include "mojo/public/cpp/system/message_pipe.h" |
12 | 15 |
13 namespace base { | 16 namespace base { |
14 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
15 } | 18 } |
16 | 19 |
17 namespace IPC { | 20 namespace IPC { |
18 class Message; | 21 class Message; |
19 } | 22 } |
20 | 23 |
21 namespace content { | 24 namespace content { |
22 | 25 |
23 // MojoApplication represents the code needed to setup a child process as a | 26 // MojoApplication represents the code needed to setup a child process as a |
24 // Mojo application via Chrome IPC. Instantiate MojoApplication and call its | 27 // Mojo application via Chrome IPC. Instantiate MojoApplication and call its |
25 // OnMessageReceived method to give it a shot at handling Chrome IPC messages. | 28 // OnMessageReceived method to give it a shot at handling Chrome IPC messages. |
26 // It makes the ServiceRegistry interface available. | 29 // It makes the ServiceRegistry interface available. |
27 class MojoApplication { | 30 class MojoApplication { |
28 public: | 31 public: |
29 explicit MojoApplication( | 32 explicit MojoApplication( |
30 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 33 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
31 virtual ~MojoApplication(); | 34 virtual ~MojoApplication(); |
32 | 35 |
| 36 // TODO(amistry): Remove OnMessageReceived() when all bootstrapping has |
| 37 // migrated to these functions. |
| 38 void InitWithToken(std::string token); |
| 39 |
33 bool OnMessageReceived(const IPC::Message& msg); | 40 bool OnMessageReceived(const IPC::Message& msg); |
34 | 41 |
35 ServiceRegistry* service_registry() { return &service_registry_; } | 42 ServiceRegistry* service_registry() { return &service_registry_; } |
36 | 43 |
37 private: | 44 private: |
38 void OnActivate(const IPC::PlatformFileForTransit& file); | 45 void OnActivate(const IPC::PlatformFileForTransit& file); |
39 | 46 |
40 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | 47 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
41 ChannelInit channel_init_; | 48 ChannelInit channel_init_; |
42 ServiceRegistryImpl service_registry_; | 49 ServiceRegistryImpl service_registry_; |
43 | 50 |
44 DISALLOW_COPY_AND_ASSIGN(MojoApplication); | 51 DISALLOW_COPY_AND_ASSIGN(MojoApplication); |
45 }; | 52 }; |
46 | 53 |
47 } // namespace content | 54 } // namespace content |
48 | 55 |
49 #endif // CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_ | 56 #endif // CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_ |
OLD | NEW |