Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: media/cast/logging/logging_impl.cc

Issue 210303003: Cast: Remove LoggingStats in favor of event subscribers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/logging/logging_impl.h ('k') | media/cast/logging/logging_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 #include "base/big_endian.h" 5 #include "base/big_endian.h"
6 #include "base/debug/trace_event.h" 6 #include "base/debug/trace_event.h"
7 #include "media/cast/logging/logging_impl.h" 7 #include "media/cast/logging/logging_impl.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
11 11
12 LoggingImpl::LoggingImpl(const CastLoggingConfig& config) 12 // TODO(imcheng): Collapse LoggingRaw onto LoggingImpl.
13 : config_(config), raw_(), stats_() { 13 LoggingImpl::LoggingImpl() {
14 // LoggingImpl can be constructed on any thread, but its methods should all be 14 // LoggingImpl can be constructed on any thread, but its methods should all be
15 // called on the same thread. 15 // called on the same thread.
16 thread_checker_.DetachFromThread(); 16 thread_checker_.DetachFromThread();
17 } 17 }
18 18
19 LoggingImpl::~LoggingImpl() {} 19 LoggingImpl::~LoggingImpl() {}
20 20
21 void LoggingImpl::InsertFrameEvent(const base::TimeTicks& time_of_event, 21 void LoggingImpl::InsertFrameEvent(const base::TimeTicks& time_of_event,
22 CastLoggingEvent event, uint32 rtp_timestamp, 22 CastLoggingEvent event, uint32 rtp_timestamp,
23 uint32 frame_id) { 23 uint32 frame_id) {
24 DCHECK(thread_checker_.CalledOnValidThread()); 24 DCHECK(thread_checker_.CalledOnValidThread());
25 if (config_.enable_raw_data_collection) { 25 raw_.InsertFrameEvent(time_of_event, event, rtp_timestamp, frame_id);
26 raw_.InsertFrameEvent(time_of_event, event, rtp_timestamp, frame_id);
27 }
28 if (config_.enable_stats_data_collection) {
29 stats_.InsertFrameEvent(time_of_event, event, rtp_timestamp, frame_id);
30 }
31 } 26 }
32 27
33 void LoggingImpl::InsertFrameEventWithSize(const base::TimeTicks& time_of_event, 28 void LoggingImpl::InsertFrameEventWithSize(const base::TimeTicks& time_of_event,
34 CastLoggingEvent event, 29 CastLoggingEvent event,
35 uint32 rtp_timestamp, 30 uint32 rtp_timestamp,
36 uint32 frame_id, int frame_size) { 31 uint32 frame_id, int frame_size) {
37 DCHECK(thread_checker_.CalledOnValidThread()); 32 DCHECK(thread_checker_.CalledOnValidThread());
38 if (config_.enable_raw_data_collection) { 33 raw_.InsertFrameEventWithSize(time_of_event, event, rtp_timestamp, frame_id,
39 raw_.InsertFrameEventWithSize(time_of_event, event, rtp_timestamp, frame_id, 34 frame_size);
40 frame_size);
41 }
42 if (config_.enable_stats_data_collection) {
43 stats_.InsertFrameEventWithSize(time_of_event, event, rtp_timestamp,
44 frame_id, frame_size);
45 }
46 } 35 }
47 36
48 void LoggingImpl::InsertFrameEventWithDelay( 37 void LoggingImpl::InsertFrameEventWithDelay(
49 const base::TimeTicks& time_of_event, CastLoggingEvent event, 38 const base::TimeTicks& time_of_event, CastLoggingEvent event,
50 uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay) { 39 uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay) {
51 DCHECK(thread_checker_.CalledOnValidThread()); 40 DCHECK(thread_checker_.CalledOnValidThread());
52 if (config_.enable_raw_data_collection) { 41 raw_.InsertFrameEventWithDelay(time_of_event, event, rtp_timestamp,
53 raw_.InsertFrameEventWithDelay(time_of_event, event, rtp_timestamp, 42 frame_id, delay);
54 frame_id, delay);
55 }
56 if (config_.enable_stats_data_collection) {
57 stats_.InsertFrameEventWithDelay(time_of_event, event, rtp_timestamp,
58 frame_id, delay);
59 }
60 } 43 }
61 44
62 void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, 45 void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event,
63 CastLoggingEvent event, 46 CastLoggingEvent event,
64 const Packet& packet) { 47 const Packet& packet) {
65 DCHECK(thread_checker_.CalledOnValidThread()); 48 DCHECK(thread_checker_.CalledOnValidThread());
66 49
67 // Parse basic properties. 50 // Parse basic properties.
68 uint32 rtp_timestamp; 51 uint32 rtp_timestamp;
69 uint16 packet_id, max_packet_id; 52 uint16 packet_id, max_packet_id;
(...skipping 25 matching lines...) Expand all
95 InsertSinglePacketEvent(time_of_event, event, *it); 78 InsertSinglePacketEvent(time_of_event, event, *it);
96 } 79 }
97 } 80 }
98 81
99 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event, 82 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event,
100 CastLoggingEvent event, 83 CastLoggingEvent event,
101 uint32 rtp_timestamp, uint32 frame_id, 84 uint32 rtp_timestamp, uint32 frame_id,
102 uint16 packet_id, uint16 max_packet_id, 85 uint16 packet_id, uint16 max_packet_id,
103 size_t size) { 86 size_t size) {
104 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
105 if (config_.enable_raw_data_collection) { 88 raw_.InsertPacketEvent(time_of_event, event, rtp_timestamp, frame_id,
106 raw_.InsertPacketEvent(time_of_event, event, rtp_timestamp, frame_id, 89 packet_id, max_packet_id, size);
107 packet_id, max_packet_id, size);
108 }
109 if (config_.enable_stats_data_collection) {
110 stats_.InsertPacketEvent(time_of_event, event, rtp_timestamp, frame_id,
111 packet_id, max_packet_id, size);
112 }
113 } 90 }
114 91
115 void LoggingImpl::InsertGenericEvent(const base::TimeTicks& time_of_event, 92 void LoggingImpl::InsertGenericEvent(const base::TimeTicks& time_of_event,
116 CastLoggingEvent event, int value) { 93 CastLoggingEvent event, int value) {
117 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
118 if (config_.enable_raw_data_collection) { 95 raw_.InsertGenericEvent(time_of_event, event, value);
119 raw_.InsertGenericEvent(time_of_event, event, value);
120 }
121 if (config_.enable_stats_data_collection) {
122 stats_.InsertGenericEvent(time_of_event, event, value);
123 }
124 } 96 }
125 97
126 void LoggingImpl::AddRawEventSubscriber(RawEventSubscriber* subscriber) { 98 void LoggingImpl::AddRawEventSubscriber(RawEventSubscriber* subscriber) {
127 DCHECK(thread_checker_.CalledOnValidThread()); 99 DCHECK(thread_checker_.CalledOnValidThread());
128 raw_.AddSubscriber(subscriber); 100 raw_.AddSubscriber(subscriber);
129 } 101 }
130 102
131 void LoggingImpl::RemoveRawEventSubscriber(RawEventSubscriber* subscriber) { 103 void LoggingImpl::RemoveRawEventSubscriber(RawEventSubscriber* subscriber) {
132 DCHECK(thread_checker_.CalledOnValidThread()); 104 DCHECK(thread_checker_.CalledOnValidThread());
133 raw_.RemoveSubscriber(subscriber); 105 raw_.RemoveSubscriber(subscriber);
134 } 106 }
135 107
136 FrameStatsMap LoggingImpl::GetFrameStatsData(EventMediaType media_type) const {
137 DCHECK(thread_checker_.CalledOnValidThread());
138 return stats_.GetFrameStatsData(media_type);
139 }
140
141 PacketStatsMap LoggingImpl::GetPacketStatsData(
142 EventMediaType media_type) const {
143 DCHECK(thread_checker_.CalledOnValidThread());
144 return stats_.GetPacketStatsData(media_type);
145 }
146
147 GenericStatsMap LoggingImpl::GetGenericStatsData() const {
148 DCHECK(thread_checker_.CalledOnValidThread());
149 return stats_.GetGenericStatsData();
150 }
151
152 void LoggingImpl::ResetStats() {
153 DCHECK(thread_checker_.CalledOnValidThread());
154 stats_.Reset();
155 }
156
157 } // namespace cast 108 } // namespace cast
158 } // namespace media 109 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/logging/logging_impl.h ('k') | media/cast/logging/logging_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698