OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | |
6 #define MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/callback.h" | |
13 #include "base/files/file_path.h" | |
14 #include "base/macros.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "mojo/shell/native_runner.h" | |
17 | |
18 namespace base { | |
19 class TaskRunner; | |
20 } | |
21 | |
22 namespace mojo { | |
23 namespace shell { | |
24 | |
25 class ChildProcessHost; | |
26 class NativeRunnerDelegate; | |
27 | |
28 // An implementation of |NativeRunner| that loads/runs the given app (from the | |
29 // file system) in a separate process (of its own). | |
30 class OutOfProcessNativeRunner : public NativeRunner { | |
31 public: | |
32 OutOfProcessNativeRunner(base::TaskRunner* launch_process_runner, | |
33 NativeRunnerDelegate* delegate); | |
34 ~OutOfProcessNativeRunner() override; | |
35 | |
36 // NativeRunner: | |
37 mojom::ShellClientPtr Start( | |
38 const base::FilePath& app_path, | |
39 const Identity& identity, | |
40 bool start_sandboxed, | |
41 const base::Callback<void(base::ProcessId)>& pid_available_callback, | |
42 const base::Closure& app_completed_callback) override; | |
43 | |
44 private: | |
45 void AppCompleted(); | |
46 | |
47 base::TaskRunner* const launch_process_runner_; | |
48 NativeRunnerDelegate* delegate_; | |
49 | |
50 base::FilePath app_path_; | |
51 base::Closure app_completed_callback_; | |
52 | |
53 scoped_ptr<ChildProcessHost> child_process_host_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner); | |
56 }; | |
57 | |
58 class OutOfProcessNativeRunnerFactory : public NativeRunnerFactory { | |
59 public: | |
60 OutOfProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner, | |
61 NativeRunnerDelegate* delegate); | |
62 ~OutOfProcessNativeRunnerFactory() override; | |
63 | |
64 scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override; | |
65 | |
66 private: | |
67 base::TaskRunner* const launch_process_runner_; | |
68 NativeRunnerDelegate* delegate_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); | |
71 }; | |
72 | |
73 } // namespace shell | |
74 } // namespace mojo | |
75 | |
76 #endif // MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ | |
OLD | NEW |