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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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_file_checker_unittest.cc ('k') | media/base/pipeline.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 <utility>
8
7 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
8 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
9 #include "base/values.h" 11 #include "base/values.h"
10 12
11 namespace media { 13 namespace media {
12 14
13 // A count of all MediaLogs created in the current process. Used to generate 15 // A count of all MediaLogs created in the current process. Used to generate
14 // unique IDs. 16 // unique IDs.
15 static base::StaticAtomicSequenceNumber g_media_log_count; 17 static base::StaticAtomicSequenceNumber g_media_log_count;
16 18
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 142
141 MediaLog::~MediaLog() {} 143 MediaLog::~MediaLog() {}
142 144
143 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) {} 145 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) {}
144 146
145 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) { 147 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) {
146 scoped_ptr<MediaLogEvent> event(new MediaLogEvent); 148 scoped_ptr<MediaLogEvent> event(new MediaLogEvent);
147 event->id = id_; 149 event->id = id_;
148 event->type = type; 150 event->type = type;
149 event->time = base::TimeTicks::Now(); 151 event->time = base::TimeTicks::Now();
150 return event.Pass(); 152 return event;
151 } 153 }
152 154
153 scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent( 155 scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent(
154 MediaLogEvent::Type type, 156 MediaLogEvent::Type type,
155 const std::string& property, 157 const std::string& property,
156 bool value) { 158 bool value) {
157 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 159 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
158 event->params.SetBoolean(property, value); 160 event->params.SetBoolean(property, value);
159 return event.Pass(); 161 return event;
160 } 162 }
161 163
162 scoped_ptr<MediaLogEvent> MediaLog::CreateStringEvent( 164 scoped_ptr<MediaLogEvent> MediaLog::CreateStringEvent(
163 MediaLogEvent::Type type, 165 MediaLogEvent::Type type,
164 const std::string& property, 166 const std::string& property,
165 const std::string& value) { 167 const std::string& value) {
166 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 168 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
167 event->params.SetString(property, value); 169 event->params.SetString(property, value);
168 return event.Pass(); 170 return event;
169 } 171 }
170 172
171 scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent( 173 scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent(
172 MediaLogEvent::Type type, 174 MediaLogEvent::Type type,
173 const std::string& property, 175 const std::string& property,
174 base::TimeDelta value) { 176 base::TimeDelta value) {
175 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 177 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
176 if (value.is_max()) 178 if (value.is_max())
177 event->params.SetString(property, "unknown"); 179 event->params.SetString(property, "unknown");
178 else 180 else
179 event->params.SetDouble(property, value.InSecondsF()); 181 event->params.SetDouble(property, value.InSecondsF());
180 return event.Pass(); 182 return event;
181 } 183 }
182 184
183 scoped_ptr<MediaLogEvent> MediaLog::CreateLoadEvent(const std::string& url) { 185 scoped_ptr<MediaLogEvent> MediaLog::CreateLoadEvent(const std::string& url) {
184 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD)); 186 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD));
185 event->params.SetString("url", url); 187 event->params.SetString("url", url);
186 return event.Pass(); 188 return event;
187 } 189 }
188 190
189 scoped_ptr<MediaLogEvent> MediaLog::CreateSeekEvent(float seconds) { 191 scoped_ptr<MediaLogEvent> MediaLog::CreateSeekEvent(float seconds) {
190 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK)); 192 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK));
191 event->params.SetDouble("seek_target", seconds); 193 event->params.SetDouble("seek_target", seconds);
192 return event.Pass(); 194 return event;
193 } 195 }
194 196
195 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent( 197 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent(
196 Pipeline::State state) { 198 Pipeline::State state) {
197 scoped_ptr<MediaLogEvent> event( 199 scoped_ptr<MediaLogEvent> event(
198 CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED)); 200 CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED));
199 event->params.SetString("pipeline_state", Pipeline::GetStateString(state)); 201 event->params.SetString("pipeline_state", Pipeline::GetStateString(state));
200 return event.Pass(); 202 return event;
201 } 203 }
202 204
203 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineErrorEvent( 205 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineErrorEvent(
204 PipelineStatus error) { 206 PipelineStatus error) {
205 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR)); 207 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR));
206 event->params.SetInteger("pipeline_error", error); 208 event->params.SetInteger("pipeline_error", error);
207 return event.Pass(); 209 return event;
208 } 210 }
209 211
210 scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent( 212 scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent(
211 size_t width, size_t height) { 213 size_t width, size_t height) {
212 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET)); 214 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET));
213 event->params.SetInteger("width", width); 215 event->params.SetInteger("width", width);
214 event->params.SetInteger("height", height); 216 event->params.SetInteger("height", height);
215 return event.Pass(); 217 return event;
216 } 218 }
217 219
218 scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent( 220 scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent(
219 int64_t start, 221 int64_t start,
220 int64_t current, 222 int64_t current,
221 int64_t end) { 223 int64_t end) {
222 scoped_ptr<MediaLogEvent> event( 224 scoped_ptr<MediaLogEvent> event(
223 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); 225 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED));
224 // These values are headed to JS where there is no int64_t so we use a double 226 // These values are headed to JS where there is no int64_t so we use a double
225 // and accept loss of precision above 2^53 bytes (8 Exabytes). 227 // and accept loss of precision above 2^53 bytes (8 Exabytes).
226 event->params.SetDouble("buffer_start", start); 228 event->params.SetDouble("buffer_start", start);
227 event->params.SetDouble("buffer_current", current); 229 event->params.SetDouble("buffer_current", current);
228 event->params.SetDouble("buffer_end", end); 230 event->params.SetDouble("buffer_end", end);
229 return event.Pass(); 231 return event;
230 } 232 }
231 233
232 void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) { 234 void MediaLog::AddLogEvent(MediaLogLevel level, const std::string& message) {
233 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level))); 235 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogLevelToEventType(level)));
234 event->params.SetString(MediaLogLevelToString(level), message); 236 event->params.SetString(MediaLogLevelToString(level), message);
235 AddEvent(event.Pass()); 237 AddEvent(std::move(event));
236 } 238 }
237 239
238 void MediaLog::SetStringProperty( 240 void MediaLog::SetStringProperty(
239 const std::string& key, const std::string& value) { 241 const std::string& key, const std::string& value) {
240 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 242 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
241 event->params.SetString(key, value); 243 event->params.SetString(key, value);
242 AddEvent(event.Pass()); 244 AddEvent(std::move(event));
243 } 245 }
244 246
245 void MediaLog::SetIntegerProperty( 247 void MediaLog::SetIntegerProperty(
246 const std::string& key, int value) { 248 const std::string& key, int value) {
247 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 249 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
248 event->params.SetInteger(key, value); 250 event->params.SetInteger(key, value);
249 AddEvent(event.Pass()); 251 AddEvent(std::move(event));
250 } 252 }
251 253
252 void MediaLog::SetDoubleProperty( 254 void MediaLog::SetDoubleProperty(
253 const std::string& key, double value) { 255 const std::string& key, double value) {
254 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 256 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
255 event->params.SetDouble(key, value); 257 event->params.SetDouble(key, value);
256 AddEvent(event.Pass()); 258 AddEvent(std::move(event));
257 } 259 }
258 260
259 void MediaLog::SetBooleanProperty( 261 void MediaLog::SetBooleanProperty(
260 const std::string& key, bool value) { 262 const std::string& key, bool value) {
261 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 263 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
262 event->params.SetBoolean(key, value); 264 event->params.SetBoolean(key, value);
263 AddEvent(event.Pass()); 265 AddEvent(std::move(event));
264 } 266 }
265 267
266 void MediaLog::SetTimeProperty( 268 void MediaLog::SetTimeProperty(
267 const std::string& key, base::TimeDelta value) { 269 const std::string& key, base::TimeDelta value) {
268 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE)); 270 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PROPERTY_CHANGE));
269 if (value.is_max()) 271 if (value.is_max())
270 event->params.SetString(key, "unknown"); 272 event->params.SetString(key, "unknown");
271 else 273 else
272 event->params.SetDouble(key, value.InSecondsF()); 274 event->params.SetDouble(key, value.InSecondsF());
273 AddEvent(event.Pass()); 275 AddEvent(std::move(event));
274 } 276 }
275 277
276 LogHelper::LogHelper(MediaLog::MediaLogLevel level, 278 LogHelper::LogHelper(MediaLog::MediaLogLevel level,
277 const scoped_refptr<MediaLog>& media_log) 279 const scoped_refptr<MediaLog>& media_log)
278 : level_(level), media_log_(media_log) { 280 : level_(level), media_log_(media_log) {
279 DCHECK(media_log_.get()); 281 DCHECK(media_log_.get());
280 } 282 }
281 283
282 LogHelper::~LogHelper() { 284 LogHelper::~LogHelper() {
283 media_log_->AddLogEvent(level_, stream_.str()); 285 media_log_->AddLogEvent(level_, stream_.str());
284 } 286 }
285 287
286 } //namespace media 288 } //namespace media
OLDNEW
« no previous file with comments | « media/base/media_file_checker_unittest.cc ('k') | media/base/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698