| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ | 5 #ifndef MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ |
| 6 #define MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ | 6 #define MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "mojo/public/cpp/bindings/interface_request.h" | 12 #include "mojo/public/cpp/bindings/interface_request.h" |
| 13 #include "mojo/services/catalog/store.h" | 13 #include "mojo/services/catalog/store.h" |
| 14 #include "mojo/shell/public/interfaces/shell_client.mojom.h" | 14 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
| 15 | 15 |
| 16 namespace catalog { | 16 namespace catalog { |
| 17 class Store; | 17 class Store; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 namespace shell { | 21 namespace shell { |
| 22 | 22 |
| 23 class NativeRunnerDelegate; | 23 class NativeRunnerDelegate; |
| 24 class Shell; |
| 24 | 25 |
| 25 // BackgroundShell starts up the mojo shell on a background thread, and | 26 // BackgroundShell starts up the mojo shell on a background thread, and |
| 26 // destroys the thread in the destructor. Once created use CreateApplication() | 27 // destroys the thread in the destructor. Once created use CreateApplication() |
| 27 // to obtain an InterfaceRequest for the Application. The InterfaceRequest can | 28 // to obtain an InterfaceRequest for the Application. The InterfaceRequest can |
| 28 // then be bound to an ApplicationImpl. | 29 // then be bound to an ApplicationImpl. |
| 29 class BackgroundShell { | 30 class BackgroundShell { |
| 30 public: | 31 public: |
| 31 struct InitParams { | 32 struct InitParams { |
| 32 InitParams(); | 33 InitParams(); |
| 33 ~InitParams(); | 34 ~InitParams(); |
| 34 | 35 |
| 35 NativeRunnerDelegate* native_runner_delegate = nullptr; | 36 NativeRunnerDelegate* native_runner_delegate = nullptr; |
| 36 scoped_ptr<catalog::Store> catalog_store; | 37 scoped_ptr<catalog::Store> catalog_store; |
| 38 // If true the edk is initialized. |
| 39 bool init_edk = true; |
| 37 }; | 40 }; |
| 38 | 41 |
| 39 BackgroundShell(); | 42 BackgroundShell(); |
| 40 ~BackgroundShell(); | 43 ~BackgroundShell(); |
| 41 | 44 |
| 42 // Starts the background shell. |command_line_switches| are additional | 45 // Starts the background shell. |command_line_switches| are additional |
| 43 // switches applied to any processes spawned by this call. | 46 // switches applied to any processes spawned by this call. |
| 44 void Init(scoped_ptr<InitParams> init_params); | 47 void Init(scoped_ptr<InitParams> init_params); |
| 45 | 48 |
| 46 // Obtains an InterfaceRequest for the specified name. | 49 // Obtains an InterfaceRequest for the specified name. |
| 47 mojom::ShellClientRequest CreateShellClientRequest( | 50 mojom::ShellClientRequest CreateShellClientRequest( |
| 48 const std::string& name); | 51 const std::string& name); |
| 49 | 52 |
| 53 // Use to do processing on the thread running the shell. The callback is |
| 54 // supplied a pointer to the Shell. The callback does *not* own the Shell. |
| 55 using ShellThreadCallback = base::Callback<void(Shell*)>; |
| 56 void ExecuteOnShellThread(const ShellThreadCallback& callback); |
| 57 |
| 50 private: | 58 private: |
| 51 class MojoThread; | 59 class MojoThread; |
| 52 | 60 |
| 53 scoped_ptr<MojoThread> thread_; | 61 scoped_ptr<MojoThread> thread_; |
| 54 | 62 |
| 55 DISALLOW_COPY_AND_ASSIGN(BackgroundShell); | 63 DISALLOW_COPY_AND_ASSIGN(BackgroundShell); |
| 56 }; | 64 }; |
| 57 | 65 |
| 58 } // namespace shell | 66 } // namespace shell |
| 59 } // namespace mojo | 67 } // namespace mojo |
| 60 | 68 |
| 61 #endif // MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ | 69 #endif // MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_ |
| OLD | NEW |