| 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 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return *this; | 290 return *this; |
| 291 } | 291 } |
| 292 | 292 |
| 293 ChildThreadImpl::Options::Builder& | 293 ChildThreadImpl::Options::Builder& |
| 294 ChildThreadImpl::Options::Builder::AddStartupFilter( | 294 ChildThreadImpl::Options::Builder::AddStartupFilter( |
| 295 IPC::MessageFilter* filter) { | 295 IPC::MessageFilter* filter) { |
| 296 options_.startup_filters.push_back(filter); | 296 options_.startup_filters.push_back(filter); |
| 297 return *this; | 297 return *this; |
| 298 } | 298 } |
| 299 | 299 |
| 300 ChildThreadImpl::Options::Builder& |
| 301 ChildThreadImpl::Options::Builder::ListenerTaskRunner( |
| 302 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 303 options_.listener_task_runner = task_runner; |
| 304 return *this; |
| 305 } |
| 306 |
| 300 ChildThreadImpl::Options ChildThreadImpl::Options::Builder::Build() { | 307 ChildThreadImpl::Options ChildThreadImpl::Options::Builder::Build() { |
| 301 return options_; | 308 return options_; |
| 302 } | 309 } |
| 303 | 310 |
| 304 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter( | 311 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter( |
| 305 IPC::Sender* sender) | 312 IPC::Sender* sender) |
| 306 : sender_(sender) {} | 313 : sender_(sender) {} |
| 307 | 314 |
| 308 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) { | 315 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) { |
| 309 return sender_->Send(msg); | 316 return sender_->Send(msg); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 443 |
| 437 #if defined(OS_MACOSX) | 444 #if defined(OS_MACOSX) |
| 438 channel_->AddFilter(new IOSurfaceManagerFilter()); | 445 channel_->AddFilter(new IOSurfaceManagerFilter()); |
| 439 #endif | 446 #endif |
| 440 | 447 |
| 441 // Add filters passed here via options. | 448 // Add filters passed here via options. |
| 442 for (auto startup_filter : options.startup_filters) { | 449 for (auto startup_filter : options.startup_filters) { |
| 443 channel_->AddFilter(startup_filter); | 450 channel_->AddFilter(startup_filter); |
| 444 } | 451 } |
| 445 | 452 |
| 453 // Set listener task runner before connect channel to avoid data race. |
| 454 if (options.listener_task_runner) { |
| 455 channel_->SetListenerTaskRunner(options.listener_task_runner); |
| 456 } |
| 446 ConnectChannel(options.use_mojo_channel); | 457 ConnectChannel(options.use_mojo_channel); |
| 447 | 458 |
| 448 int connection_timeout = kConnectionTimeoutS; | 459 int connection_timeout = kConnectionTimeoutS; |
| 449 std::string connection_override = | 460 std::string connection_override = |
| 450 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 461 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 451 switches::kIPCConnectionTimeout); | 462 switches::kIPCConnectionTimeout); |
| 452 if (!connection_override.empty()) { | 463 if (!connection_override.empty()) { |
| 453 int temp; | 464 int temp; |
| 454 if (base::StringToInt(connection_override, &temp)) | 465 if (base::StringToInt(connection_override, &temp)) |
| 455 connection_timeout = temp; | 466 connection_timeout = temp; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 726 |
| 716 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | 727 void ChildThreadImpl::OnProcessBackgrounded(bool background) { |
| 717 // Set timer slack to maximum on main thread when in background. | 728 // Set timer slack to maximum on main thread when in background. |
| 718 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 729 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
| 719 if (background) | 730 if (background) |
| 720 timer_slack = base::TIMER_SLACK_MAXIMUM; | 731 timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 721 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 732 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 722 } | 733 } |
| 723 | 734 |
| 724 } // namespace content | 735 } // namespace content |
| OLD | NEW |