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

Unified Diff: content/browser/media/audio_stream_monitor.cc

Issue 972973002: Revert of Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/audio_stream_monitor.cc
diff --git a/content/browser/media/audio_stream_monitor.cc b/content/browser/media/audio_stream_monitor.cc
index 4c0bc0a5d720c6ce0debbadd6587ac96b8a0fa75..1d2f76f7f2c02f986f5b52122834363ff96be1e8 100644
--- a/content/browser/media/audio_stream_monitor.cc
+++ b/content/browser/media/audio_stream_monitor.cc
@@ -21,36 +21,23 @@
WebContentsImpl* const web_contents =
static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(
RenderFrameHost::FromID(render_process_id, render_frame_id)));
-
- if (!web_contents)
- return nullptr;
-
- AudioStateProvider* audio_provider = web_contents->audio_state_provider();
- return audio_provider ? audio_provider->audio_stream_monitor() : nullptr;
+ return web_contents ? web_contents->audio_stream_monitor() : NULL;
}
} // namespace
AudioStreamMonitor::AudioStreamMonitor(WebContents* contents)
- : AudioStateProvider(contents),
- clock_(&default_tick_clock_)
-{
+ : web_contents_(contents),
+ clock_(&default_tick_clock_),
+ was_recently_audible_(false) {
+ DCHECK(web_contents_);
}
AudioStreamMonitor::~AudioStreamMonitor() {}
-bool AudioStreamMonitor::IsAudioStateAvailable() const {
- return media::AudioOutputController::will_monitor_audio_levels();
-}
-
-// This provider is the monitor.
-AudioStreamMonitor* AudioStreamMonitor::audio_stream_monitor() {
- return this;
-}
-
bool AudioStreamMonitor::WasRecentlyAudible() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return AudioStateProvider::WasRecentlyAudible();
+ return was_recently_audible_;
}
// static
@@ -59,7 +46,7 @@
int render_frame_id,
int stream_id,
const ReadPowerAndClipCallback& read_power_callback) {
- if (!media::AudioOutputController::will_monitor_audio_levels())
+ if (!monitoring_available())
return;
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
@@ -74,7 +61,7 @@
void AudioStreamMonitor::StopMonitoringStream(int render_process_id,
int render_frame_id,
int stream_id) {
- if (!media::AudioOutputController::will_monitor_audio_levels())
+ if (!monitoring_available())
return;
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
@@ -151,12 +138,16 @@
}
void AudioStreamMonitor::MaybeToggle() {
+ const bool indicator_was_on = was_recently_audible_;
const base::TimeTicks off_time =
last_blurt_time_ + base::TimeDelta::FromMilliseconds(kHoldOnMilliseconds);
const base::TimeTicks now = clock_->NowTicks();
const bool should_indicator_be_on = now < off_time;
- Notify(should_indicator_be_on);
+ if (should_indicator_be_on != indicator_was_on) {
+ was_recently_audible_ = should_indicator_be_on;
+ web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
+ }
if (!should_indicator_be_on) {
off_timer_.Stop();
« no previous file with comments | « content/browser/media/audio_stream_monitor.h ('k') | content/browser/media/audio_stream_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698