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

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

Issue 1761153002: Replace ChildController with ShellClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@29binding
Patch Set: . 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
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
(...skipping 15 matching lines...) Expand all
26 26
27 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { 27 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() {
28 if (child_process_host_ && !app_path_.empty()) 28 if (child_process_host_ && !app_path_.empty())
29 child_process_host_->Join(); 29 child_process_host_->Join();
30 } 30 }
31 31
32 void OutOfProcessNativeRunner::Start( 32 void OutOfProcessNativeRunner::Start(
33 const base::FilePath& app_path, 33 const base::FilePath& app_path,
34 const Identity& target, 34 const Identity& target,
35 bool start_sandboxed, 35 bool start_sandboxed,
36 InterfaceRequest<mojom::ShellClient> request, 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(base::Bind( 46 child_process_host_->Start(base::Bind(
47 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this), 47 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this),
48 base::Passed(&request), pid_available_callback)); 48 base::Passed(&request), target.name(), pid_available_callback));
49 } 49 }
50 50
51 void OutOfProcessNativeRunner::InitHost( 51 void OutOfProcessNativeRunner::InitHost(
52 ScopedHandle channel, 52 mojom::ShellClientFactoryPtr factory,
53 InterfaceRequest<mojom::ShellClient> request) { 53 const String& name,
54 child_process_host_.reset(new ChildProcessHost(std::move(channel))); 54 mojom::ShellClientRequest request) {
55 child_process_host_->StartApp( 55 child_process_host_.reset(new ChildProcessHost(std::move(factory)));
56 std::move(request), 56 child_process_host_->StartChild(
57 std::move(request), name,
57 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 58 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
58 base::Unretained(this))); 59 base::Unretained(this)));
59 } 60 }
60 61
61 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { 62 void OutOfProcessNativeRunner::AppCompleted() {
62 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")";
63
64 if (child_process_host_) 63 if (child_process_host_)
65 child_process_host_->Join(); 64 child_process_host_->Join();
66 child_process_host_.reset(); 65 child_process_host_.reset();
67 // This object may be deleted by this callback. 66 // This object may be deleted by this callback.
68 base::Closure app_completed_callback = app_completed_callback_; 67 base::Closure app_completed_callback = app_completed_callback_;
69 app_completed_callback_.Reset(); 68 app_completed_callback_.Reset();
70 if (!app_completed_callback.is_null()) 69 if (!app_completed_callback.is_null())
71 app_completed_callback.Run(); 70 app_completed_callback.Run();
72 } 71 }
73 72
74 void OutOfProcessNativeRunner::OnProcessLaunched( 73 void OutOfProcessNativeRunner::OnProcessLaunched(
75 InterfaceRequest<mojom::ShellClient> request, 74 mojom::ShellClientRequest request,
75 const String& name,
76 const base::Callback<void(base::ProcessId)>& pid_available_callback, 76 const base::Callback<void(base::ProcessId)>& pid_available_callback,
77 base::ProcessId pid) { 77 base::ProcessId pid) {
78 DCHECK(child_process_host_); 78 DCHECK(child_process_host_);
79 child_process_host_->StartApp( 79 child_process_host_->StartChild(
80 std::move(request), 80 std::move(request), name,
81 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 81 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
82 base::Unretained(this))); 82 base::Unretained(this)));
83 pid_available_callback.Run(pid); 83 pid_available_callback.Run(pid);
84 } 84 }
85 85
86 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory( 86 OutOfProcessNativeRunnerFactory::OutOfProcessNativeRunnerFactory(
87 base::TaskRunner* launch_process_runner, 87 base::TaskRunner* launch_process_runner,
88 NativeRunnerDelegate* delegate) 88 NativeRunnerDelegate* delegate)
89 : launch_process_runner_(launch_process_runner), delegate_(delegate) {} 89 : launch_process_runner_(launch_process_runner), delegate_(delegate) {}
90 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {} 90 OutOfProcessNativeRunnerFactory::~OutOfProcessNativeRunnerFactory() {}
91 91
92 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( 92 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create(
93 const base::FilePath& app_path) { 93 const base::FilePath& app_path) {
94 return make_scoped_ptr( 94 return make_scoped_ptr(
95 new OutOfProcessNativeRunner(launch_process_runner_, delegate_)); 95 new OutOfProcessNativeRunner(launch_process_runner_, delegate_));
96 } 96 }
97 97
98 } // namespace shell 98 } // namespace shell
99 } // namespace mojo 99 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/out_of_process_native_runner.h ('k') | mojo/shell/tests/application_manager/driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698