| 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 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); | 370 #if USE_ATTACHMENT_BROKER |
| 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 |
| 371 | 378 |
| 372 channel_ = | 379 channel_ = |
| 373 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), | 380 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), |
| 374 ChildProcess::current()->GetShutDownEvent()); | 381 ChildProcess::current()->GetShutDownEvent()); |
| 375 #ifdef IPC_MESSAGE_LOG_ENABLED | 382 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 376 if (!IsInBrowserProcess()) | 383 if (!IsInBrowserProcess()) |
| 377 IPC::Logging::GetInstance()->SetIPCSender(this); | 384 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 378 #endif | 385 #endif |
| 379 | 386 |
| 380 if (!IsInBrowserProcess()) { | 387 if (!IsInBrowserProcess()) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 #if defined(USE_OZONE) | 453 #if defined(USE_OZONE) |
| 447 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); | 454 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); |
| 448 #endif | 455 #endif |
| 449 | 456 |
| 450 // Add filters passed here via options. | 457 // Add filters passed here via options. |
| 451 for (auto startup_filter : options.startup_filters) { | 458 for (auto startup_filter : options.startup_filters) { |
| 452 channel_->AddFilter(startup_filter); | 459 channel_->AddFilter(startup_filter); |
| 453 } | 460 } |
| 454 | 461 |
| 455 ConnectChannel(options.use_mojo_channel); | 462 ConnectChannel(options.use_mojo_channel); |
| 456 IPC::AttachmentBroker* global = IPC::AttachmentBroker::GetGlobal(); | 463 if (attachment_broker_) |
| 457 if (global && !global->IsPrivilegedBroker()) | 464 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get()); |
| 458 global->DesignateBrokerCommunicationChannel(channel_.get()); | |
| 459 | 465 |
| 460 int connection_timeout = kConnectionTimeoutS; | 466 int connection_timeout = kConnectionTimeoutS; |
| 461 std::string connection_override = | 467 std::string connection_override = |
| 462 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 468 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 463 switches::kIPCConnectionTimeout); | 469 switches::kIPCConnectionTimeout); |
| 464 if (!connection_override.empty()) { | 470 if (!connection_override.empty()) { |
| 465 int temp; | 471 int temp; |
| 466 if (base::StringToInt(connection_override, &temp)) | 472 if (base::StringToInt(connection_override, &temp)) |
| 467 connection_timeout = temp; | 473 connection_timeout = temp; |
| 468 } | 474 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 void ChildThreadImpl::EnsureConnected() { | 732 void ChildThreadImpl::EnsureConnected() { |
| 727 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 733 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 728 base::Process::Current().Terminate(0, false); | 734 base::Process::Current().Terminate(0, false); |
| 729 } | 735 } |
| 730 | 736 |
| 731 bool ChildThreadImpl::IsInBrowserProcess() const { | 737 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 732 return browser_process_io_runner_; | 738 return browser_process_io_runner_; |
| 733 } | 739 } |
| 734 | 740 |
| 735 } // namespace content | 741 } // namespace content |
| OLD | NEW |