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/runner/host/out_of_process_native_runner.h" | 5 #include "mojo/runner/host/out_of_process_native_runner.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
12 #include "mojo/runner/host/child_process_host.h" | 14 #include "mojo/runner/host/child_process_host.h" |
13 #include "mojo/runner/host/in_process_native_runner.h" | 15 #include "mojo/runner/host/in_process_native_runner.h" |
14 | 16 |
15 namespace mojo { | 17 namespace mojo { |
16 namespace runner { | 18 namespace runner { |
(...skipping 15 matching lines...) Expand all Loading... |
32 app_path_ = app_path; | 34 app_path_ = app_path; |
33 | 35 |
34 DCHECK(app_completed_callback_.is_null()); | 36 DCHECK(app_completed_callback_.is_null()); |
35 app_completed_callback_ = app_completed_callback; | 37 app_completed_callback_ = app_completed_callback; |
36 | 38 |
37 child_process_host_.reset( | 39 child_process_host_.reset( |
38 new ChildProcessHost(launch_process_runner_, start_sandboxed, app_path)); | 40 new ChildProcessHost(launch_process_runner_, start_sandboxed, app_path)); |
39 child_process_host_->Start(); | 41 child_process_host_->Start(); |
40 | 42 |
41 child_process_host_->StartApp( | 43 child_process_host_->StartApp( |
42 application_request.Pass(), | 44 std::move(application_request), |
43 base::Bind(&OutOfProcessNativeRunner::AppCompleted, | 45 base::Bind(&OutOfProcessNativeRunner::AppCompleted, |
44 base::Unretained(this))); | 46 base::Unretained(this))); |
45 } | 47 } |
46 | 48 |
47 void OutOfProcessNativeRunner::InitHost( | 49 void OutOfProcessNativeRunner::InitHost( |
48 ScopedHandle channel, | 50 ScopedHandle channel, |
49 InterfaceRequest<Application> application_request) { | 51 InterfaceRequest<Application> application_request) { |
50 child_process_host_.reset(new ChildProcessHost(channel.Pass())); | 52 child_process_host_.reset(new ChildProcessHost(std::move(channel))); |
51 child_process_host_->StartApp( | 53 child_process_host_->StartApp( |
52 application_request.Pass(), | 54 std::move(application_request), |
53 base::Bind(&OutOfProcessNativeRunner::AppCompleted, | 55 base::Bind(&OutOfProcessNativeRunner::AppCompleted, |
54 base::Unretained(this))); | 56 base::Unretained(this))); |
55 } | 57 } |
56 | 58 |
57 base::ProcessId OutOfProcessNativeRunner::GetApplicationPID() const { | 59 base::ProcessId OutOfProcessNativeRunner::GetApplicationPID() const { |
58 return child_process_host_->GetChildPID(); | 60 return child_process_host_->GetChildPID(); |
59 } | 61 } |
60 | 62 |
61 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { | 63 void OutOfProcessNativeRunner::AppCompleted(int32_t result) { |
62 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; | 64 DVLOG(2) << "OutOfProcessNativeRunner::AppCompleted(" << result << ")"; |
63 | 65 |
64 if (child_process_host_) | 66 if (child_process_host_) |
65 child_process_host_->Join(); | 67 child_process_host_->Join(); |
66 child_process_host_.reset(); | 68 child_process_host_.reset(); |
67 // This object may be deleted by this callback. | 69 // This object may be deleted by this callback. |
68 base::Closure app_completed_callback = app_completed_callback_; | 70 base::Closure app_completed_callback = app_completed_callback_; |
69 app_completed_callback_.Reset(); | 71 app_completed_callback_.Reset(); |
70 app_completed_callback.Run(); | 72 app_completed_callback.Run(); |
71 } | 73 } |
72 | 74 |
73 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( | 75 scoped_ptr<shell::NativeRunner> OutOfProcessNativeRunnerFactory::Create( |
74 const base::FilePath& app_path) { | 76 const base::FilePath& app_path) { |
75 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_)); | 77 return make_scoped_ptr(new OutOfProcessNativeRunner(launch_process_runner_)); |
76 } | 78 } |
77 | 79 |
78 } // namespace runner | 80 } // namespace runner |
79 } // namespace mojo | 81 } // namespace mojo |
OLD | NEW |