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

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

Issue 1801963002: Change primordial pipes to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase onto catalog CL Created 4 years, 9 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
« no previous file with comments | « mojo/shell/runner/host/out_of_process_native_runner.h ('k') | mojo/shell/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/client_util.h"
16 #include "mojo/shell/runner/host/child_process_host.h" 17 #include "mojo/shell/runner/host/child_process_host.h"
17 #include "mojo/shell/runner/host/in_process_native_runner.h" 18 #include "mojo/shell/runner/host/in_process_native_runner.h"
18 19
19 namespace mojo { 20 namespace mojo {
20 namespace shell { 21 namespace shell {
21 22
22 OutOfProcessNativeRunner::OutOfProcessNativeRunner( 23 OutOfProcessNativeRunner::OutOfProcessNativeRunner(
23 base::TaskRunner* launch_process_runner, 24 base::TaskRunner* launch_process_runner,
24 NativeRunnerDelegate* delegate) 25 NativeRunnerDelegate* delegate)
25 : launch_process_runner_(launch_process_runner), delegate_(delegate) {} 26 : launch_process_runner_(launch_process_runner), delegate_(delegate) {}
26 27
27 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { 28 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() {
28 if (child_process_host_ && !app_path_.empty()) 29 if (child_process_host_ && !app_path_.empty())
29 child_process_host_->Join(); 30 child_process_host_->Join();
30 } 31 }
31 32
32 void OutOfProcessNativeRunner::Start( 33 mojom::ShellClientPtr OutOfProcessNativeRunner::Start(
33 const base::FilePath& app_path, 34 const base::FilePath& app_path,
34 const Identity& target, 35 const Identity& target,
35 bool start_sandboxed, 36 bool start_sandboxed,
36 mojom::ShellClientRequest request,
37 const base::Callback<void(base::ProcessId)>& pid_available_callback, 37 const base::Callback<void(base::ProcessId)>& pid_available_callback,
38 const base::Closure& app_completed_callback) { 38 const base::Closure& app_completed_callback) {
39 app_path_ = app_path; 39 app_path_ = app_path;
40 40
41 DCHECK(app_completed_callback_.is_null()); 41 DCHECK(app_completed_callback_.is_null());
42 app_completed_callback_ = app_completed_callback; 42 app_completed_callback_ = app_completed_callback;
43 43
44 child_process_host_.reset(new ChildProcessHost( 44 child_process_host_.reset(new ChildProcessHost(
45 launch_process_runner_, delegate_, start_sandboxed, target, app_path)); 45 launch_process_runner_, delegate_, start_sandboxed, target, app_path));
46 child_process_host_->Start(std::move(request), target.name(), 46 return child_process_host_->Start(
47 pid_available_callback, 47 target.name(), pid_available_callback,
48 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 48 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
49 base::Unretained(this))); 49 base::Unretained(this)));
50 } 50 }
51 51
52 void OutOfProcessNativeRunner::AppCompleted() { 52 void OutOfProcessNativeRunner::AppCompleted() {
53 if (child_process_host_) 53 if (child_process_host_)
54 child_process_host_->Join(); 54 child_process_host_->Join();
55 child_process_host_.reset(); 55 child_process_host_.reset();
56 // This object may be deleted by this callback. 56 // This object may be deleted by this callback.
57 base::Closure app_completed_callback = app_completed_callback_; 57 base::Closure app_completed_callback = app_completed_callback_;
58 app_completed_callback_.Reset(); 58 app_completed_callback_.Reset();
59 if (!app_completed_callback.is_null()) 59 if (!app_completed_callback.is_null())
60 app_completed_callback.Run(); 60 app_completed_callback.Run();
61 } 61 }
62 62
63 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory( 63 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory(
64 base::TaskRunner* launch_process_runner, 64 base::TaskRunner* launch_process_runner,
65 NativeRunnerDelegate* delegate) 65 NativeRunnerDelegate* delegate)
66 : launch_process_runner_(launch_process_runner), delegate_(delegate) {} 66 : launch_process_runner_(launch_process_runner), delegate_(delegate) {}
67 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {} 67 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {}
68 68
69 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( 69 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create(
70 const base::FilePath& app_path) { 70 const base::FilePath& app_path) {
71 return make_scoped_ptr( 71 return make_scoped_ptr(
72 new OutOfProcessNativeRunner(launch_process_runner_, delegate_)); 72 new OutOfProcessNativeRunner(launch_process_runner_, delegate_));
73 } 73 }
74 74
75 } // namespace shell 75 } // namespace shell
76 } // namespace mojo 76 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/out_of_process_native_runner.h ('k') | mojo/shell/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698