| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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(size_t count = 1); |
| 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 // Useful for resetting this between tests with different threading. |
| 33 void DetachFromThreadForTesting(); |
| 34 |
| 32 size_t max_stream_count() const; | 35 size_t max_stream_count() const; |
| 33 | 36 |
| 34 private: | 37 private: |
| 35 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, IncreaseAndDecreaseOnce); | 38 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, IncreaseAndDecreaseOnce); |
| 36 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, | 39 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, |
| 37 IncreaseAndDecreaseMultiple); | 40 IncreaseAndDecreaseMultiple); |
| 38 | 41 |
| 39 // Confirms single-threaded access. | 42 // Confirms single-threaded access. |
| 40 base::ThreadChecker thread_checker_; | 43 base::ThreadChecker thread_checker_; |
| 41 | 44 |
| 42 // Stores the current and maximum number of streams. | 45 // Stores the current and maximum number of streams. |
| 43 size_t current_stream_count_; | 46 size_t current_stream_count_; |
| 44 size_t max_stream_count_; | 47 size_t max_stream_count_; |
| 45 | 48 |
| 46 DISALLOW_COPY_AND_ASSIGN(AudioStreamsTracker); | 49 DISALLOW_COPY_AND_ASSIGN(AudioStreamsTracker); |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 } // namespace media | 52 } // namespace media |
| 50 | 53 |
| 51 #endif // MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | 54 #endif // MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ |
| OLD | NEW |