| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 scoped_ptr<MediaLogEvent> event( | 229 scoped_ptr<MediaLogEvent> event( |
| 230 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); | 230 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); |
| 231 // These values are headed to JS where there is no int64 so we use a double | 231 // These values are headed to JS where there is no int64 so we use a double |
| 232 // and accept loss of precision above 2^53 bytes (8 Exabytes). | 232 // and accept loss of precision above 2^53 bytes (8 Exabytes). |
| 233 event->params.SetDouble("buffer_start", start); | 233 event->params.SetDouble("buffer_start", start); |
| 234 event->params.SetDouble("buffer_current", current); | 234 event->params.SetDouble("buffer_current", current); |
| 235 event->params.SetDouble("buffer_end", end); | 235 event->params.SetDouble("buffer_end", end); |
| 236 return event.Pass(); | 236 return event.Pass(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) { | 239 scoped_ptr<MediaLogEvent> MediaLog::CreateLogEvent(MediaLogLevel level, |
| 240 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level))); | 240 const std::string& message) { |
| 241 event->params.SetString(MediaLogLevelToString(level), message); | 241 const MediaLogEvent::Type type = MediaLogLevelToEventType(level); |
| 242 AddEvent(event.Pass()); | 242 const std::string param = MediaLogLevelToString(level); |
| 243 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); |
| 244 event->params.SetString(param, message); |
| 245 return event.Pass(); |
| 243 } | 246 } |
| 244 | 247 |
| 245 void MediaLog::SetStringProperty( | 248 void MediaLog::SetStringProperty( |
| 246 const std::string& key, const std::string& value) { | 249 const std::string& key, const std::string& value) { |
| 247 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); | 250 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); |
| 248 event->params.SetString(key, value); | 251 event->params.SetString(key, value); |
| 249 AddEvent(event.Pass()); | 252 AddEvent(event.Pass()); |
| 250 } | 253 } |
| 251 | 254 |
| 252 void MediaLog::SetIntegerProperty( | 255 void MediaLog::SetIntegerProperty( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 : level_(level), log_cb_(log_cb) { | 287 : level_(level), log_cb_(log_cb) { |
| 285 } | 288 } |
| 286 | 289 |
| 287 LogHelper::~LogHelper() { | 290 LogHelper::~LogHelper() { |
| 288 if (log_cb_.is_null()) | 291 if (log_cb_.is_null()) |
| 289 return; | 292 return; |
| 290 log_cb_.Run(level_, stream_.str()); | 293 log_cb_.Run(level_, stream_.str()); |
| 291 } | 294 } |
| 292 | 295 |
| 293 } //namespace media | 296 } //namespace media |
| OLD | NEW |