| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | |
| 6 #define MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/threading/thread_checker.h" | |
| 13 #include "media/base/media_export.h" | |
| 14 | |
| 15 namespace media { | |
| 16 | |
| 17 // Tracks the maximum number of simultaneous streams that was ever registered. | |
| 18 // All functions must be called on the same thread. | |
| 19 class MEDIA_EXPORT AudioStreamsTracker { | |
| 20 public: | |
| 21 AudioStreamsTracker(); | |
| 22 ~AudioStreamsTracker(); | |
| 23 | |
| 24 // Increases/decreases current stream count. Updates max stream count if | |
| 25 // current count is larger. | |
| 26 void IncreaseStreamCount(); | |
| 27 void DecreaseStreamCount(size_t count = 1); | |
| 28 | |
| 29 // Resets the max stream count, i.e. sets it to the current stream count. | |
| 30 void ResetMaxStreamCount(); | |
| 31 | |
| 32 size_t max_stream_count() const; | |
| 33 | |
| 34 private: | |
| 35 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, IncreaseAndDecreaseOnce); | |
| 36 FRIEND_TEST_ALL_PREFIXES(AudioStreamsTrackerTest, | |
| 37 IncreaseAndDecreaseMultiple); | |
| 38 | |
| 39 // Confirms single-threaded access. | |
| 40 base::ThreadChecker thread_checker_; | |
| 41 | |
| 42 // Stores the current and maximum number of streams. | |
| 43 size_t current_stream_count_; | |
| 44 size_t max_stream_count_; | |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(AudioStreamsTracker); | |
| 47 }; | |
| 48 | |
| 49 } // namespace media | |
| 50 | |
| 51 #endif // MEDIA_AUDIO_AUDIO_STREAMS_TRACKER_H_ | |
| OLD | NEW |