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

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

Issue 1675153002: ApplicationImpl->ShellConnection, mojom::Application->mojom::ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ci2
Patch Set: . 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
(...skipping 13 matching lines...) Expand all
24 : launch_process_runner_(launch_process_runner) {} 24 : launch_process_runner_(launch_process_runner) {}
25 25
26 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() { 26 OutOfProcessNativeRunner::~OutOfProcessNativeRunner() {
27 if (child_process_host_ && !app_path_.empty()) 27 if (child_process_host_ && !app_path_.empty())
28 child_process_host_->Join(); 28 child_process_host_->Join();
29 } 29 }
30 30
31 void OutOfProcessNativeRunner::Start( 31 void OutOfProcessNativeRunner::Start(
32 const base::FilePath& app_path, 32 const base::FilePath& app_path,
33 bool start_sandboxed, 33 bool start_sandboxed,
34 InterfaceRequest<mojom::Application> application_request, 34 InterfaceRequest<mojom::ShellClient> request,
35 const base::Callback<void(base::ProcessId)>& pid_available_callback, 35 const base::Callback<void(base::ProcessId)>& pid_available_callback,
36 const base::Closure& app_completed_callback) { 36 const base::Closure& app_completed_callback) {
37 app_path_ = app_path; 37 app_path_ = app_path;
38 38
39 DCHECK(app_completed_callback_.is_null()); 39 DCHECK(app_completed_callback_.is_null());
40 app_completed_callback_ = app_completed_callback; 40 app_completed_callback_ = app_completed_callback;
41 41
42 child_process_host_.reset( 42 child_process_host_.reset(
43 new ChildProcessHost(launch_process_runner_, start_sandboxed, app_path)); 43 new ChildProcessHost(launch_process_runner_, start_sandboxed, app_path));
44 child_process_host_->Start(base::Bind( 44 child_process_host_->Start(base::Bind(
45 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this), 45 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this),
46 base::Passed(&application_request), pid_available_callback)); 46 base::Passed(&request), pid_available_callback));
47 } 47 }
48 48
49 void OutOfProcessNativeRunner::InitHost( 49 void OutOfProcessNativeRunner::InitHost(
50 ScopedHandle channel, 50 ScopedHandle channel,
51 InterfaceRequest<mojom::Application> application_request) { 51 InterfaceRequest<mojom::ShellClient> request) {
52 child_process_host_.reset(new ChildProcessHost(std::move(channel))); 52 child_process_host_.reset(new ChildProcessHost(std::move(channel)));
53 child_process_host_->StartApp( 53 child_process_host_->StartApp(
54 std::move(application_request), 54 std::move(request),
55 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 55 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
56 base::Unretained(this))); 56 base::Unretained(this)));
57 } 57 }
58 58
59 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { 59 void OutOfProcessNativeRunner::AppCompleted(int32_t result) {
60 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; 60 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")";
61 61
62 if (child_process_host_) 62 if (child_process_host_)
63 child_process_host_->Join(); 63 child_process_host_->Join();
64 child_process_host_.reset(); 64 child_process_host_.reset();
65 // This object may be deleted by this callback. 65 // This object may be deleted by this callback.
66 base::Closure app_completed_callback = app_completed_callback_; 66 base::Closure app_completed_callback = app_completed_callback_;
67 app_completed_callback_.Reset(); 67 app_completed_callback_.Reset();
68 app_completed_callback.Run(); 68 app_completed_callback.Run();
69 } 69 }
70 70
71 void OutOfProcessNativeRunner::OnProcessLaunched( 71 void OutOfProcessNativeRunner::OnProcessLaunched(
72 InterfaceRequest<mojom::Application> application_request, 72 InterfaceRequest<mojom::ShellClient> request,
73 const base::Callback<void(base::ProcessId)>& pid_available_callback, 73 const base::Callback<void(base::ProcessId)>& pid_available_callback,
74 base::ProcessId pid) { 74 base::ProcessId pid) {
75 DCHECK(child_process_host_); 75 DCHECK(child_process_host_);
76 child_process_host_->StartApp( 76 child_process_host_->StartApp(
77 std::move(application_request), 77 std::move(request),
78 base::Bind(&OutOfProcessNativeRunner::AppCompleted, 78 base::Bind(&OutOfProcessNativeRunner::AppCompleted,
79 base::Unretained(this))); 79 base::Unretained(this)));
80 pid_available_callback.Run(pid); 80 pid_available_callback.Run(pid);
81 } 81 }
82 82
83 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( 83 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create(
84 const base::FilePath& app_path) { 84 const base::FilePath& app_path) {
85 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_)); 85 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_));
86 } 86 }
87 87
88 } // namespace shell 88 } // namespace shell
89 } // namespace mojo 89 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/out_of_process_native_runner.h ('k') | mojo/shell/shell_application_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698