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 "services/shell/runner/host/in_process_native_runner.h" | 5 #include "services/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/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/process/process.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
16 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
17 #include "mojo/public/cpp/bindings/interface_request.h" | 18 #include "mojo/public/cpp/bindings/interface_request.h" |
18 #include "services/shell/runner/host/native_application_support.h" | 19 #include "services/shell/runner/host/native_application_support.h" |
19 #include "services/shell/runner/host/out_of_process_native_runner.h" | 20 #include "services/shell/runner/host/out_of_process_native_runner.h" |
20 #include "services/shell/runner/init.h" | 21 #include "services/shell/runner/init.h" |
21 | 22 |
22 namespace shell { | 23 namespace shell { |
(...skipping 28 matching lines...) Expand all Loading... |
51 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(), | 52 &base::TaskRunner::PostTask, base::ThreadTaskRunnerHandle::Get(), |
52 FROM_HERE, app_completed_callback); | 53 FROM_HERE, app_completed_callback); |
53 | 54 |
54 DCHECK(!thread_); | 55 DCHECK(!thread_); |
55 std::string thread_name = "mojo:app_thread"; | 56 std::string thread_name = "mojo:app_thread"; |
56 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
57 thread_name = base::WideToUTF8(app_path_.BaseName().value()); | 58 thread_name = base::WideToUTF8(app_path_.BaseName().value()); |
58 #endif | 59 #endif |
59 thread_.reset(new base::DelegateSimpleThread(this, thread_name)); | 60 thread_.reset(new base::DelegateSimpleThread(this, thread_name)); |
60 thread_->Start(); | 61 thread_->Start(); |
61 pid_available_callback.Run(base::kNullProcessId); | 62 pid_available_callback.Run(base::Process::Current().Pid()); |
62 | 63 |
63 return client; | 64 return client; |
64 } | 65 } |
65 | 66 |
66 void InProcessNativeRunner::Run() { | 67 void InProcessNativeRunner::Run() { |
67 DVLOG(2) << "Loading/running Mojo app in process from library: " | 68 DVLOG(2) << "Loading/running Mojo app in process from library: " |
68 << app_path_.value() | 69 << app_path_.value() |
69 << " thread id=" << base::PlatformThread::CurrentId(); | 70 << " thread id=" << base::PlatformThread::CurrentId(); |
70 | 71 |
71 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! | 72 // TODO(vtl): ScopedNativeLibrary doesn't have a .get() method! |
(...skipping 13 matching lines...) Expand all Loading... |
85 const base::FilePath& app_path) { | 86 const base::FilePath& app_path) { |
86 // Non-Mojo apps are always run in a new process. | 87 // Non-Mojo apps are always run in a new process. |
87 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { | 88 if (!app_path.MatchesExtension(FILE_PATH_LITERAL(".mojo"))) { |
88 return base::WrapUnique( | 89 return base::WrapUnique( |
89 new OutOfProcessNativeRunner(launch_process_runner_, nullptr)); | 90 new OutOfProcessNativeRunner(launch_process_runner_, nullptr)); |
90 } | 91 } |
91 return base::WrapUnique(new InProcessNativeRunner); | 92 return base::WrapUnique(new InProcessNativeRunner); |
92 } | 93 } |
93 | 94 |
94 } // namespace shell | 95 } // namespace shell |
OLD | NEW |