| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 g_lazy_tls.Pointer()->Set(this); | 360 g_lazy_tls.Pointer()->Set(this); |
| 361 on_channel_error_called_ = false; | 361 on_channel_error_called_ = false; |
| 362 message_loop_ = base::MessageLoop::current(); | 362 message_loop_ = base::MessageLoop::current(); |
| 363 #ifdef IPC_MESSAGE_LOG_ENABLED | 363 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 364 // We must make sure to instantiate the IPC Logger *before* we create the | 364 // We must make sure to instantiate the IPC Logger *before* we create the |
| 365 // channel, otherwise we can get a callback on the IO thread which creates | 365 // channel, otherwise we can get a callback on the IO thread which creates |
| 366 // the logger, and the logger does not like being created on the IO thread. | 366 // the logger, and the logger does not like being created on the IO thread. |
| 367 IPC::Logging::GetInstance(); | 367 IPC::Logging::GetInstance(); |
| 368 #endif | 368 #endif |
| 369 | 369 |
| 370 #if USE_ATTACHMENT_BROKER | 370 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); |
| 371 // The only reason a global would already exist is if the thread is being run | |
| 372 // in the browser process because of a command line switch. | |
| 373 if (!IPC::AttachmentBroker::GetGlobal()) { | |
| 374 attachment_broker_.reset( | |
| 375 IPC::AttachmentBrokerUnprivileged::CreateBroker().release()); | |
| 376 } | |
| 377 #endif | |
| 378 | 371 |
| 379 channel_ = | 372 channel_ = |
| 380 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), | 373 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), |
| 381 ChildProcess::current()->GetShutDownEvent()); | 374 ChildProcess::current()->GetShutDownEvent()); |
| 382 #ifdef IPC_MESSAGE_LOG_ENABLED | 375 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 383 if (!IsInBrowserProcess()) | 376 if (!IsInBrowserProcess()) |
| 384 IPC::Logging::GetInstance()->SetIPCSender(this); | 377 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 385 #endif | 378 #endif |
| 386 | 379 |
| 387 if (!IsInBrowserProcess()) { | 380 if (!IsInBrowserProcess()) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 #if defined(USE_OZONE) | 446 #if defined(USE_OZONE) |
| 454 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); | 447 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); |
| 455 #endif | 448 #endif |
| 456 | 449 |
| 457 // Add filters passed here via options. | 450 // Add filters passed here via options. |
| 458 for (auto startup_filter : options.startup_filters) { | 451 for (auto startup_filter : options.startup_filters) { |
| 459 channel_->AddFilter(startup_filter); | 452 channel_->AddFilter(startup_filter); |
| 460 } | 453 } |
| 461 | 454 |
| 462 ConnectChannel(options.use_mojo_channel); | 455 ConnectChannel(options.use_mojo_channel); |
| 463 if (attachment_broker_) | 456 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); |
| 464 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get()); | 457 if (global && !global->IsPrivilegedBroker()) |
| 458 global->DesignateBrokerCommunicationChannel(channel_.get()); |
| 465 | 459 |
| 466 int connection_timeout = kConnectionTimeoutS; | 460 int connection_timeout = kConnectionTimeoutS; |
| 467 std::string connection_override = | 461 std::string connection_override = |
| 468 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 462 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 469 switches::kIPCConnectionTimeout); | 463 switches::kIPCConnectionTimeout); |
| 470 if (!connection_override.empty()) { | 464 if (!connection_override.empty()) { |
| 471 int temp; | 465 int temp; |
| 472 if (base::StringToInt(connection_override, &temp)) | 466 if (base::StringToInt(connection_override, &temp)) |
| 473 connection_timeout = temp; | 467 connection_timeout = temp; |
| 474 } | 468 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 void ChildThreadImpl::EnsureConnected() { | 726 void ChildThreadImpl::EnsureConnected() { |
| 733 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 727 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 734 base::Process::Current().Terminate(0, false); | 728 base::Process::Current().Terminate(0, false); |
| 735 } | 729 } |
| 736 | 730 |
| 737 bool ChildThreadImpl::IsInBrowserProcess() const { | 731 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 738 return browser_process_io_runner_; | 732 return browser_process_io_runner_; |
| 739 } | 733 } |
| 740 | 734 |
| 741 } // namespace content | 735 } // namespace content |
| OLD | NEW |