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

Side by Side Diff: content/browser/media/audio_stream_monitor.cc

Issue 2655413004: Strip out stream counting from AudioRendererHost. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/audio_stream_monitor.h" 5 #include "content/browser/media/audio_stream_monitor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 int render_process_id, 80 int render_process_id,
81 int render_frame_id, 81 int render_frame_id,
82 int stream_id, 82 int stream_id,
83 const ReadPowerAndClipCallback& read_power_callback) { 83 const ReadPowerAndClipCallback& read_power_callback) {
84 DCHECK_CURRENTLY_ON(BrowserThread::UI); 84 DCHECK_CURRENTLY_ON(BrowserThread::UI);
85 AudioStreamMonitor* const monitor = 85 AudioStreamMonitor* const monitor =
86 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id); 86 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id);
87 if (!monitor) 87 if (!monitor)
88 return; 88 return;
89 89
90 RenderProcessHostImpl* render_process_host =
DaleCurtis 2017/01/30 21:12:19 +ncarter for content/ review. Is it possible for t
ncarter (slow) 2017/01/31 18:33:12 This is safe, given the implementation of AudioStr
DaleCurtis 2017/02/06 22:19:02 Replaced all of this with a helper function. We ca
91 static_cast<RenderProcessHostImpl*>(
92 RenderProcessHost::FromID(render_process_id));
93 if (!render_process_host)
94 return;
95 render_process_host->OnAudioStreamAdded();
90 monitor->OnStreamAdded(); 96 monitor->OnStreamAdded();
91 97
92 if (!power_level_monitoring_available()) 98 if (!power_level_monitoring_available())
93 return; 99 return;
94 100
95 monitor->StartMonitoringStreamOnUIThread(render_process_id, stream_id, 101 monitor->StartMonitoringStreamOnUIThread(render_process_id, stream_id,
96 read_power_callback); 102 read_power_callback);
97 } 103 }
98 104
99 // static 105 // static
100 void AudioStreamMonitor::StopMonitoringHelper(int render_process_id, 106 void AudioStreamMonitor::StopMonitoringHelper(int render_process_id,
101 int render_frame_id, 107 int render_frame_id,
102 int stream_id) { 108 int stream_id) {
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); 109 DCHECK_CURRENTLY_ON(BrowserThread::UI);
104 AudioStreamMonitor* const monitor = 110 AudioStreamMonitor* const monitor =
105 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id); 111 AudioStreamMonitorFromRenderFrame(render_process_id, render_frame_id);
106 if (!monitor) 112 if (!monitor)
107 return; 113 return;
108 114
115 RenderProcessHostImpl* render_process_host =
116 static_cast<RenderProcessHostImpl*>(
117 RenderProcessHost::FromID(render_process_id));
118 if (!render_process_host)
119 return;
120 render_process_host->OnAudioStreamRemoved();
ncarter (slow) 2017/01/31 18:33:12 How confident are you that this perfectly balances
DaleCurtis 2017/02/06 22:19:02 Test added; it was incorrect before, but is correc
109 monitor->OnStreamRemoved(); 121 monitor->OnStreamRemoved();
110 122
111 if (!power_level_monitoring_available()) 123 if (!power_level_monitoring_available())
112 return; 124 return;
113 125
114 monitor->StopMonitoringStreamOnUIThread(render_process_id, stream_id); 126 monitor->StopMonitoringStreamOnUIThread(render_process_id, stream_id);
115 } 127 }
116 128
117 void AudioStreamMonitor::StartMonitoringStreamOnUIThread( 129 void AudioStreamMonitor::StartMonitoringStreamOnUIThread(
118 int render_process_id, 130 int render_process_id,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return; 219 return;
208 220
209 if (active_streams_ == 0) { 221 if (active_streams_ == 0) {
210 is_audible_ = false; 222 is_audible_ = false;
211 web_contents_->OnAudioStateChanged(false); 223 web_contents_->OnAudioStateChanged(false);
212 MaybeToggle(); 224 MaybeToggle();
213 } 225 }
214 } 226 }
215 227
216 } // namespace content 228 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698