| 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 MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 5 #ifndef MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| 6 #define MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 6 #define MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "mojo/shell/native_runner.h" | 14 #include "mojo/shell/native_runner.h" |
| 15 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class TaskRunner; | 18 class TaskRunner; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace mojo { | 21 namespace mojo { |
| 21 namespace shell { | 22 namespace shell { |
| 22 | 23 |
| 23 class ChildProcessHost; | 24 class ChildProcessHost; |
| 24 class NativeRunnerDelegate; | 25 class NativeRunnerDelegate; |
| 25 | 26 |
| 26 // An implementation of |NativeRunner| that loads/runs the given app (from the | 27 // An implementation of |NativeRunner| that loads/runs the given app (from the |
| 27 // file system) in a separate process (of its own). | 28 // file system) in a separate process (of its own). |
| 28 class OutOfProcessNativeRunner : public NativeRunner { | 29 class OutOfProcessNativeRunner : public NativeRunner { |
| 29 public: | 30 public: |
| 30 OutOfProcessNativeRunner(base::TaskRunner* launch_process_runner, | 31 OutOfProcessNativeRunner(base::TaskRunner* launch_process_runner, |
| 31 NativeRunnerDelegate* delegate); | 32 NativeRunnerDelegate* delegate); |
| 32 ~OutOfProcessNativeRunner() override; | 33 ~OutOfProcessNativeRunner() override; |
| 33 | 34 |
| 34 // NativeRunner: | 35 // NativeRunner: |
| 35 void Start( | 36 void Start( |
| 36 const base::FilePath& app_path, | 37 const base::FilePath& app_path, |
| 37 const Identity& identity, | 38 const Identity& identity, |
| 38 bool start_sandboxed, | 39 bool start_sandboxed, |
| 39 InterfaceRequest<mojom::ShellClient> request, | 40 mojom::ShellClientRequest request, |
| 40 const base::Callback<void(base::ProcessId)>& pid_available_callback, | 41 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
| 41 const base::Closure& app_completed_callback) override; | 42 const base::Closure& app_completed_callback) override; |
| 42 void InitHost( | 43 void InitHost(mojom::ShellClientFactoryPtr factory, |
| 43 ScopedHandle channel, | 44 const String& name, |
| 44 InterfaceRequest<mojom::ShellClient> request) override; | 45 mojom::ShellClientRequest request) override; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 // |ChildController::StartApp()| callback: | 48 void AppCompleted(); |
| 48 void AppCompleted(int32_t result); | |
| 49 | 49 |
| 50 // Callback run when the child process has launched. | 50 // Callback run when the child process has launched. |
| 51 void OnProcessLaunched( | 51 void OnProcessLaunched( |
| 52 InterfaceRequest<mojom::ShellClient> request, | 52 mojom::ShellClientRequest request, |
| 53 const String& name, |
| 53 const base::Callback<void(base::ProcessId)>& pid_available_callback, | 54 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
| 54 base::ProcessId pid); | 55 base::ProcessId pid); |
| 55 | 56 |
| 56 base::TaskRunner* const launch_process_runner_; | 57 base::TaskRunner* const launch_process_runner_; |
| 57 NativeRunnerDelegate* delegate_; | 58 NativeRunnerDelegate* delegate_; |
| 58 | 59 |
| 59 base::FilePath app_path_; | 60 base::FilePath app_path_; |
| 60 base::Closure app_completed_callback_; | 61 base::Closure app_completed_callback_; |
| 61 | 62 |
| 62 scoped_ptr<ChildProcessHost> child_process_host_; | 63 scoped_ptr<ChildProcessHost> child_process_host_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 76 base::TaskRunner* const launch_process_runner_; | 77 base::TaskRunner* const launch_process_runner_; |
| 77 NativeRunnerDelegate* delegate_; | 78 NativeRunnerDelegate* delegate_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); | 80 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 } // namespace shell | 83 } // namespace shell |
| 83 } // namespace mojo | 84 } // namespace mojo |
| 84 | 85 |
| 85 #endif // MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | 86 #endif // MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ |
| OLD | NEW |