OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 InterfaceRequest<Application> application_request, | 34 InterfaceRequest<Application> application_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(pid_available_callback); | 44 child_process_host_->Start(base::Bind( |
45 | 45 &OutOfProcessNativeRunner::OnProcessLaunched, base::Unretained(this), |
46 child_process_host_->StartApp( | 46 base::Passed(&application_request), pid_available_callback)); |
47 std::move(application_request), | |
48 base::Bind(&OutOfProcessNativeRunner::AppCompleted, | |
49 base::Unretained(this))); | |
50 } | 47 } |
51 | 48 |
52 void OutOfProcessNativeRunner::InitHost( | 49 void OutOfProcessNativeRunner::InitHost( |
53 ScopedHandle channel, | 50 ScopedHandle channel, |
54 InterfaceRequest<Application> application_request) { | 51 InterfaceRequest<Application> application_request) { |
55 child_process_host_.reset(new ChildProcessHost(std::move(channel))); | 52 child_process_host_.reset(new ChildProcessHost(std::move(channel))); |
56 child_process_host_->StartApp( | 53 child_process_host_->StartApp( |
57 std::move(application_request), | 54 std::move(application_request), |
58 base::Bind(&OutOfProcessNativeRunner::AppCompleted, | 55 base::Bind(&OutOfProcessNativeRunner::AppCompleted, |
59 base::Unretained(this))); | 56 base::Unretained(this))); |
60 } | 57 } |
61 | 58 |
62 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { | 59 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { |
63 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; | 60 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; |
64 | 61 |
65 if (child_process_host_) | 62 if (child_process_host_) |
66 child_process_host_->Join(); | 63 child_process_host_->Join(); |
67 child_process_host_.reset(); | 64 child_process_host_.reset(); |
68 // This object may be deleted by this callback. | 65 // This object may be deleted by this callback. |
69 base::Closure app_completed_callback = app_completed_callback_; | 66 base::Closure app_completed_callback = app_completed_callback_; |
70 app_completed_callback_.Reset(); | 67 app_completed_callback_.Reset(); |
71 app_completed_callback.Run(); | 68 app_completed_callback.Run(); |
72 } | 69 } |
73 | 70 |
74 scoped_ptr<NativeRunner> OutOfProcessNativeRunnerFactory::Create( | 71 void OutOfProcessNativeRunner::OnProcessLaunched( |
| 72 InterfaceRequest<Application> application_request, |
| 73 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
| 74 base::ProcessId pid) { |
| 75 DCHECK(child_process_host_); |
| 76 child_process_host_->StartApp( |
| 77 std::move(application_request), |
| 78 base::Bind(&OutOfProcessNativeRunner::AppCompleted, |
| 79 base::Unretained(this))); |
| 80 pid_available_callback.Run(pid); |
| 81 } |
| 82 |
| 83 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( |
75 const base::FilePath& app_path) { | 84 const base::FilePath& app_path) { |
76 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_)); | 85 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_)); |
77 } | 86 } |
78 | 87 |
79 } // namespace shell | 88 } // namespace shell |
80 } // namespace mojo | 89 } // namespace mojo |
OLD | NEW |