OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ |
6 #define MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | 6 #define MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Tracks the maximum number of simultaneous streams that was ever registered. | 17 // Tracks the maximum number of simultaneous streams that was ever registered. |
18 // All functions must be called on the same thread. | 18 // All functions must be called on the same thread. |
19 class MEDIA_EXPORT AudioStreamsTracker { | 19 class MEDIA_EXPORT AudioStreamsTracker { |
20 public: | 20 public: |
21 AudioStreamsTracker(); | 21 AudioStreamsTracker(); |
22 ~AudioStreamsTracker(); | 22 ~AudioStreamsTracker(); |
23 | 23 |
24 // Increases/decreases current stream count. Updates max stream count if | 24 // Increases/decreases current stream count. Updates max stream count if |
25 // current count is larger. | 25 // current count is larger. |
26 void IncreaseStreamCount(); | 26 void IncreaseStreamCount(); |
27 void DecreaseStreamCount(size_t count = 1); | 27 void DecreaseStreamCount(); |
28 | 28 |
29 // Resets the max stream count, i.e. sets it to the current stream count. | 29 // Resets the max stream count, i.e. sets it to the current stream count. |
30 void ResetMaxStreamCount(); | 30 void ResetMaxStreamCount(); |
31 | 31 |
32 size_t max_stream_count() const; | 32 bool has_streams() const { return !!current_stream_count_; } |
33 size_t max_stream_count() const { return max_stream_count_; } | |
o1ka
2017/01/30 12:19:13
These two need thread checks.
DaleCurtis
2017/01/30 21:12:19
Okay, but they can't be hacker_style() then, so I'
DaleCurtis
2017/02/06 22:19:03
Deleted this whole class instead. It's overkill fo
| |
33 | 34 |
34 private: | 35 private: |
35 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, IncreaseAndDecreaseOnce); | 36 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, IncreaseAndDecreaseOnce); |
36 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, | 37 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, |
37 IncreaseAndDecreaseMultiple); | 38 IncreaseAndDecreaseMultiple); |
38 | 39 |
39 // Confirms single-threaded access. | 40 // Confirms single-threaded access. |
40 base::ThreadChecker thread_checker_; | 41 base::ThreadChecker thread_checker_; |
41 | 42 |
42 // Stores the current and maximum number of streams. | 43 // Stores the current and maximum number of streams. |
43 size_t current_stream_count_; | 44 size_t current_stream_count_; |
44 size_t max_stream_count_; | 45 size_t max_stream_count_; |
45 | 46 |
46 DISALLOW_COPY_AND_ASSIGN(AudioStreamsTracker); | 47 DISALLOW_COPY_AND_ASSIGN(AudioStreamsTracker); |
47 }; | 48 }; |
48 | 49 |
49 } // namespace media | 50 } // namespace media |
50 | 51 |
51 #endif // MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | 52 #endif // MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ |
OLD | NEW |