| 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. Tracing of raw events. | 10 // 2. Tracing of raw events. |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "media/cast/cast_config.h" | 14 #include "media/cast/cast_config.h" |
| 15 #include "media/cast/logging/logging_defines.h" | 15 #include "media/cast/logging/logging_defines.h" |
| 16 #include "media/cast/logging/logging_raw.h" | 16 #include "media/cast/logging/logging_raw.h" |
| 17 #include "media/cast/logging/logging_stats.h" | 17 #include "media/cast/logging/logging_stats.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 namespace cast { | 20 namespace cast { |
| 21 | 21 |
| 22 // Should only be called from the main thread. | 22 class LoggingImpl { |
| 23 class LoggingImpl : public base::NonThreadSafe { | |
| 24 public: | 23 public: |
| 25 LoggingImpl(scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, | 24 explicit LoggingImpl(const CastLoggingConfig& config); |
| 26 const CastLoggingConfig& config); | |
| 27 | 25 |
| 28 ~LoggingImpl(); | 26 ~LoggingImpl(); |
| 29 | 27 |
| 28 // Note: All methods below should be called from the same thread. |
| 29 |
| 30 void InsertFrameEvent(const base::TimeTicks& time_of_event, | 30 void InsertFrameEvent(const base::TimeTicks& time_of_event, |
| 31 CastLoggingEvent event, uint32 rtp_timestamp, | 31 CastLoggingEvent event, uint32 rtp_timestamp, |
| 32 uint32 frame_id); | 32 uint32 frame_id); |
| 33 | 33 |
| 34 void InsertFrameEventWithSize(const base::TimeTicks& time_of_event, | 34 void InsertFrameEventWithSize(const base::TimeTicks& time_of_event, |
| 35 CastLoggingEvent event, uint32 rtp_timestamp, | 35 CastLoggingEvent event, uint32 rtp_timestamp, |
| 36 uint32 frame_id, int frame_size); | 36 uint32 frame_id, int frame_size); |
| 37 | 37 |
| 38 void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, | 38 void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, |
| 39 CastLoggingEvent event, uint32 rtp_timestamp, | 39 CastLoggingEvent event, uint32 rtp_timestamp, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 | 59 |
| 60 // Get stats only. | 60 // Get stats only. |
| 61 FrameStatsMap GetFrameStatsData() const; | 61 FrameStatsMap GetFrameStatsData() const; |
| 62 PacketStatsMap GetPacketStatsData() const; | 62 PacketStatsMap GetPacketStatsData() const; |
| 63 GenericStatsMap GetGenericStatsData() const; | 63 GenericStatsMap GetGenericStatsData() const; |
| 64 | 64 |
| 65 // Reset stats logging data. | 65 // Reset stats logging data. |
| 66 void ResetStats(); | 66 void ResetStats(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_; | 69 base::ThreadChecker thread_checker_; |
| 70 const CastLoggingConfig config_; | 70 const CastLoggingConfig config_; |
| 71 LoggingRaw raw_; | 71 LoggingRaw raw_; |
| 72 LoggingStats stats_; | 72 LoggingStats stats_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(LoggingImpl); | 74 DISALLOW_COPY_AND_ASSIGN(LoggingImpl); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace cast | 77 } // namespace cast |
| 78 } // namespace media | 78 } // namespace media |
| 79 | 79 |
| 80 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ | 80 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ |
| OLD | NEW |