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