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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2383473002: [scheduler] Teach scheduler about audio state (Closed)
Patch Set: Support out-of-process frames Created 4 years, 2 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 397c14b9dbbf688fadb669dfc336582cdd7a1488..0d392b178664246bc0f3e0cc64d01d2575ecf972 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -882,6 +882,29 @@ int WebContentsImpl::SendToAllFrames(IPC::Message* message) {
return number_of_messages;
}
+int WebContentsImpl::SendToAllViews(IPC::Message* message) {
clamy 2016/10/05 12:11:35 I think it would make a lot more sense to have the
altimin 2016/10/05 13:26:37 Done.
+ std::unordered_set<RenderViewHost*> render_view_hosts;
+ for (RenderFrameHost* rfh : GetAllFrames()) {
+ if (!rfh->IsRenderFrameLive())
+ continue;
+
+ render_view_hosts.insert(rfh->GetRenderViewHost());
+ }
+
+ int number_of_messages = 0;
+ for (RenderViewHost* rvh : render_view_hosts) {
+ if (!rvh->IsRenderViewLive())
+ continue;
+
+ ++number_of_messages;
+ IPC::Message* message_copy = new IPC::Message(*message);
+ message_copy->set_routing_id(rvh->GetRoutingID());
+ rvh->Send(message_copy);
+ }
+ delete message;
+ return number_of_messages;
+}
+
void WebContentsImpl::SendPageMessage(IPC::Message* msg) {
frame_tree_.root()->render_manager()->SendPageMessage(msg, nullptr);
}
@@ -1278,8 +1301,7 @@ void WebContentsImpl::SetAudioMuted(bool mute) {
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
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 {
@@ -1339,6 +1361,14 @@ void WebContentsImpl::NotifyNavigationStateChanged(
GetOuterWebContents()->NotifyNavigationStateChanged(changed_flags);
}
+void WebContentsImpl::OnAudioStateChanged(bool is_audio_playing) {
+ SendToAllViews(
+ new ViewMsg_AudioStateChanged(GetRoutingID(), 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_;
}
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698