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