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/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 ChildThreadImpl::Options::Builder::Builder() { | 260 ChildThreadImpl::Options::Builder::Builder() { |
261 } | 261 } |
262 | 262 |
263 ChildThreadImpl::Options::Builder& | 263 ChildThreadImpl::Options::Builder& |
264 ChildThreadImpl::Options::Builder::InBrowserProcess( | 264 ChildThreadImpl::Options::Builder::InBrowserProcess( |
265 const InProcessChildThreadParams& params) { | 265 const InProcessChildThreadParams& params) { |
266 options_.browser_process_io_runner = params.io_runner(); | 266 options_.browser_process_io_runner = params.io_runner(); |
267 options_.channel_name = params.channel_name(); | 267 options_.channel_name = params.channel_name(); |
268 options_.in_process_message_pipe_handle = params.handle(); | 268 options_.in_process_message_pipe_handle = params.handle(); |
| 269 options_.in_process_application_message_pipe_handle = |
| 270 params.application_handle(); |
269 return *this; | 271 return *this; |
270 } | 272 } |
271 | 273 |
272 ChildThreadImpl::Options::Builder& | 274 ChildThreadImpl::Options::Builder& |
273 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { | 275 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { |
274 options_.use_mojo_channel = use_mojo_channel; | 276 options_.use_mojo_channel = use_mojo_channel; |
275 return *this; | 277 return *this; |
276 } | 278 } |
277 | 279 |
278 ChildThreadImpl::Options::Builder& | 280 ChildThreadImpl::Options::Builder& |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 InitializeMojoIPCChannel(); | 385 InitializeMojoIPCChannel(); |
384 } | 386 } |
385 | 387 |
386 if (MojoShellConnectionImpl::Get()) { | 388 if (MojoShellConnectionImpl::Get()) { |
387 base::ElapsedTimer timer; | 389 base::ElapsedTimer timer; |
388 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); | 390 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); |
389 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); | 391 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); |
390 } | 392 } |
391 | 393 |
392 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); | 394 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); |
| 395 if (!IsInBrowserProcess()) { |
| 396 std::string mojo_application_token = |
| 397 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 398 switches::kMojoApplicationChannelToken); |
| 399 if (!mojo_application_token.empty()) |
| 400 mojo_application_->InitWithToken(mojo_application_token); |
| 401 } else { |
| 402 mojo::ScopedMessagePipeHandle handle( |
| 403 options.in_process_application_message_pipe_handle); |
| 404 if (handle.is_valid()) |
| 405 mojo_application_->InitWithPipe(std::move(handle)); |
| 406 } |
393 | 407 |
394 sync_message_filter_ = channel_->CreateSyncMessageFilter(); | 408 sync_message_filter_ = channel_->CreateSyncMessageFilter(); |
395 thread_safe_sender_ = new ThreadSafeSender( | 409 thread_safe_sender_ = new ThreadSafeSender( |
396 message_loop_->task_runner(), sync_message_filter_.get()); | 410 message_loop_->task_runner(), sync_message_filter_.get()); |
397 | 411 |
398 resource_dispatcher_.reset(new ResourceDispatcher( | 412 resource_dispatcher_.reset(new ResourceDispatcher( |
399 this, message_loop()->task_runner())); | 413 this, message_loop()->task_runner())); |
400 websocket_dispatcher_.reset(new WebSocketDispatcher); | 414 websocket_dispatcher_.reset(new WebSocketDispatcher); |
401 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 415 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
402 | 416 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 void ChildThreadImpl::EnsureConnected() { | 723 void ChildThreadImpl::EnsureConnected() { |
710 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 724 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
711 base::Process::Current().Terminate(0, false); | 725 base::Process::Current().Terminate(0, false); |
712 } | 726 } |
713 | 727 |
714 bool ChildThreadImpl::IsInBrowserProcess() const { | 728 bool ChildThreadImpl::IsInBrowserProcess() const { |
715 return browser_process_io_runner_; | 729 return browser_process_io_runner_; |
716 } | 730 } |
717 | 731 |
718 } // namespace content | 732 } // namespace content |
OLD | NEW |