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/in_process_native_runner.h" | 5 #include "mojo/shell/runner/host/in_process_native_runner.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
15 #include "mojo/shell/runner/host/command_line_switch.h" | |
16 #include "mojo/shell/runner/host/native_application_support.h" | 15 #include "mojo/shell/runner/host/native_application_support.h" |
17 #include "mojo/shell/runner/host/out_of_process_native_runner.h" | 16 #include "mojo/shell/runner/host/out_of_process_native_runner.h" |
18 #include "mojo/shell/runner/init.h" | 17 #include "mojo/shell/runner/init.h" |
19 | 18 |
20 namespace mojo { | 19 namespace mojo { |
21 namespace shell { | 20 namespace shell { |
22 | 21 |
23 InProcessNativeRunner::InProcessNativeRunner() : app_library_(nullptr) {} | 22 InProcessNativeRunner::InProcessNativeRunner() : app_library_(nullptr) {} |
24 | 23 |
25 InProcessNativeRunner::~InProcessNativeRunner() { | 24 InProcessNativeRunner::~InProcessNativeRunner() { |
26 // It is important to let the thread exit before unloading the DSO (when | 25 // It is important to let the thread exit before unloading the DSO (when |
27 // app_library_ is destructed), because the library may have registered | 26 // app_library_ is destructed), because the library may have registered |
28 // thread-local data and destructors to run on thread termination. | 27 // thread-local data and destructors to run on thread termination. |
29 if (thread_) { | 28 if (thread_) { |
30 DCHECK(thread_->HasBeenStarted()); | 29 DCHECK(thread_->HasBeenStarted()); |
31 DCHECK(!thread_->HasBeenJoined()); | 30 DCHECK(!thread_->HasBeenJoined()); |
32 thread_->Join(); | 31 thread_->Join(); |
33 } | 32 } |
34 } | 33 } |
35 | 34 |
36 void InProcessNativeRunner::Start( | 35 void InProcessNativeRunner::Start( |
37 const base::FilePath& app_path, | 36 const base::FilePath& app_path, |
| 37 const Identity& target, |
38 bool start_sandboxed, | 38 bool start_sandboxed, |
39 InterfaceRequest<mojom::ShellClient> request, | 39 InterfaceRequest<mojom::ShellClient> request, |
40 const base::Callback<void(base::ProcessId)>& pid_available_callback, | 40 const base::Callback<void(base::ProcessId)>& pid_available_callback, |
41 const base::Closure& app_completed_callback) { | 41 const base::Closure& app_completed_callback) { |
42 app_path_ = app_path; | 42 app_path_ = app_path; |
43 | 43 |
44 DCHECK(!request_.is_pending()); | 44 DCHECK(!request_.is_pending()); |
45 request_ = std::move(request); | 45 request_ = std::move(request); |
46 | 46 |
47 DCHECK(app_completed_callback_runner_.is_null()); | 47 DCHECK(app_completed_callback_runner_.is_null()); |
(...skipping 28 matching lines...) Expand all Loading... |
76 #endif | 76 #endif |
77 RunNativeApplication(app_library, std::move(request_)); | 77 RunNativeApplication(app_library, std::move(request_)); |
78 app_completed_callback_runner_.Run(); | 78 app_completed_callback_runner_.Run(); |
79 app_completed_callback_runner_.Reset(); | 79 app_completed_callback_runner_.Reset(); |
80 } | 80 } |
81 | 81 |
82 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( | 82 scoped_ptr<NativeRunner> InProcessNativeRunnerFactory::Create( |
83 const base::FilePath& app_path) { | 83 const base::FilePath& app_path) { |
84 // Non-Mojo apps are always run in a new process. | 84 // Non-Mojo apps are always run in a new process. |
85 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { | 85 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { |
86 return make_scoped_ptr(new OutOfProcessNativeRunner( | 86 return make_scoped_ptr( |
87 launch_process_runner_, std::vector<CommandLineSwitch>())); | 87 new OutOfProcessNativeRunner(launch_process_runner_, nullptr)); |
88 } | 88 } |
89 return make_scoped_ptr(new InProcessNativeRunner); | 89 return make_scoped_ptr(new InProcessNativeRunner); |
90 } | 90 } |
91 | 91 |
92 } // namespace shell | 92 } // namespace shell |
93 } // namespace mojo | 93 } // namespace mojo |
OLD | NEW |