Chromium Code Reviews| 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/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 // A count of all MediaLogs created on this render process. | 18 // A count of all MediaLogs created on this render process. |
| 18 // Used to generate unique ids. | 19 // Used to generate unique ids. |
| 19 static base::AtomicSequenceNumber media_log_count(base::LINKER_INITIALIZED); | 20 static base::LazyInstance<base::AtomicSequenceNumber> media_log_count = |
|
Nico
2012/01/18 03:48:31
This needs LeakyLakyInstanceTraits as 2nd template
Ami GONE FROM CHROMIUM
2012/01/18 04:52:31
As you wish: https://chromiumcodereview.appspot.co
| |
| 21 LAZY_INSTANCE_INITIALIZER; | |
| 20 | 22 |
| 21 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { | 23 const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) { |
| 22 switch (type) { | 24 switch (type) { |
| 23 case MediaLogEvent::WEBMEDIAPLAYER_CREATED: | 25 case MediaLogEvent::WEBMEDIAPLAYER_CREATED: |
| 24 return "WEBMEDIAPLAYER_CREATED"; | 26 return "WEBMEDIAPLAYER_CREATED"; |
| 25 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED: | 27 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED: |
| 26 return "WEBMEDIAPLAYER_DESTROYED"; | 28 return "WEBMEDIAPLAYER_DESTROYED"; |
| 27 case MediaLogEvent::PIPELINE_CREATED: | 29 case MediaLogEvent::PIPELINE_CREATED: |
| 28 return "PIPELINE_CREATED"; | 30 return "PIPELINE_CREATED"; |
| 29 case MediaLogEvent::PIPELINE_DESTROYED: | 31 case MediaLogEvent::PIPELINE_DESTROYED: |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 case DECODER_ERROR_NOT_SUPPORTED: | 139 case DECODER_ERROR_NOT_SUPPORTED: |
| 138 return "decoder: not supported"; | 140 return "decoder: not supported"; |
| 139 case DATASOURCE_ERROR_URL_NOT_SUPPORTED: | 141 case DATASOURCE_ERROR_URL_NOT_SUPPORTED: |
| 140 return "data source: url not supported"; | 142 return "data source: url not supported"; |
| 141 } | 143 } |
| 142 NOTREACHED(); | 144 NOTREACHED(); |
| 143 return NULL; | 145 return NULL; |
| 144 } | 146 } |
| 145 | 147 |
| 146 MediaLog::MediaLog() { | 148 MediaLog::MediaLog() { |
| 147 id_ = media_log_count.GetNext(); | 149 id_ = media_log_count.Get().GetNext(); |
| 148 stats_update_pending_ = false; | 150 stats_update_pending_ = false; |
| 149 } | 151 } |
| 150 | 152 |
| 151 MediaLog::~MediaLog() {} | 153 MediaLog::~MediaLog() {} |
| 152 | 154 |
| 153 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { | 155 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) { |
| 154 } | 156 } |
| 155 | 157 |
| 156 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { | 158 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { |
| 157 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... | |
| 253 last_statistics_.video_bytes_decoded); | 255 last_statistics_.video_bytes_decoded); |
| 254 event->params.SetInteger("video_frames_decoded", | 256 event->params.SetInteger("video_frames_decoded", |
| 255 last_statistics_.video_frames_decoded); | 257 last_statistics_.video_frames_decoded); |
| 256 event->params.SetInteger("video_frames_dropped", | 258 event->params.SetInteger("video_frames_dropped", |
| 257 last_statistics_.video_frames_dropped); | 259 last_statistics_.video_frames_dropped); |
| 258 AddEvent(event.Pass()); | 260 AddEvent(event.Pass()); |
| 259 stats_update_pending_ = false; | 261 stats_update_pending_ = false; |
| 260 } | 262 } |
| 261 | 263 |
| 262 } //namespace media | 264 } //namespace media |
| OLD | NEW |