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

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

Issue 2655413004: Strip out stream counting from AudioRendererHost. (Closed)
Patch Set: Created 3 years, 11 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 4a3b2c7ce211d146e0517b63d327e78a2d0cbd5e..286e15c15299b48c04d8dc42ead347c6d6d68654 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -319,6 +319,11 @@ bool has_done_stun_trials = false;
#endif
+// Tracks the maximum number of simultaneous output streams browser-wide.
+// Accessed on UI thread.
+base::LazyInstance<media::AudioStreamsTracker> g_audio_streams_tracker =
+ LAZY_INSTANCE_INITIALIZER;
+
// the global list of all renderer processes
base::LazyInstance<IDMap<RenderProcessHost*>>::Leaky g_all_hosts =
LAZY_INSTANCE_INITIALIZER;
@@ -782,6 +787,19 @@ RenderProcessHostImpl::~RenderProcessHostImpl() {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&RemoveShaderInfo, GetID()));
}
+
+ // If we had any streams, report UMA stats for the maximum number of
+ // simultaneous streams for this render process and for the whole browser
+ // process since last reported.
+ if (audio_streams_tracker_.max_stream_count() > 0) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Media.AudioRendererIpcStreams",
+ audio_streams_tracker_.max_stream_count(), 1,
+ 50, 51);
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Media.AudioRendererIpcStreamsTotal",
+ g_audio_streams_tracker.Get().max_stream_count(), 1, 100, 101);
ncarter (slow) 2017/01/31 18:33:12 This logging used to happen each time a MessageFil
DaleCurtis 2017/01/31 22:08:31 Ah, I didn't know multiple sets of MessageFilter's
Henrik Grunell 2017/02/03 08:52:20 Sorry Dale, I missed that I was supposed to reply
DaleCurtis 2017/02/06 22:19:02 Deleted, thanks!
+ g_audio_streams_tracker.Get().ResetMaxStreamCount();
+ }
}
bool RenderProcessHostImpl::Init() {
@@ -1555,7 +1573,15 @@ int RenderProcessHostImpl::VisibleWidgetCount() const {
return visible_widgets_;
}
-void RenderProcessHostImpl::AudioStateChanged() {
+void RenderProcessHostImpl::OnAudioStreamAdded() {
+ audio_streams_tracker_.IncreaseStreamCount();
+ g_audio_streams_tracker.Get().IncreaseStreamCount();
+ UpdateProcessPriority();
Max Morin 2017/01/30 11:47:07 It probably makes sense to only UpdateProcessPrior
DaleCurtis 2017/02/06 22:19:02 UpdateProcessPriority() takes care of this.
+}
+
+void RenderProcessHostImpl::OnAudioStreamRemoved() {
+ audio_streams_tracker_.DecreaseStreamCount();
+ g_audio_streams_tracker.Get().DecreaseStreamCount();
UpdateProcessPriority();
}
@@ -2815,7 +2841,7 @@ void RenderProcessHostImpl::UpdateProcessPriority() {
// visible widgets -- the callers must call this function whenever we
// transition in/out of those states.
const bool should_background =
- visible_widgets_ == 0 && !audio_renderer_host_->HasActiveAudio() &&
+ visible_widgets_ == 0 && !audio_streams_tracker_.has_streams() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableRendererBackgrounding);

Powered by Google App Engine
This is Rietveld 408576698