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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 653 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
654 return OnControlMessageReceived(msg); | 654 return OnControlMessageReceived(msg); |
655 | 655 |
656 return router_.OnMessageReceived(msg); | 656 return router_.OnMessageReceived(msg); |
657 } | 657 } |
658 | 658 |
659 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 659 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
660 return false; | 660 return false; |
661 } | 661 } |
662 | 662 |
| 663 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { |
| 664 // Set timer slack to maximum on main thread when in background. |
| 665 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
| 666 if (backgrounded) |
| 667 timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 668 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 669 } |
| 670 |
663 void ChildThreadImpl::OnShutdown() { | 671 void ChildThreadImpl::OnShutdown() { |
664 base::MessageLoop::current()->Quit(); | 672 base::MessageLoop::current()->Quit(); |
665 } | 673 } |
666 | 674 |
667 #if defined(IPC_MESSAGE_LOG_ENABLED) | 675 #if defined(IPC_MESSAGE_LOG_ENABLED) |
668 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { | 676 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { |
669 if (enable) | 677 if (enable) |
670 IPC::Logging::GetInstance()->Enable(); | 678 IPC::Logging::GetInstance()->Enable(); |
671 else | 679 else |
672 IPC::Logging::GetInstance()->Disable(); | 680 IPC::Logging::GetInstance()->Disable(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 739 |
732 void ChildThreadImpl::EnsureConnected() { | 740 void ChildThreadImpl::EnsureConnected() { |
733 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 741 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
734 base::Process::Current().Terminate(0, false); | 742 base::Process::Current().Terminate(0, false); |
735 } | 743 } |
736 | 744 |
737 bool ChildThreadImpl::IsInBrowserProcess() const { | 745 bool ChildThreadImpl::IsInBrowserProcess() const { |
738 return browser_process_io_runner_; | 746 return browser_process_io_runner_; |
739 } | 747 } |
740 | 748 |
741 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | |
742 // Set timer slack to maximum on main thread when in background. | |
743 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | |
744 if (background) | |
745 timer_slack = base::TIMER_SLACK_MAXIMUM; | |
746 base::MessageLoop::current()->SetTimerSlack(timer_slack); | |
747 } | |
748 | |
749 } // namespace content | 749 } // namespace content |
OLD | NEW |