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

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

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 #include "mojo/shell/runner/host/out_of_process_native_runner.h" 5 #include "mojo/shell/runner/host/out_of_process_native_runner.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/task_runner.h" 15 #include "base/task_runner.h"
16 #include "mojo/shell/runner/host/child_process_host.h" 16 #include "mojo/shell/runner/host/child_process_host.h"
17 #include "mojo/shell/runner/host/command_line_switch.h"
18 #include "mojo/shell/runner/host/in_process_native_runner.h" 17 #include "mojo/shell/runner/host/in_process_native_runner.h"
19 18
20 namespace mojo { 19 namespace mojo {
21 namespace shell { 20 namespace shell {
22 21
23 OutOfProcessNativeRunner::OutOfProcessNativeRunner( 22 OutOfProcessNativeRunner::OutOfProcessNativeRunner(
24 base::TaskRunner* launch_process_runner, 23 base::TaskRunner* launch_process_runner,
25 const std::vector<CommandLineSwitch>& command_line_switches) 24 NativeRunnerDelegate* delegate)
26 : launch_process_runner_(launch_process_runner), 25 : launch_process_runner_(launch_process_runner), delegate_(delegate) {}
27 command_line_switches_(command_line_switches) {}
28 26
29 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { 27 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() {
30 if (child_process_host_ && !app_path_.empty()) 28 if (child_process_host_ && !app_path_.empty())
31 child_process_host_->Join(); 29 child_process_host_->Join();
32 } 30 }
33 31
34 void OutOfProcessNativeRunner::Start( 32 void OutOfProcessNativeRunner::Start(
35 const base::FilePath& app_path, 33 const base::FilePath& app_path,
34 const Identity& target,
36 bool start_sandboxed, 35 bool start_sandboxed,
37 InterfaceRequest<mojom::ShellClient> request, 36 InterfaceRequest<mojom::ShellClient> request,
38 const base::Callback<void(base::ProcessId)>& pid_available_callback, 37 const base::Callback<void(base::ProcessId)>& pid_available_callback,
39 const base::Closure& app_completed_callback) { 38 const base::Closure& app_completed_callback) {
40 app_path_ = app_path; 39 app_path_ = app_path;
41 40
42 DCHECK(app_completed_callback_.is_null()); 41 DCHECK(app_completed_callback_.is_null());
43 app_completed_callback_ = app_completed_callback; 42 app_completed_callback_ = app_completed_callback;
44 43
45 child_process_host_.reset(new ChildProcessHost(launch_process_runner_, 44 child_process_host_.reset(new ChildProcessHost(
46 start_sandboxed, app_path, 45 launch_process_runner_, delegate_, start_sandboxed, target, app_path));
47 command_line_switches_));
48 child_process_host_->Start(base::Bind( 46 child_process_host_->Start(base::Bind(
49 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this), 47 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this),
50 base::Passed(&request), pid_available_callback)); 48 base::Passed(&request), pid_available_callback));
51 } 49 }
52 50
53 void OutOfProcessNativeRunner::InitHost( 51 void OutOfProcessNativeRunner::InitHost(
54 ScopedHandle channel, 52 ScopedHandle channel,
55 InterfaceRequest<mojom::ShellClient> request) { 53 InterfaceRequest<mojom::ShellClient> request) {
56 child_process_host_.reset(new ChildProcessHost(std::move(channel))); 54 child_process_host_.reset(new ChildProcessHost(std::move(channel)));
57 child_process_host_->StartApp( 55 child_process_host_->StartApp(
(...skipping 21 matching lines...) Expand all
79 DCHECK(child_process_host_); 77 DCHECK(child_process_host_);
80 child_process_host_->StartApp( 78 child_process_host_->StartApp(
81 std::move(request), 79 std::move(request),
82 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 80 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
83 base::Unretained(this))); 81 base::Unretained(this)));
84 pid_available_callback.Run(pid); 82 pid_available_callback.Run(pid);
85 } 83 }
86 84
87 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory( 85 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory(
88 base::TaskRunner* launch_process_runner, 86 base::TaskRunner* launch_process_runner,
89 const std::vector<CommandLineSwitch>& command_line_switches) 87 NativeRunnerDelegate* delegate)
90 : launch_process_runner_(launch_process_runner), 88 : launch_process_runner_(launch_process_runner), delegate_(delegate) {}
91 command_line_switches_(command_line_switches) {}
92 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {} 89 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {}
93 90
94 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( 91 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create(
95 const base::FilePath& app_path) { 92 const base::FilePath& app_path) {
96 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_, 93 return make_scoped_ptr(
97 command_line_switches_)); 94 new OutOfProcessNativeRunner(launch_process_runner_, delegate_));
98 } 95 }
99 96
100 } // namespace shell 97 } // namespace shell
101 } // namespace mojo 98 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698