OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/utility_process_host_impl.h" | 5 #include "content/browser/utility_process_host_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
19 #include "content/browser/browser_child_process_host_impl.h" | 19 #include "content/browser/browser_child_process_host_impl.h" |
20 #include "content/browser/mojo/mojo_application_host.h" | 20 #include "content/browser/mojo/mojo_application_host.h" |
21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
22 #include "content/common/child_process_host_impl.h" | 22 #include "content/common/child_process_host_impl.h" |
23 #include "content/common/in_process_child_thread_params.h" | 23 #include "content/common/in_process_child_thread_params.h" |
| 24 #include "content/common/mojo/service_registry_impl.h" |
24 #include "content/common/utility_messages.h" | 25 #include "content/common/utility_messages.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
27 #include "content/public/browser/utility_process_host_client.h" | 28 #include "content/public/browser/utility_process_host_client.h" |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/process_type.h" | 30 #include "content/public/common/process_type.h" |
30 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 31 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
31 #include "ipc/ipc_switches.h" | 32 #include "ipc/ipc_switches.h" |
32 #include "ui/base/ui_base_switches.h" | 33 #include "ui/base/ui_base_switches.h" |
33 | 34 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return true; | 202 return true; |
202 started_ = true; | 203 started_ = true; |
203 | 204 |
204 if (is_batch_mode_) | 205 if (is_batch_mode_) |
205 return true; | 206 return true; |
206 | 207 |
207 // Name must be set or metrics_service will crash in any test which | 208 // Name must be set or metrics_service will crash in any test which |
208 // launches a UtilityProcessHost. | 209 // launches a UtilityProcessHost. |
209 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this)); | 210 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this)); |
210 process_->SetName(name_); | 211 process_->SetName(name_); |
| 212 if (mojo_application_host_) { |
| 213 process_->SetServiceRegistry( |
| 214 static_cast<ServiceRegistryImpl*>(GetServiceRegistry())->GetWeakPtr()); |
| 215 } |
211 | 216 |
212 std::string channel_id = process_->GetHost()->CreateChannel(); | 217 std::string channel_id = process_->GetHost()->CreateChannel(); |
213 if (channel_id.empty()) | 218 if (channel_id.empty()) |
214 return false; | 219 return false; |
215 | 220 |
216 if (RenderProcessHost::run_renderer_in_process()) { | 221 if (RenderProcessHost::run_renderer_in_process()) { |
217 DCHECK(g_utility_main_thread_factory); | 222 DCHECK(g_utility_main_thread_factory); |
218 // See comment in RenderProcessHostImpl::Init() for the background on why we | 223 // See comment in RenderProcessHostImpl::Init() for the background on why we |
219 // support single process mode this way. | 224 // support single process mode this way. |
220 in_process_thread_.reset( | 225 in_process_thread_.reset( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 if (RenderProcessHost::run_renderer_in_process()) | 344 if (RenderProcessHost::run_renderer_in_process()) |
340 handle = base::GetCurrentProcessHandle(); | 345 handle = base::GetCurrentProcessHandle(); |
341 else | 346 else |
342 handle = process_->GetData().handle; | 347 handle = process_->GetData().handle; |
343 | 348 |
344 mojo_application_host_->Activate(this, handle); | 349 mojo_application_host_->Activate(this, handle); |
345 } | 350 } |
346 } | 351 } |
347 | 352 |
348 } // namespace content | 353 } // namespace content |
OLD | NEW |