| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), | 401 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), |
| 402 ChildProcess::current()->GetShutDownEvent()); | 402 ChildProcess::current()->GetShutDownEvent()); |
| 403 #ifdef IPC_MESSAGE_LOG_ENABLED | 403 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 404 if (!IsInBrowserProcess()) | 404 if (!IsInBrowserProcess()) |
| 405 IPC::Logging::GetInstance()->SetIPCSender(this); | 405 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 406 #endif | 406 #endif |
| 407 | 407 |
| 408 if (!IsInBrowserProcess()) { | 408 if (!IsInBrowserProcess()) { |
| 409 // Don't double-initialize IPC support in single-process mode. | 409 // Don't double-initialize IPC support in single-process mode. |
| 410 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport(GetIOTaskRunner())); | 410 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport(GetIOTaskRunner())); |
| 411 | |
| 412 InitializeMojoIPCChannel(); | 411 InitializeMojoIPCChannel(); |
| 413 } | 412 } |
| 414 | 413 |
| 415 // If this process was launched with a primordial pipe token, we exchange it | 414 if (MojoShellConnectionImpl::Get()) { |
| 416 // for a pipe to connect to the shell. | |
| 417 std::string pipe_token = | |
| 418 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 419 switches::kMojoPrimordialPipeToken); | |
| 420 if (!pipe_token.empty() && MojoShellConnectionImpl::Get()) { | |
| 421 mojo::ScopedMessagePipeHandle pipe = | |
| 422 mojo::edk::CreateChildMessagePipe(pipe_token); | |
| 423 | |
| 424 base::ElapsedTimer timer; | 415 base::ElapsedTimer timer; |
| 425 MojoShellConnectionImpl::Get()->BindToMessagePipe(std::move(pipe)); | 416 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); |
| 426 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); | 417 UMA_HISTOGRAM_TIMES("Mojo.Shell.ChildConnectionTime", timer.Elapsed()); |
| 427 } | 418 } |
| 428 | 419 |
| 429 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); | 420 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); |
| 430 | 421 |
| 431 sync_message_filter_ = channel_->CreateSyncMessageFilter(); | 422 sync_message_filter_ = channel_->CreateSyncMessageFilter(); |
| 432 thread_safe_sender_ = new ThreadSafeSender( | 423 thread_safe_sender_ = new ThreadSafeSender( |
| 433 message_loop_->task_runner(), sync_message_filter_.get()); | 424 message_loop_->task_runner(), sync_message_filter_.get()); |
| 434 | 425 |
| 435 resource_dispatcher_.reset(new ResourceDispatcher( | 426 resource_dispatcher_.reset(new ResourceDispatcher( |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 void ChildThreadImpl::EnsureConnected() { | 741 void ChildThreadImpl::EnsureConnected() { |
| 751 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 742 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 752 base::Process::Current().Terminate(0, false); | 743 base::Process::Current().Terminate(0, false); |
| 753 } | 744 } |
| 754 | 745 |
| 755 bool ChildThreadImpl::IsInBrowserProcess() const { | 746 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 756 return browser_process_io_runner_; | 747 return browser_process_io_runner_; |
| 757 } | 748 } |
| 758 | 749 |
| 759 } // namespace content | 750 } // namespace content |
| OLD | NEW |