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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1214883004: Fixed the audio backgrounding bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment change Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 3471e3c087df2e43716a1bd742defd22d7326c79..b3b1c5d07605dca7d81855c0636bc8ffb2fdda8d 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1092,6 +1092,28 @@ int RenderProcessHostImpl::VisibleWidgetCount() const {
return visible_widgets_;
}
+void RenderProcessHostImpl::AudioStopped() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // If the backgrounding was skipped because audio was playing, background the
+ // tab now.
+ if (backgrounded_)
+ SetBackgrounded(true);
+}
+
+void RenderProcessHostImpl::AudioStarted() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // If audio starts playing from a backgrounded tab, un-background it.
+ if (backgrounded_) {
+ SetBackgrounded(false);
+
+ // Since it's not a visible tab, it needs to be marked for backgrounding
+ // again so that it is re-backgrounded if/when the audio stops.
+ SetBackgrounded(true);
ncarter (slow) 2015/07/06 21:53:57 I think we should fix things up so that this hack
gab 2015/07/08 18:52:14 Proposed skeleton SGTM, the AudioRendererHost coul
sebsg 2015/08/02 16:44:23 Done.
sebsg 2015/08/02 16:44:23 Done.
+ }
+}
+
bool RenderProcessHostImpl::IsForGuestsOnly() const {
return is_for_guests_only_;
}
@@ -2237,6 +2259,7 @@ void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) {
}
void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
TRACE_EVENT1("renderer_host", "RenderProcessHostImpl::SetBackgrounded",
"backgrounded", backgrounded);
// Note: we always set the backgrounded_ value. If the process is NULL

Powered by Google App Engine
This is Rietveld 408576698