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

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

Issue 1047313002: media-internals: Simplify the code path for creating a media log entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MEDIA_LOG_INFO_ERROR_DEBUG
Patch Set: Fix compile on Android Created 5 years, 8 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/base/media_log.h ('k') | media/blink/webmediaplayer_impl.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 (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
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 scoped_ptr<MediaLogEvent> MediaLog::CreateLogEvent(MediaLogLevel level, 239 void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) {
240 const std::string& message) { 240 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level)));
241 const MediaLogEvent::Type type = MediaLogLevelToEventType(level); 241 event->params.SetString(MediaLogLevelToString(level), message);
242 const std::string param = MediaLogLevelToString(level); 242 AddEvent(event.Pass());
243 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
244 event->params.SetString(param, message);
245 return event.Pass();
246 } 243 }
247 244
248 void MediaLog::SetStringProperty( 245 void MediaLog::SetStringProperty(
249 const std::string& key, const std::string& value) { 246 const std::string& key, const std::string& value) {
250 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 247 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
251 event->params.SetString(key, value); 248 event->params.SetString(key, value);
252 AddEvent(event.Pass()); 249 AddEvent(event.Pass());
253 } 250 }
254 251
255 void MediaLog::SetIntegerProperty( 252 void MediaLog::SetIntegerProperty(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 : level_(level), log_cb_(log_cb) { 284 : level_(level), log_cb_(log_cb) {
288 } 285 }
289 286
290 LogHelper::~LogHelper() { 287 LogHelper::~LogHelper() {
291 if (log_cb_.is_null()) 288 if (log_cb_.is_null())
292 return; 289 return;
293 log_cb_.Run(level_, stream_.str()); 290 log_cb_.Run(level_, stream_.str());
294 } 291 }
295 292
296 } //namespace media 293 } //namespace media
OLDNEW
« no previous file with comments | « media/base/media_log.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698