xref: /aosp_15_r20/external/webrtc/logging/rtc_event_log/fake_rtc_event_log.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef LOGGING_RTC_EVENT_LOG_FAKE_RTC_EVENT_LOG_H_
12 #define LOGGING_RTC_EVENT_LOG_FAKE_RTC_EVENT_LOG_H_
13 
14 #include <map>
15 #include <memory>
16 
17 #include "api/rtc_event_log/rtc_event.h"
18 #include "api/rtc_event_log/rtc_event_log.h"
19 #include "rtc_base/synchronization/mutex.h"
20 #include "rtc_base/thread_annotations.h"
21 
22 namespace webrtc {
23 
24 class FakeRtcEventLog : public RtcEventLog {
25  public:
26   FakeRtcEventLog() = default;
27   ~FakeRtcEventLog() override = default;
28 
29   bool StartLogging(std::unique_ptr<RtcEventLogOutput> output,
30                     int64_t output_period_ms) override;
31   void StopLogging() override;
32   void Log(std::unique_ptr<RtcEvent> event) override;
33   int GetEventCount(RtcEvent::Type event_type);
34 
35  private:
36   Mutex mu_;
37   std::map<RtcEvent::Type, int> count_ RTC_GUARDED_BY(mu_);
38 };
39 
40 }  // namespace webrtc
41 
42 #endif  // LOGGING_RTC_EVENT_LOG_FAKE_RTC_EVENT_LOG_H_
43