| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "services/service_manager/public/cpp/interface_provider.h" | 73 #include "services/service_manager/public/cpp/interface_provider.h" |
| 74 #include "services/service_manager/runner/common/client_util.h" | 74 #include "services/service_manager/runner/common/client_util.h" |
| 75 | 75 |
| 76 #if defined(OS_POSIX) | 76 #if defined(OS_POSIX) |
| 77 #include "base/posix/global_descriptors.h" | 77 #include "base/posix/global_descriptors.h" |
| 78 #include "content/public/common/content_descriptors.h" | 78 #include "content/public/common/content_descriptors.h" |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 #if defined(OS_MACOSX) | 81 #if defined(OS_MACOSX) |
| 82 #include "base/allocator/allocator_interception_mac.h" | 82 #include "base/allocator/allocator_interception_mac.h" |
| 83 #include "base/process/process.h" |
| 84 #include "content/common/mac/app_nap_activity.h" |
| 83 #endif | 85 #endif |
| 84 | 86 |
| 85 using tracked_objects::ThreadData; | 87 using tracked_objects::ThreadData; |
| 86 | 88 |
| 87 namespace content { | 89 namespace content { |
| 88 namespace { | 90 namespace { |
| 89 | 91 |
| 90 // How long to wait for a connection to the browser process before giving up. | 92 // How long to wait for a connection to the browser process before giving up. |
| 91 const int kConnectionTimeoutS = 15; | 93 const int kConnectionTimeoutS = 15; |
| 92 | 94 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 if (base::StringToInt(connection_override, &temp)) | 558 if (base::StringToInt(connection_override, &temp)) |
| 557 connection_timeout = temp; | 559 connection_timeout = temp; |
| 558 } | 560 } |
| 559 | 561 |
| 560 #if defined(OS_MACOSX) | 562 #if defined(OS_MACOSX) |
| 561 if (base::CommandLine::InitializedForCurrentProcess() && | 563 if (base::CommandLine::InitializedForCurrentProcess() && |
| 562 base::CommandLine::ForCurrentProcess()->HasSwitch( | 564 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 563 switches::kEnableHeapProfiling)) { | 565 switches::kEnableHeapProfiling)) { |
| 564 base::allocator::PeriodicallyShimNewMallocZones(); | 566 base::allocator::PeriodicallyShimNewMallocZones(); |
| 565 } | 567 } |
| 568 if (base::Process::IsAppNapEnabled()) { |
| 569 app_nap_activity_.reset(new AppNapActivity()); |
| 570 app_nap_activity_->Begin(); |
| 571 }; |
| 566 #endif | 572 #endif |
| 567 | 573 |
| 568 message_loop_->task_runner()->PostDelayedTask( | 574 message_loop_->task_runner()->PostDelayedTask( |
| 569 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected, | 575 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected, |
| 570 channel_connected_factory_->GetWeakPtr()), | 576 channel_connected_factory_->GetWeakPtr()), |
| 571 base::TimeDelta::FromSeconds(connection_timeout)); | 577 base::TimeDelta::FromSeconds(connection_timeout)); |
| 572 | 578 |
| 573 #if defined(OS_ANDROID) | 579 #if defined(OS_ANDROID) |
| 574 g_quit_closure.Get().BindToMainThread(); | 580 g_quit_closure.Get().BindToMainThread(); |
| 575 #endif | 581 #endif |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 756 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 751 return false; | 757 return false; |
| 752 } | 758 } |
| 753 | 759 |
| 754 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { | 760 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { |
| 755 // Set timer slack to maximum on main thread when in background. | 761 // Set timer slack to maximum on main thread when in background. |
| 756 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 762 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
| 757 if (backgrounded) | 763 if (backgrounded) |
| 758 timer_slack = base::TIMER_SLACK_MAXIMUM; | 764 timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 759 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 765 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 766 #if defined(OS_MACOSX) |
| 767 if (base::Process::IsAppNapEnabled()) { |
| 768 if (backgrounded) { |
| 769 app_nap_activity_->End(); |
| 770 } else { |
| 771 app_nap_activity_->Begin(); |
| 772 } |
| 773 } |
| 774 #endif // defined(OS_MACOSX) |
| 760 } | 775 } |
| 761 | 776 |
| 762 void ChildThreadImpl::OnProcessPurgeAndSuspend() { | 777 void ChildThreadImpl::OnProcessPurgeAndSuspend() { |
| 763 } | 778 } |
| 764 | 779 |
| 765 void ChildThreadImpl::OnProcessResume() {} | 780 void ChildThreadImpl::OnProcessResume() {} |
| 766 | 781 |
| 767 void ChildThreadImpl::OnShutdown() { | 782 void ChildThreadImpl::OnShutdown() { |
| 768 base::MessageLoop::current()->QuitWhenIdle(); | 783 base::MessageLoop::current()->QuitWhenIdle(); |
| 769 } | 784 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 Listener* route = router_.GetRoute(routing_id); | 856 Listener* route = router_.GetRoute(routing_id); |
| 842 if (route) | 857 if (route) |
| 843 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); | 858 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); |
| 844 } | 859 } |
| 845 | 860 |
| 846 bool ChildThreadImpl::IsInBrowserProcess() const { | 861 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 847 return static_cast<bool>(browser_process_io_runner_); | 862 return static_cast<bool>(browser_process_io_runner_); |
| 848 } | 863 } |
| 849 | 864 |
| 850 } // namespace content | 865 } // namespace content |
| OLD | NEW |