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

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

Issue 670623002: Change base::TickClock to a ref counted class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_redesign
Patch Set: y Created 6 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 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 #ifndef CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_
6 #define CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ 6 #define CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
14 #include "base/time/tick_clock.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
18 #include "media/audio/audio_output_controller.h" 19 #include "media/audio/audio_output_controller.h"
19 20
20 namespace base { 21 namespace base {
21 class TickClock; 22 class TickClock;
22 } 23 }
23 24
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 // Called by |poll_timer_| to sample the power levels from each of the streams 107 // Called by |poll_timer_| to sample the power levels from each of the streams
107 // playing in the tab. 108 // playing in the tab.
108 void Poll(); 109 void Poll();
109 110
110 // Compares last known indicator state with what it should be, and triggers UI 111 // Compares last known indicator state with what it should be, and triggers UI
111 // updates through |web_contents_| if needed. When the indicator is turned 112 // updates through |web_contents_| if needed. When the indicator is turned
112 // on, |off_timer_| is started to re-invoke this method in the future. 113 // on, |off_timer_| is started to re-invoke this method in the future.
113 void MaybeToggle(); 114 void MaybeToggle();
114 115
116 void set_clock_for_testing(const scoped_refptr<base::TickClock>& clock) {
117 clock_ = clock;
118 }
119
115 // The WebContents instance instance to receive indicator toggle 120 // The WebContents instance instance to receive indicator toggle
116 // notifications. This pointer should be valid for the lifetime of 121 // notifications. This pointer should be valid for the lifetime of
117 // AudioStreamMonitor. 122 // AudioStreamMonitor.
118 WebContents* const web_contents_; 123 WebContents* const web_contents_;
119 124
120 // Note: |clock_| is always |&default_tick_clock_|, except during unit 125 // Note: |clock_| is always a DefaultTickClock(), except during unit testing.
121 // testing. 126 scoped_refptr<base::TickClock> clock_;
122 base::DefaultTickClock default_tick_clock_;
123 base::TickClock* const clock_;
124 127
125 // Confirms single-threaded access in debug builds. 128 // Confirms single-threaded access in debug builds.
126 base::ThreadChecker thread_checker_; 129 base::ThreadChecker thread_checker_;
127 130
128 // The callbacks to read power levels for each stream. Only playing (i.e., 131 // The callbacks to read power levels for each stream. Only playing (i.e.,
129 // not paused) streams will have an entry in this map. 132 // not paused) streams will have an entry in this map.
130 typedef std::pair<int, int> StreamID; 133 typedef std::pair<int, int> StreamID;
131 typedef std::map<StreamID, ReadPowerAndClipCallback> StreamPollCallbackMap; 134 typedef std::map<StreamID, ReadPowerAndClipCallback> StreamPollCallbackMap;
132 StreamPollCallbackMap poll_callbacks_; 135 StreamPollCallbackMap poll_callbacks_;
133 136
(...skipping 10 matching lines...) Expand all
144 // Started only when an indicator is toggled on, to turn it off again in the 147 // Started only when an indicator is toggled on, to turn it off again in the
145 // future. 148 // future.
146 base::OneShotTimer<AudioStreamMonitor> off_timer_; 149 base::OneShotTimer<AudioStreamMonitor> off_timer_;
147 150
148 DISALLOW_COPY_AND_ASSIGN(AudioStreamMonitor); 151 DISALLOW_COPY_AND_ASSIGN(AudioStreamMonitor);
149 }; 152 };
150 153
151 } // namespace content 154 } // namespace content
152 155
153 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_ 156 #endif // CONTENT_BROWSER_MEDIA_AUDIO_STREAM_MONITOR_H_
OLDNEW
« no previous file with comments | « components/network_time/network_time_tracker_unittest.cc ('k') | content/browser/media/audio_stream_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698