[scheduler] Teach scheduler about audio state
This patch wires information about audio state to renderer scheduler
and stops all throttling (background and offscreen) while
audio is playing and for a short period after audio is stopped.
BUG=642321,616519, 656019
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel
Committed: https://crrev.com/a7a651d546b76499821b4ba47b8f017d4b8becac
Review-Url: https://codereview.chromium.org/2383473002
Cr-Original-Commit-Position: refs/heads/master@{#423405}
Cr-Commit-Position: refs/heads/master@{#429861}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index f16dbea..ab72f5a 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1259,8 +1259,7 @@
for (auto& observer : observers_)
observer.DidUpdateAudioMutingState(mute);
- // Notification for UI updates in response to the changed muting state.
- NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+ OnAudioStateChanged(!mute && audio_stream_monitor_.IsCurrentlyAudible());
}
bool WebContentsImpl::IsConnectedToBluetoothDevice() const {
@@ -1320,6 +1319,14 @@
GetOuterWebContents()->NotifyNavigationStateChanged(changed_flags);
}
+void WebContentsImpl::OnAudioStateChanged(bool is_audio_playing) {
+ SendPageMessage(
+ new PageMsg_AudioStateChanged(MSG_ROUTING_NONE, is_audio_playing));
+
+ // Notification for UI updates in response to the changed muting state.
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+}
+
base::TimeTicks WebContentsImpl::GetLastActiveTime() const {
return last_active_time_;
}