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