Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: mojo/shell/runner/host/out_of_process_native_runner.h

Issue 1722743002: Adds ability for chrome to behave as mojo_runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to tip of tree Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector>
11
12 #include "base/callback.h" 10 #include "base/callback.h"
13 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
14 #include "base/macros.h" 12 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "mojo/shell/native_runner.h" 14 #include "mojo/shell/native_runner.h"
17 15
18 namespace base { 16 namespace base {
19 class TaskRunner; 17 class TaskRunner;
20 } 18 }
21 19
22 namespace mojo { 20 namespace mojo {
23 namespace shell { 21 namespace shell {
24 22
25 class ChildProcessHost; 23 class ChildProcessHost;
26 struct CommandLineSwitch; 24 class NativeRunnerDelegate;
27 25
28 // An implementation of |NativeRunner| that loads/runs the given app (from the 26 // An implementation of |NativeRunner| that loads/runs the given app (from the
29 // file system) in a separate process (of its own). 27 // file system) in a separate process (of its own).
30 class OutOfProcessNativeRunner : public NativeRunner { 28 class OutOfProcessNativeRunner : public NativeRunner {
31 public: 29 public:
32 OutOfProcessNativeRunner( 30 OutOfProcessNativeRunner(base::TaskRunner* launch_process_runner,
33 base::TaskRunner* launch_process_runner, 31 NativeRunnerDelegate* delegate);
34 const std::vector<CommandLineSwitch>& command_line_switches);
35 ~OutOfProcessNativeRunner() override; 32 ~OutOfProcessNativeRunner() override;
36 33
37 // NativeRunner: 34 // NativeRunner:
38 void Start( 35 void Start(
39 const base::FilePath& app_path, 36 const base::FilePath& app_path,
37 const Identity& identity,
40 bool start_sandboxed, 38 bool start_sandboxed,
41 InterfaceRequest<mojom::ShellClient> request, 39 InterfaceRequest<mojom::ShellClient> request,
42 const base::Callback<void(base::ProcessId)>& pid_available_callback, 40 const base::Callback<void(base::ProcessId)>& pid_available_callback,
43 const base::Closure& app_completed_callback) override; 41 const base::Closure& app_completed_callback) override;
44 void InitHost( 42 void InitHost(
45 ScopedHandle channel, 43 ScopedHandle channel,
46 InterfaceRequest<mojom::ShellClient> request) override; 44 InterfaceRequest<mojom::ShellClient> request) override;
47 45
48 private: 46 private:
49 // |ChildController::StartApp()| callback: 47 // |ChildController::StartApp()| callback:
50 void AppCompleted(int32_t result); 48 void AppCompleted(int32_t result);
51 49
52 // Callback run when the child process has launched. 50 // Callback run when the child process has launched.
53 void OnProcessLaunched( 51 void OnProcessLaunched(
54 InterfaceRequest<mojom::ShellClient> request, 52 InterfaceRequest<mojom::ShellClient> request,
55 const base::Callback<void(base::ProcessId)>& pid_available_callback, 53 const base::Callback<void(base::ProcessId)>& pid_available_callback,
56 base::ProcessId pid); 54 base::ProcessId pid);
57 55
58 base::TaskRunner* const launch_process_runner_; 56 base::TaskRunner* const launch_process_runner_;
57 NativeRunnerDelegate* delegate_;
59 58
60 base::FilePath app_path_; 59 base::FilePath app_path_;
61 base::Closure app_completed_callback_; 60 base::Closure app_completed_callback_;
62 61
63 std::vector<CommandLineSwitch> command_line_switches_;
64
65 scoped_ptr<ChildProcessHost> child_process_host_; 62 scoped_ptr<ChildProcessHost> child_process_host_;
66 63
67 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner); 64 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunner);
68 }; 65 };
69 66
70 class OutOfProcessNativeRunnerFactory : public NativeRunnerFactory { 67 class OutOfProcessNativeRunnerFactory : public NativeRunnerFactory {
71 public: 68 public:
72 OutOfProcessNativeRunnerFactory( 69 OutOfProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner,
73 base::TaskRunner* launch_process_runner, 70 NativeRunnerDelegate* delegate);
74 const std::vector<CommandLineSwitch>& command_line_switches);
75 ~OutOfProcessNativeRunnerFactory() override; 71 ~OutOfProcessNativeRunnerFactory() override;
76 72
77 scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override; 73 scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override;
78 74
79 private: 75 private:
80 base::TaskRunner* const launch_process_runner_; 76 base::TaskRunner* const launch_process_runner_;
81 std::vector<CommandLineSwitch> command_line_switches_; 77 NativeRunnerDelegate* delegate_;
82 78
83 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory); 79 DISALLOW_COPY_AND_ASSIGN(OutOfProcessNativeRunnerFactory);
84 }; 80 };
85 81
86 } // namespace shell 82 } // namespace shell
87 } // namespace mojo 83 } // namespace mojo
88 84
89 #endif // MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_ 85 #endif // MOJO_SHELL_RUNNER_HOST_OUT_OF_PROCESS_NATIVE_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698