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

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: Removed an unnecessary atomic operation Created 5 years, 6 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..6b065927239f147f709dab5723974a490b4883d7 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, we background
gab 2015/06/30 13:41:41 -we (in general we try to avoid "we" in comments),
sebsg 2015/07/02 12:58:08 Done.
+ // the tab.
+ if (backgrounded_)
+ SetBackgrounded(true);
+}
+
+void RenderProcessHostImpl::AudioStarted() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // If audio starts from a backgrounded tab, we un-background it.
gab 2015/06/30 13:41:41 // If audio starts playing from a backgrounded tab
sebsg 2015/07/02 12:58:08 Done.
+ if (backgrounded_) {
+ SetBackgrounded(false);
+
+ // Since it's not a visible tab, we need to set it to backgrounded so that
+ // it is backgrounded again when the video finishes.
gab 2015/06/30 13:41:41 // Since it's not a visible tab, it needs to be ma
sebsg 2015/07/02 12:58:09 Done.
+ SetBackgrounded(true);
+ }
+}
+
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