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