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

Side by Side Diff: media/base/media_log.cc

Issue 10332082: Remove reporting statistics reporting from chrome://media-internals and fix event logging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix year Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « media/base/media_log.h ('k') | media/base/media_log_event.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/media_log.h" 5 #include "media/base/media_log.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/bind.h"
11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 10 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
scherkus (not reviewing) 2012/05/10 02:45:03 this .h should be removed
14 #include "base/message_loop.h" 12 #include "base/message_loop.h"
15 #include "base/values.h" 13 #include "base/values.h"
16 14
17 namespace media { 15 namespace media {
18 16
19 // A count of all MediaLogs created on this render process. 17 // A count of all MediaLogs created in the current process. Used to generate
20 // Used to generate unique ids. 18 // unique IDs.
21 static base::StaticAtomicSequenceNumber media_log_count; 19 static base::StaticAtomicSequenceNumber g_media_log_count;
22 20
23 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { 21 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) {
24 switch (type) { 22 switch (type) {
25 case MediaLogEvent::WEBMEDIAPLAYER_CREATED: 23 case MediaLogEvent::WEBMEDIAPLAYER_CREATED:
26 return "WEBMEDIAPLAYER_CREATED"; 24 return "WEBMEDIAPLAYER_CREATED";
27 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED: 25 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED:
28 return "WEBMEDIAPLAYER_DESTROYED"; 26 return "WEBMEDIAPLAYER_DESTROYED";
29 case MediaLogEvent::PIPELINE_CREATED: 27 case MediaLogEvent::PIPELINE_CREATED:
30 return "PIPELINE_CREATED"; 28 return "PIPELINE_CREATED";
31 case MediaLogEvent::PIPELINE_DESTROYED: 29 case MediaLogEvent::PIPELINE_DESTROYED:
(...skipping 17 matching lines...) Expand all
49 case MediaLogEvent::TOTAL_BYTES_SET: 47 case MediaLogEvent::TOTAL_BYTES_SET:
50 return "TOTAL_BYTES_SET"; 48 return "TOTAL_BYTES_SET";
51 case MediaLogEvent::NETWORK_ACTIVITY_SET: 49 case MediaLogEvent::NETWORK_ACTIVITY_SET:
52 return "NETWORK_ACTIVITY_SET"; 50 return "NETWORK_ACTIVITY_SET";
53 case MediaLogEvent::ENDED: 51 case MediaLogEvent::ENDED:
54 return "ENDED"; 52 return "ENDED";
55 case MediaLogEvent::AUDIO_RENDERER_DISABLED: 53 case MediaLogEvent::AUDIO_RENDERER_DISABLED:
56 return "AUDIO_RENDERER_DISABLED"; 54 return "AUDIO_RENDERER_DISABLED";
57 case MediaLogEvent::BUFFERED_EXTENTS_CHANGED: 55 case MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
58 return "BUFFERED_EXTENTS_CHANGED"; 56 return "BUFFERED_EXTENTS_CHANGED";
59 case MediaLogEvent::STATISTICS_UPDATED:
60 return "STATISTICS_UPDATED";
61 } 57 }
62 NOTREACHED(); 58 NOTREACHED();
63 return NULL; 59 return NULL;
64 } 60 }
65 61
66 const char* MediaLog::PipelineStateToString(Pipeline::State state) { 62 const char* MediaLog::PipelineStateToString(Pipeline::State state) {
67 switch (state) { 63 switch (state) {
68 case Pipeline::kCreated: 64 case Pipeline::kCreated:
69 return "created"; 65 return "created";
70 case Pipeline::kInitDemuxer: 66 case Pipeline::kInitDemuxer:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return "dumuxer: could not parse"; 128 return "dumuxer: could not parse";
133 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS: 129 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
134 return "demuxer: no supported streams"; 130 return "demuxer: no supported streams";
135 case DECODER_ERROR_NOT_SUPPORTED: 131 case DECODER_ERROR_NOT_SUPPORTED:
136 return "decoder: not supported"; 132 return "decoder: not supported";
137 } 133 }
138 NOTREACHED(); 134 NOTREACHED();
139 return NULL; 135 return NULL;
140 } 136 }
141 137
142 MediaLog::MediaLog() { 138 MediaLog::MediaLog()
143 id_ = media_log_count.GetNext(); 139 : id_(g_media_log_count.GetNext()) {
scherkus (not reviewing) 2012/05/10 02:45:03 crap I need to fix indent here
Ami GONE FROM CHROMIUM 2012/05/10 17:16:49 single line?
scherkus (not reviewing) 2012/05/10 17:31:23 Done.
144 stats_update_pending_ = false;
145 } 140 }
146 141
147 MediaLog::~MediaLog() {} 142 MediaLog::~MediaLog() {}
148 143
149 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { 144 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) {}
Ami GONE FROM CHROMIUM 2012/05/10 17:16:49 Should this be pure-virtual?
scherkus (not reviewing) 2012/05/10 17:31:23 We create non-overridden MediaLogs in a few spots
150 }
151 145
152 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { 146 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) {
153 scoped_ptr<MediaLogEvent> event(new MediaLogEvent); 147 scoped_ptr<MediaLogEvent> event(new MediaLogEvent);
154 event->id = id_; 148 event->id = id_;
155 event->type = type; 149 event->type = type;
156 event->time = base::Time::Now(); 150 event->time = base::Time::Now();
157 return event.Pass(); 151 return event.Pass();
158 } 152 }
159 153
160 scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent( 154 scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent( 210 scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent(
217 size_t start, size_t current, size_t end) { 211 size_t start, size_t current, size_t end) {
218 scoped_ptr<MediaLogEvent> event( 212 scoped_ptr<MediaLogEvent> event(
219 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); 213 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED));
220 event->params.SetInteger("buffer_start", start); 214 event->params.SetInteger("buffer_start", start);
221 event->params.SetInteger("buffer_current", current); 215 event->params.SetInteger("buffer_current", current);
222 event->params.SetInteger("buffer_end", end); 216 event->params.SetInteger("buffer_end", end);
223 return event.Pass(); 217 return event.Pass();
224 } 218 }
225 219
226 void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) {
227 base::AutoLock auto_lock(stats_lock_);
228 last_statistics_ = stats;
229
230 // Sadly, this function can get dispatched on threads not running a message
231 // loop. Happily, this is pretty rare (only VideoRendererBase at this time)
232 // so we simply leave stats updating for another call to trigger.
233 if (!stats_update_pending_ && MessageLoop::current()) {
234 stats_update_pending_ = true;
235 MessageLoop::current()->PostDelayedTask(
236 FROM_HERE,
237 base::Bind(&media::MediaLog::AddStatisticsUpdatedEvent, this),
238 base::TimeDelta::FromMilliseconds(500));
239 }
240 }
241
242 void MediaLog::AddStatisticsUpdatedEvent() {
243 base::AutoLock auto_lock(stats_lock_);
244 scoped_ptr<MediaLogEvent> event(
245 CreateEvent(MediaLogEvent::STATISTICS_UPDATED));
246 event->params.SetInteger("audio_bytes_decoded",
247 last_statistics_.audio_bytes_decoded);
248 event->params.SetInteger("video_bytes_decoded",
249 last_statistics_.video_bytes_decoded);
250 event->params.SetInteger("video_frames_decoded",
251 last_statistics_.video_frames_decoded);
252 event->params.SetInteger("video_frames_dropped",
253 last_statistics_.video_frames_dropped);
254 AddEvent(event.Pass());
255 stats_update_pending_ = false;
256 }
257
258 } //namespace media 220 } //namespace media
OLDNEW
« no previous file with comments | « media/base/media_log.h ('k') | media/base/media_log_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698