Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 2310343002: Defer suspend events on Android when audio is active. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 void ChildThreadImpl::StartMojoShellConnection() { 770 void ChildThreadImpl::StartMojoShellConnection() {
771 DCHECK(mojo_shell_connection_); 771 DCHECK(mojo_shell_connection_);
772 mojo_shell_connection_->Start(); 772 mojo_shell_connection_->Start();
773 } 773 }
774 774
775 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { 775 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
776 return false; 776 return false;
777 } 777 }
778 778
779 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { 779 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) {
780 LOG(ERROR) << __func__ << " : " << backgrounded;
780 // Set timer slack to maximum on main thread when in background. 781 // Set timer slack to maximum on main thread when in background.
781 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 782 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
782 if (backgrounded) 783 if (backgrounded)
783 timer_slack = base::TIMER_SLACK_MAXIMUM; 784 timer_slack = base::TIMER_SLACK_MAXIMUM;
785 #if defined(OS_ANDROID)
786 // Defer suspend events on Android if the scheduler says so; this ensures that
787 // functionality like background audio playback works properly.
788 base::PowerMonitor::Get()->DeferSuspendEvents(!backgrounded);
789 #endif
790
784 base::MessageLoop::current()->SetTimerSlack(timer_slack); 791 base::MessageLoop::current()->SetTimerSlack(timer_slack);
785 } 792 }
786 793
787 void ChildThreadImpl::OnProcessPurgeAndSuspend() { 794 void ChildThreadImpl::OnProcessPurgeAndSuspend() {
788 } 795 }
789 796
790 void ChildThreadImpl::OnShutdown() { 797 void ChildThreadImpl::OnShutdown() {
791 base::MessageLoop::current()->QuitWhenIdle(); 798 base::MessageLoop::current()->QuitWhenIdle();
792 } 799 }
793 800
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void ChildThreadImpl::EnsureConnected() { 854 void ChildThreadImpl::EnsureConnected() {
848 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 855 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
849 base::Process::Current().Terminate(0, false); 856 base::Process::Current().Terminate(0, false);
850 } 857 }
851 858
852 bool ChildThreadImpl::IsInBrowserProcess() const { 859 bool ChildThreadImpl::IsInBrowserProcess() const {
853 return static_cast<bool>(browser_process_io_runner_); 860 return static_cast<bool>(browser_process_io_runner_);
854 } 861 }
855 862
856 } // namespace content 863 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698