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

Side by Side Diff: content/browser/renderer_host/render_process_host_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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 12 matching lines...) Expand all
23 #include "base/lazy_instance.h" 23 #include "base/lazy_instance.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/macros.h" 26 #include "base/macros.h"
27 #include "base/memory/ref_counted.h" 27 #include "base/memory/ref_counted.h"
28 #include "base/memory/shared_memory.h" 28 #include "base/memory/shared_memory.h"
29 #include "base/memory/shared_memory_handle.h" 29 #include "base/memory/shared_memory_handle.h"
30 #include "base/metrics/histogram_macros.h" 30 #include "base/metrics/histogram_macros.h"
31 #include "base/metrics/persistent_histogram_allocator.h" 31 #include "base/metrics/persistent_histogram_allocator.h"
32 #include "base/metrics/persistent_memory_allocator.h" 32 #include "base/metrics/persistent_memory_allocator.h"
33 #include "base/power_monitor/power_monitor.h"
33 #include "base/process/process_handle.h" 34 #include "base/process/process_handle.h"
34 #include "base/rand_util.h" 35 #include "base/rand_util.h"
35 #include "base/single_thread_task_runner.h" 36 #include "base/single_thread_task_runner.h"
36 #include "base/stl_util.h" 37 #include "base/stl_util.h"
37 #include "base/strings/string_number_conversions.h" 38 #include "base/strings/string_number_conversions.h"
38 #include "base/strings/stringprintf.h" 39 #include "base/strings/stringprintf.h"
39 #include "base/supports_user_data.h" 40 #include "base/supports_user_data.h"
40 #include "base/synchronization/lock.h" 41 #include "base/synchronization/lock.h"
41 #include "base/sys_info.h" 42 #include "base/sys_info.h"
42 #include "base/threading/thread.h" 43 #include "base/threading/thread.h"
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 DCHECK(!is_process_backgrounded_); 1432 DCHECK(!is_process_backgrounded_);
1432 UpdateProcessPriority(); 1433 UpdateProcessPriority();
1433 } 1434 }
1434 } 1435 }
1435 1436
1436 int RenderProcessHostImpl::VisibleWidgetCount() const { 1437 int RenderProcessHostImpl::VisibleWidgetCount() const {
1437 return visible_widgets_; 1438 return visible_widgets_;
1438 } 1439 }
1439 1440
1440 void RenderProcessHostImpl::AudioStateChanged() { 1441 void RenderProcessHostImpl::AudioStateChanged() {
1442 LOG(ERROR) << __func__;
1441 UpdateProcessPriority(); 1443 UpdateProcessPriority();
1442 } 1444 }
1443 1445
1444 bool RenderProcessHostImpl::IsForGuestsOnly() const { 1446 bool RenderProcessHostImpl::IsForGuestsOnly() const {
1445 return is_for_guests_only_; 1447 return is_for_guests_only_;
1446 } 1448 }
1447 1449
1448 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { 1450 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const {
1449 return storage_partition_impl_; 1451 return storage_partition_impl_;
1450 } 1452 }
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 return; 2747 return;
2746 #endif // OS_WIN 2748 #endif // OS_WIN
2747 2749
2748 // Control the background state from the browser process, otherwise the task 2750 // Control the background state from the browser process, otherwise the task
2749 // telling the renderer to "unbackground" itself may be preempted by other 2751 // telling the renderer to "unbackground" itself may be preempted by other
2750 // tasks executing at lowered priority ahead of it or simply by not being 2752 // tasks executing at lowered priority ahead of it or simply by not being
2751 // swiftly scheduled by the OS per the low process priority 2753 // swiftly scheduled by the OS per the low process priority
2752 // (http://crbug.com/398103). 2754 // (http://crbug.com/398103).
2753 child_process_launcher_->SetProcessBackgrounded(should_background); 2755 child_process_launcher_->SetProcessBackgrounded(should_background);
2754 2756
2757 #if defined(OS_ANDROID)
2758 // Defer suspend events on Android if the scheduler says so; this ensures that
2759 // functionality like background audio playback works properly.
2760 base::PowerMonitor::Get()->DeferSuspendEvents(!should_background);
2761 #endif
2762
2755 // Notify the child process of background state. 2763 // Notify the child process of background state.
2756 Send(new ChildProcessMsg_SetProcessBackgrounded(should_background)); 2764 Send(new ChildProcessMsg_SetProcessBackgrounded(should_background));
2757 } 2765 }
2758 2766
2759 void RenderProcessHostImpl::OnProcessLaunched() { 2767 void RenderProcessHostImpl::OnProcessLaunched() {
2760 // No point doing anything, since this object will be destructed soon. We 2768 // No point doing anything, since this object will be destructed soon. We
2761 // especially don't want to send the RENDERER_PROCESS_CREATED notification, 2769 // especially don't want to send the RENDERER_PROCESS_CREATED notification,
2762 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to 2770 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to
2763 // properly cleanup. 2771 // properly cleanup.
2764 if (deleting_soon_) 2772 if (deleting_soon_)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 2970 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
2963 2971
2964 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 2972 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
2965 // enough information here so that we can determine what the bad message was. 2973 // enough information here so that we can determine what the bad message was.
2966 base::debug::Alias(&error); 2974 base::debug::Alias(&error);
2967 bad_message::ReceivedBadMessage(process.get(), 2975 bad_message::ReceivedBadMessage(process.get(),
2968 bad_message::RPH_MOJO_PROCESS_ERROR); 2976 bad_message::RPH_MOJO_PROCESS_ERROR);
2969 } 2977 }
2970 2978
2971 } // namespace content 2979 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698