OLD | NEW |
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" | 10 #include "base/bind.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 // A count of all MediaLogs created on this render process. | 19 // A count of all MediaLogs created on this render process. |
20 // Used to generate unique ids. | 20 // Used to generate unique ids. |
21 static base::LazyInstance<base::AtomicSequenceNumber>::Leaky media_log_count = | 21 static base::StaticAtomicSequenceNumber media_log_count; |
22 LAZY_INSTANCE_INITIALIZER; | |
23 | 22 |
24 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { | 23 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { |
25 switch (type) { | 24 switch (type) { |
26 case MediaLogEvent::WEBMEDIAPLAYER_CREATED: | 25 case MediaLogEvent::WEBMEDIAPLAYER_CREATED: |
27 return "WEBMEDIAPLAYER_CREATED"; | 26 return "WEBMEDIAPLAYER_CREATED"; |
28 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED: | 27 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED: |
29 return "WEBMEDIAPLAYER_DESTROYED"; | 28 return "WEBMEDIAPLAYER_DESTROYED"; |
30 case MediaLogEvent::PIPELINE_CREATED: | 29 case MediaLogEvent::PIPELINE_CREATED: |
31 return "PIPELINE_CREATED"; | 30 return "PIPELINE_CREATED"; |
32 case MediaLogEvent::PIPELINE_DESTROYED: | 31 case MediaLogEvent::PIPELINE_DESTROYED: |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 case DECODER_ERROR_NOT_SUPPORTED: | 139 case DECODER_ERROR_NOT_SUPPORTED: |
141 return "decoder: not supported"; | 140 return "decoder: not supported"; |
142 case DATASOURCE_ERROR_URL_NOT_SUPPORTED: | 141 case DATASOURCE_ERROR_URL_NOT_SUPPORTED: |
143 return "data source: url not supported"; | 142 return "data source: url not supported"; |
144 } | 143 } |
145 NOTREACHED(); | 144 NOTREACHED(); |
146 return NULL; | 145 return NULL; |
147 } | 146 } |
148 | 147 |
149 MediaLog::MediaLog() { | 148 MediaLog::MediaLog() { |
150 id_ = media_log_count.Get().GetNext(); | 149 id_ = media_log_count.GetNext(); |
151 stats_update_pending_ = false; | 150 stats_update_pending_ = false; |
152 } | 151 } |
153 | 152 |
154 MediaLog::~MediaLog() {} | 153 MediaLog::~MediaLog() {} |
155 | 154 |
156 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { | 155 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { |
157 } | 156 } |
158 | 157 |
159 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { | 158 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { |
160 scoped_ptr<MediaLogEvent> event(new MediaLogEvent); | 159 scoped_ptr<MediaLogEvent> event(new MediaLogEvent); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 last_statistics_.video_bytes_decoded); | 255 last_statistics_.video_bytes_decoded); |
257 event->params.SetInteger("video_frames_decoded", | 256 event->params.SetInteger("video_frames_decoded", |
258 last_statistics_.video_frames_decoded); | 257 last_statistics_.video_frames_decoded); |
259 event->params.SetInteger("video_frames_dropped", | 258 event->params.SetInteger("video_frames_dropped", |
260 last_statistics_.video_frames_dropped); | 259 last_statistics_.video_frames_dropped); |
261 AddEvent(event.Pass()); | 260 AddEvent(event.Pass()); |
262 stats_update_pending_ = false; | 261 stats_update_pending_ = false; |
263 } | 262 } |
264 | 263 |
265 } //namespace media | 264 } //namespace media |
OLD | NEW |