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

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

Issue 877273002: Add media log messages to the main log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better logging Created 5 years, 10 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
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/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 // A count of all MediaLogs created in the current process. Used to generate 16 // A count of all MediaLogs created in the current process. Used to generate
16 // unique IDs. 17 // unique IDs.
17 static base::StaticAtomicSequenceNumber g_media_log_count; 18 static base::StaticAtomicSequenceNumber g_media_log_count;
18 19
19 std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) { 20 std::string MediaLog::EventTypeToString(MediaLogEvent::Type type) {
20 switch (type) { 21 switch (type) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return "demuxer: could not parse"; 92 return "demuxer: could not parse";
92 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS: 93 case DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
93 return "demuxer: no supported streams"; 94 return "demuxer: no supported streams";
94 case DECODER_ERROR_NOT_SUPPORTED: 95 case DECODER_ERROR_NOT_SUPPORTED:
95 return "decoder: not supported"; 96 return "decoder: not supported";
96 } 97 }
97 NOTREACHED(); 98 NOTREACHED();
98 return NULL; 99 return NULL;
99 } 100 }
100 101
102 std::string MediaLog::MediaEventToLogString(const MediaLogEvent& event) {
wolenetz 2015/02/04 22:04:18 This method seems quite fragile to event parameter
103 std::string param;
104 switch (event.type) {
105 case MediaLogEvent::WEBMEDIAPLAYER_CREATED:
106 case MediaLogEvent::WEBMEDIAPLAYER_DESTROYED:
107 case MediaLogEvent::PIPELINE_CREATED:
108 case MediaLogEvent::PIPELINE_DESTROYED:
109 case MediaLogEvent::PLAY:
110 case MediaLogEvent::PAUSE:
111 case MediaLogEvent::ENDED:
112 case MediaLogEvent::TEXT_ENDED:
113 case MediaLogEvent::BUFFERED_EXTENTS_CHANGED:
114 case MediaLogEvent::TOTAL_BYTES_SET:
115 case MediaLogEvent::NETWORK_ACTIVITY_SET:
116 case MediaLogEvent::PROPERTY_CHANGE:
117 return EventTypeToString(event.type);
118
119 case MediaLogEvent::LOAD:
120 event.params.GetString("url", &param);
121 return EventTypeToString(event.type) + " url=" + param;
122
123 case MediaLogEvent::SEEK:
124 {
125 double seek_target = 0.0;
126 if (event.params.GetDouble("seek_target", &seek_target)) {
127 return EventTypeToString(event.type) + " seek_target=" +
128 base::DoubleToString(seek_target);
129 }
130 return EventTypeToString(event.type) + " seek_target=unknown";
131 }
132
133 case MediaLogEvent::PIPELINE_STATE_CHANGED:
134 event.params.GetString("pipeline_state", &param);
135 return EventTypeToString(event.type) + " pipeline_state=" + param;
136
137 case MediaLogEvent::PIPELINE_ERROR:
138 event.params.GetString("pipeline_error", &param);
139 return EventTypeToString(event.type) + " pipeline_error=" + param;
140
141 case MediaLogEvent::VIDEO_SIZE_SET:
142 {
143 int width = 0;
144 int height = 0;
145 event.params.GetInteger("width", &width);
146 event.params.GetInteger("height", &height);
147 return EventTypeToString(event.type) + " " + base::IntToString(width) +
148 "x" + base::IntToString(height);
149 }
150
151 case MediaLogEvent::DURATION_SET:
152 {
153 double duration = 0.0;
154 if (event.params.GetDouble("duration", &duration)) {
155 return EventTypeToString(event.type) + " duration=" +
156 base::DoubleToString(duration);
157 }
158 return EventTypeToString(event.type) + " duration=unknown";
159 }
160
161 case MediaLogEvent::MEDIA_SOURCE_ERROR:
162 event.params.GetString("error", &param);
163 return EventTypeToString(event.type) + " error=" + param;
164
165 default:
wolenetz 2015/02/04 22:04:18 Please drop the default case and instead let build
166 return "UNKNOWN_EVENT_TYPE!!";
167 }
168 NOTREACHED();
169 return NULL;
170 }
171
101 LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {} 172 LogHelper::LogHelper(const LogCB& log_cb) : log_cb_(log_cb) {}
102 173
103 LogHelper::~LogHelper() { 174 LogHelper::~LogHelper() {
104 if (log_cb_.is_null()) 175 if (log_cb_.is_null())
105 return; 176 return;
106 log_cb_.Run(stream_.str()); 177 log_cb_.Run(stream_.str());
107 } 178 }
108 179
109 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {} 180 MediaLog::MediaLog() : id_(g_media_log_count.GetNext()) {}
110 181
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const std::string& key, base::TimeDelta value) { 308 const std::string& key, base::TimeDelta value) {
238 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 309 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
239 if (value.is_max()) 310 if (value.is_max())
240 event->params.SetString(key, "unknown"); 311 event->params.SetString(key, "unknown");
241 else 312 else
242 event->params.SetDouble(key, value.InSecondsF()); 313 event->params.SetDouble(key, value.InSecondsF());
243 AddEvent(event.Pass()); 314 AddEvent(event.Pass());
244 } 315 }
245 316
246 } //namespace media 317 } //namespace media
OLDNEW
« content/renderer/media/render_media_log.cc ('K') | « media/base/media_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698