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

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

Issue 9015015: Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: acolwell CR#2 responses. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « media/base/media_log.h ('k') | media/base/mock_filters.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return NULL; 143 return NULL;
144 } 144 }
145 145
146 MediaLog::MediaLog() { 146 MediaLog::MediaLog() {
147 id_ = media_log_count.GetNext(); 147 id_ = media_log_count.GetNext();
148 stats_update_pending_ = false; 148 stats_update_pending_ = false;
149 } 149 }
150 150
151 MediaLog::~MediaLog() {} 151 MediaLog::~MediaLog() {}
152 152
153 void MediaLog::AddEvent(MediaLogEvent* event) { 153 void MediaLog::AddEvent(scoped_ptr<MediaLogEvent> event) {
154 scoped_ptr<MediaLogEvent> e(event);
155 } 154 }
156 155
157 MediaLogEvent* MediaLog::CreateEvent(MediaLogEvent::Type type) { 156 scoped_ptr<MediaLogEvent> MediaLog::CreateEvent(MediaLogEvent::Type type) {
158 scoped_ptr<MediaLogEvent> event(new MediaLogEvent); 157 scoped_ptr<MediaLogEvent> event(new MediaLogEvent);
159 event->id = id_; 158 event->id = id_;
160 event->type = type; 159 event->type = type;
161 event->time = base::Time::Now(); 160 event->time = base::Time::Now();
162 return event.release(); 161 return event.Pass();
163 } 162 }
164 163
165 MediaLogEvent* MediaLog::CreateBooleanEvent(MediaLogEvent::Type type, 164 scoped_ptr<MediaLogEvent> MediaLog::CreateBooleanEvent(MediaLogEvent::Type type,
166 const char* property, bool value) { 165 const char* property, bool value) {
scherkus (not reviewing) 2012/01/10 02:11:30 indent here + below
Ami GONE FROM CHROMIUM 2012/01/10 03:26:00 Done.
167 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 166 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
168 event->params.SetBoolean(property, value); 167 event->params.SetBoolean(property, value);
169 return event.release(); 168 return event.Pass();
170 } 169 }
171 170
172 MediaLogEvent* MediaLog::CreateIntegerEvent(MediaLogEvent::Type type, 171 scoped_ptr<MediaLogEvent> MediaLog::CreateIntegerEvent(MediaLogEvent::Type type,
173 const char* property, int64 value) { 172 const char* property, int64 value) {
174 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 173 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
175 event->params.SetInteger(property, value); 174 event->params.SetInteger(property, value);
176 return event.release(); 175 return event.Pass();
177 } 176 }
178 177
179 MediaLogEvent* MediaLog::CreateTimeEvent(MediaLogEvent::Type type, 178 scoped_ptr<MediaLogEvent> MediaLog::CreateTimeEvent(MediaLogEvent::Type type,
180 const char* property, 179 const char* property,
181 base::TimeDelta value) { 180 base::TimeDelta value) {
182 scoped_ptr<MediaLogEvent> event(CreateEvent(type)); 181 scoped_ptr<MediaLogEvent> event(CreateEvent(type));
183 event->params.SetDouble(property, value.InSecondsF()); 182 event->params.SetDouble(property, value.InSecondsF());
184 return event.release(); 183 return event.Pass();
185 } 184 }
186 185
187 MediaLogEvent* MediaLog::CreateLoadEvent(const std::string& url) { 186 scoped_ptr<MediaLogEvent> MediaLog::CreateLoadEvent(const std::string& url) {
188 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD)); 187 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::LOAD));
189 event->params.SetString("url", url); 188 event->params.SetString("url", url);
190 return event.release(); 189 return event.Pass();
191 } 190 }
192 191
193 MediaLogEvent* MediaLog::CreateSeekEvent(float seconds) { 192 scoped_ptr<MediaLogEvent> MediaLog::CreateSeekEvent(float seconds) {
194 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK)); 193 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::SEEK));
195 event->params.SetDouble("seek_target", seconds); 194 event->params.SetDouble("seek_target", seconds);
196 return event.release(); 195 return event.Pass();
197 } 196 }
198 197
199 MediaLogEvent* MediaLog::CreatePipelineStateChangedEvent( 198 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineStateChangedEvent(
200 PipelineImpl::State state) { 199 PipelineImpl::State state) {
201 scoped_ptr<MediaLogEvent> event( 200 scoped_ptr<MediaLogEvent> event(
202 CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED)); 201 CreateEvent(MediaLogEvent::PIPELINE_STATE_CHANGED));
203 event->params.SetString("pipeline_state", PipelineStateToString(state)); 202 event->params.SetString("pipeline_state", PipelineStateToString(state));
204 return event.release(); 203 return event.Pass();
205 } 204 }
206 205
207 MediaLogEvent* MediaLog::CreatePipelineErrorEvent(PipelineStatus error) { 206 scoped_ptr<MediaLogEvent> MediaLog::CreatePipelineErrorEvent(
207 PipelineStatus error) {
208 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR)); 208 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::PIPELINE_ERROR));
209 event->params.SetString("pipeline_error", PipelineStatusToString(error)); 209 event->params.SetString("pipeline_error", PipelineStatusToString(error));
210 return event.release(); 210 return event.Pass();
211 } 211 }
212 212
213 MediaLogEvent* MediaLog::CreateVideoSizeSetEvent(size_t width, size_t height) { 213 scoped_ptr<MediaLogEvent> MediaLog::CreateVideoSizeSetEvent(
214 size_t width, size_t height) {
214 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET)); 215 scoped_ptr<MediaLogEvent> event(CreateEvent(MediaLogEvent::VIDEO_SIZE_SET));
215 event->params.SetInteger("width", width); 216 event->params.SetInteger("width", width);
216 event->params.SetInteger("height", height); 217 event->params.SetInteger("height", height);
217 return event.release(); 218 return event.Pass();
218 } 219 }
219 220
220 MediaLogEvent* MediaLog::CreateBufferedExtentsChangedEvent( 221 scoped_ptr<MediaLogEvent> MediaLog::CreateBufferedExtentsChangedEvent(
221 size_t start, size_t current, size_t end) { 222 size_t start, size_t current, size_t end) {
222 scoped_ptr<MediaLogEvent> event( 223 scoped_ptr<MediaLogEvent> event(
223 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED)); 224 CreateEvent(MediaLogEvent::BUFFERED_EXTENTS_CHANGED));
224 event->params.SetInteger("buffer_start", start); 225 event->params.SetInteger("buffer_start", start);
225 event->params.SetInteger("buffer_current", current); 226 event->params.SetInteger("buffer_current", current);
226 event->params.SetInteger("buffer_end", end); 227 event->params.SetInteger("buffer_end", end);
227 return event.release(); 228 return event.Pass();
228 } 229 }
229 230
230 void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) { 231 void MediaLog::QueueStatisticsUpdatedEvent(PipelineStatistics stats) {
231 base::AutoLock auto_lock(stats_lock_); 232 base::AutoLock auto_lock(stats_lock_);
232 last_statistics_ = stats; 233 last_statistics_ = stats;
233 234
234 // Sadly, this function can get dispatched on threads not running a message 235 // Sadly, this function can get dispatched on threads not running a message
235 // loop. Happily, this is pretty rare (only VideoRendererBase at this time) 236 // loop. Happily, this is pretty rare (only VideoRendererBase at this time)
236 // so we simply leave stats updating for another call to trigger. 237 // so we simply leave stats updating for another call to trigger.
237 if (!stats_update_pending_ && MessageLoop::current()) { 238 if (!stats_update_pending_ && MessageLoop::current()) {
(...skipping 10 matching lines...) Expand all
248 scoped_ptr<MediaLogEvent> event( 249 scoped_ptr<MediaLogEvent> event(
249 CreateEvent(MediaLogEvent::STATISTICS_UPDATED)); 250 CreateEvent(MediaLogEvent::STATISTICS_UPDATED));
250 event->params.SetInteger("audio_bytes_decoded", 251 event->params.SetInteger("audio_bytes_decoded",
251 last_statistics_.audio_bytes_decoded); 252 last_statistics_.audio_bytes_decoded);
252 event->params.SetInteger("video_bytes_decoded", 253 event->params.SetInteger("video_bytes_decoded",
253 last_statistics_.video_bytes_decoded); 254 last_statistics_.video_bytes_decoded);
254 event->params.SetInteger("video_frames_decoded", 255 event->params.SetInteger("video_frames_decoded",
255 last_statistics_.video_frames_decoded); 256 last_statistics_.video_frames_decoded);
256 event->params.SetInteger("video_frames_dropped", 257 event->params.SetInteger("video_frames_dropped",
257 last_statistics_.video_frames_dropped); 258 last_statistics_.video_frames_dropped);
258 AddEvent(event.release()); 259 AddEvent(event.Pass());
259 stats_update_pending_ = false; 260 stats_update_pending_ = false;
260 } 261 }
261 262
262 } //namespace media 263 } //namespace media
OLDNEW
« no previous file with comments | « media/base/media_log.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698