OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ | 4 #ifndef MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ |
5 #define MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ | 5 #define MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ |
6 | 6 |
7 // Generic class that handles event logging for the cast library. | 7 // Generic class that handles event logging for the cast library. |
8 // Logging has three possible optional forms: | 8 // Logging has three possible optional forms: |
9 // 1. Raw data and stats accessible by the application. | 9 // 1. Raw data and stats accessible by the application. |
10 // 2. UMA stats. | 10 // 2. UMA stats. |
11 // 3. Tracing of raw events. | 11 // 3. Tracing of raw events. |
12 | 12 |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/task_runner.h" |
13 #include "media/cast/logging/logging_defines.h" | 15 #include "media/cast/logging/logging_defines.h" |
14 #include "media/cast/logging/logging_raw.h" | 16 #include "media/cast/logging/logging_raw.h" |
15 #include "media/cast/logging/logging_stats.h" | 17 #include "media/cast/logging/logging_stats.h" |
16 | 18 |
17 namespace media { | 19 namespace media { |
18 namespace cast { | 20 namespace cast { |
19 | 21 |
20 class LoggingImpl { | 22 static const int kFrameIdUnknown = -1; |
| 23 // Should only be called from the main thread. |
| 24 class LoggingImpl : public base::NonThreadSafe { |
21 public: | 25 public: |
22 LoggingImpl(base::TickClock* clock, | 26 LoggingImpl(base::TickClock* clock, |
23 bool enable_data_collection, | 27 scoped_refptr<base::TaskRunner> main_thread_proxy, |
24 bool enable_uma_stats, | 28 const CastLoggingConfig& config); |
25 bool enable_tracing); | |
26 | 29 |
27 ~LoggingImpl(); | 30 ~LoggingImpl(); |
28 | 31 |
29 void InsertFrameEvent(CastLoggingEvent event, | 32 void InsertFrameEvent(CastLoggingEvent event, |
30 uint32 rtp_timestamp, | 33 uint32 rtp_timestamp, |
31 uint32 frame_id); | 34 uint32 frame_id); |
32 void InsertFrameEventWithSize(CastLoggingEvent event, | 35 void InsertFrameEventWithSize(CastLoggingEvent event, |
33 uint32 rtp_timestamp, | 36 uint32 rtp_timestamp, |
34 uint32 frame_id, | 37 uint32 frame_id, |
35 int frame_size); | 38 int frame_size); |
36 void InsertFrameEventWithDelay(CastLoggingEvent event, | 39 void InsertFrameEventWithDelay(CastLoggingEvent event, |
37 uint32 rtp_timestamp, | 40 uint32 rtp_timestamp, |
38 uint32 frame_id, | 41 uint32 frame_id, |
39 base::TimeDelta delay); | 42 base::TimeDelta delay); |
40 void InsertPacketEvent(CastLoggingEvent event, | 43 void InsertPacketEvent(CastLoggingEvent event, |
41 uint32 rtp_timestamp, | 44 uint32 rtp_timestamp, |
42 uint32 frame_id, | 45 uint32 frame_id, |
43 uint16 packet_id, | 46 uint16 packet_id, |
44 uint16 max_packet_id, | 47 uint16 max_packet_id, |
45 int size); | 48 size_t size); |
46 void InsertGenericEvent(CastLoggingEvent event, int value); | 49 void InsertGenericEvent(CastLoggingEvent event, int value); |
47 | 50 |
48 // Get raw data. | 51 // Get raw data. |
49 FrameRawMap GetFrameRawData(); | 52 FrameRawMap GetFrameRawData(); |
50 PacketRawMap GetPacketRawData(); | 53 PacketRawMap GetPacketRawData(); |
51 GenericRawMap GetGenericRawData(); | 54 GenericRawMap GetGenericRawData(); |
52 // Get stats only (computed when called). Triggers UMA stats when enabled. | 55 // Get stats only (computed when called). Triggers UMA stats when enabled. |
53 const FrameStatsMap* GetFrameStatsData(); | 56 const FrameStatsMap* GetFrameStatsData(); |
54 const PacketStatsMap* GetPacketStatsData(); | 57 const PacketStatsMap* GetPacketStatsData(); |
55 const GenericStatsMap* GetGenericStatsData(); | 58 const GenericStatsMap* GetGenericStatsData(); |
56 | 59 |
57 void Reset(); | 60 void Reset(); |
58 | 61 |
59 private: | 62 private: |
| 63 scoped_refptr<base::TaskRunner> main_thread_proxy_; |
| 64 const CastLoggingConfig config_; |
60 LoggingRaw raw_; | 65 LoggingRaw raw_; |
61 LoggingStats stats_; | 66 LoggingStats stats_; |
62 bool enable_data_collection_; | |
63 bool enable_uma_stats_; | |
64 bool enable_tracing_; | |
65 | 67 |
66 DISALLOW_COPY_AND_ASSIGN(LoggingImpl); | 68 DISALLOW_COPY_AND_ASSIGN(LoggingImpl); |
67 }; | 69 }; |
68 | 70 |
69 } // namespace cast | 71 } // namespace cast |
70 } // namespace media | 72 } // namespace media |
71 | 73 |
72 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ | 74 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ |
OLD | NEW |