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

Side by Side Diff: webkit/media/buffered_data_source.cc

Issue 12388039: Use base::MessageLoopProxy instead of MessageLoop* in webkit/media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 9 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 | « webkit/media/buffered_data_source.h ('k') | webkit/media/buffered_data_source_unittest.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 "webkit/media/buffered_data_source.h" 5 #include "webkit/media/buffered_data_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop_proxy.h"
10 #include "media/base/media_log.h" 10 #include "media/base/media_log.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 12
13 using WebKit::WebFrame; 13 using WebKit::WebFrame;
14 14
15 namespace { 15 namespace {
16 16
17 // BufferedDataSource has an intermediate buffer, this value governs the initial 17 // BufferedDataSource has an intermediate buffer, this value governs the initial
18 // size of that buffer. It is set to 32KB because this is a typical read size 18 // size of that buffer. It is set to 32KB because this is a typical read size
19 // of FFmpeg. 19 // of FFmpeg.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DCHECK(callback_.is_null()); 71 DCHECK(callback_.is_null());
72 } 72 }
73 73
74 // static 74 // static
75 void BufferedDataSource::ReadOperation::Run( 75 void BufferedDataSource::ReadOperation::Run(
76 scoped_ptr<ReadOperation> read_op, int result) { 76 scoped_ptr<ReadOperation> read_op, int result) {
77 base::ResetAndReturn(&read_op->callback_).Run(result); 77 base::ResetAndReturn(&read_op->callback_).Run(result);
78 } 78 }
79 79
80 BufferedDataSource::BufferedDataSource( 80 BufferedDataSource::BufferedDataSource(
81 MessageLoop* render_loop, 81 const scoped_refptr<base::MessageLoopProxy>& render_loop,
82 WebFrame* frame, 82 WebFrame* frame,
83 media::MediaLog* media_log, 83 media::MediaLog* media_log,
84 const DownloadingCB& downloading_cb) 84 const DownloadingCB& downloading_cb)
85 : cors_mode_(BufferedResourceLoader::kUnspecified), 85 : cors_mode_(BufferedResourceLoader::kUnspecified),
86 total_bytes_(kPositionNotSpecified), 86 total_bytes_(kPositionNotSpecified),
87 assume_fully_buffered_(false), 87 assume_fully_buffered_(false),
88 streaming_(false), 88 streaming_(false),
89 frame_(frame), 89 frame_(frame),
90 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), 90 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]),
91 intermediate_read_buffer_size_(kInitialReadBufferSize), 91 intermediate_read_buffer_size_(kInitialReadBufferSize),
92 render_loop_(render_loop), 92 render_loop_(render_loop),
93 stop_signal_received_(false), 93 stop_signal_received_(false),
94 media_has_played_(false), 94 media_has_played_(false),
95 preload_(AUTO), 95 preload_(AUTO),
96 bitrate_(0), 96 bitrate_(0),
97 playback_rate_(0.0), 97 playback_rate_(0.0),
98 media_log_(media_log), 98 media_log_(media_log),
99 downloading_cb_(downloading_cb) { 99 downloading_cb_(downloading_cb) {
100 DCHECK(!downloading_cb_.is_null()); 100 DCHECK(!downloading_cb_.is_null());
101 } 101 }
102 102
103 BufferedDataSource::~BufferedDataSource() {} 103 BufferedDataSource::~BufferedDataSource() {}
104 104
105 // A factory method to create BufferedResourceLoader using the read parameters. 105 // A factory method to create BufferedResourceLoader using the read parameters.
106 // This method can be overridden to inject mock BufferedResourceLoader object 106 // This method can be overridden to inject mock BufferedResourceLoader object
107 // for testing purpose. 107 // for testing purpose.
108 BufferedResourceLoader* BufferedDataSource::CreateResourceLoader( 108 BufferedResourceLoader* BufferedDataSource::CreateResourceLoader(
109 int64 first_byte_position, int64 last_byte_position) { 109 int64 first_byte_position, int64 last_byte_position) {
110 DCHECK(MessageLoop::current() == render_loop_); 110 DCHECK(render_loop_->BelongsToCurrentThread());
111 111
112 BufferedResourceLoader::DeferStrategy strategy = preload_ == METADATA ? 112 BufferedResourceLoader::DeferStrategy strategy = preload_ == METADATA ?
113 BufferedResourceLoader::kReadThenDefer : 113 BufferedResourceLoader::kReadThenDefer :
114 BufferedResourceLoader::kCapacityDefer; 114 BufferedResourceLoader::kCapacityDefer;
115 115
116 return new BufferedResourceLoader(url_, 116 return new BufferedResourceLoader(url_,
117 cors_mode_, 117 cors_mode_,
118 first_byte_position, 118 first_byte_position,
119 last_byte_position, 119 last_byte_position,
120 strategy, 120 strategy,
121 bitrate_, 121 bitrate_,
122 playback_rate_, 122 playback_rate_,
123 media_log_); 123 media_log_);
124 } 124 }
125 125
126 void BufferedDataSource::set_host(media::DataSourceHost* host) { 126 void BufferedDataSource::set_host(media::DataSourceHost* host) {
127 DataSource::set_host(host); 127 DataSource::set_host(host);
128 128
129 if (loader_.get()) { 129 if (loader_.get()) {
130 base::AutoLock auto_lock(lock_); 130 base::AutoLock auto_lock(lock_);
131 UpdateHostState_Locked(); 131 UpdateHostState_Locked();
132 } 132 }
133 } 133 }
134 134
135 void BufferedDataSource::Initialize( 135 void BufferedDataSource::Initialize(
136 const GURL& url, 136 const GURL& url,
137 BufferedResourceLoader::CORSMode cors_mode, 137 BufferedResourceLoader::CORSMode cors_mode,
138 const InitializeCB& init_cb) { 138 const InitializeCB& init_cb) {
139 DCHECK(MessageLoop::current() == render_loop_); 139 DCHECK(render_loop_->BelongsToCurrentThread());
140 DCHECK(!init_cb.is_null()); 140 DCHECK(!init_cb.is_null());
141 DCHECK(!loader_.get()); 141 DCHECK(!loader_.get());
142 url_ = url; 142 url_ = url;
143 cors_mode_ = cors_mode; 143 cors_mode_ = cors_mode;
144 144
145 init_cb_ = init_cb; 145 init_cb_ = init_cb;
146 146
147 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) { 147 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) {
148 // Do an unbounded range request starting at the beginning. If the server 148 // Do an unbounded range request starting at the beginning. If the server
149 // responds with 200 instead of 206 we'll fall back into a streaming mode. 149 // responds with 200 instead of 206 we'll fall back into a streaming mode.
150 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified)); 150 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified));
151 } else { 151 } else {
152 // For all other protocols, assume they support range request. We fetch 152 // For all other protocols, assume they support range request. We fetch
153 // the full range of the resource to obtain the instance size because 153 // the full range of the resource to obtain the instance size because
154 // we won't be served HTTP headers. 154 // we won't be served HTTP headers.
155 loader_.reset(CreateResourceLoader(kPositionNotSpecified, 155 loader_.reset(CreateResourceLoader(kPositionNotSpecified,
156 kPositionNotSpecified)); 156 kPositionNotSpecified));
157 assume_fully_buffered_ = true; 157 assume_fully_buffered_ = true;
158 } 158 }
159 159
160 loader_->Start( 160 loader_->Start(
161 base::Bind(&BufferedDataSource::StartCallback, this), 161 base::Bind(&BufferedDataSource::StartCallback, this),
162 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, this), 162 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, this),
163 base::Bind(&BufferedDataSource::ProgressCallback, this), 163 base::Bind(&BufferedDataSource::ProgressCallback, this),
164 frame_); 164 frame_);
165 } 165 }
166 166
167 void BufferedDataSource::SetPreload(Preload preload) { 167 void BufferedDataSource::SetPreload(Preload preload) {
168 DCHECK(MessageLoop::current() == render_loop_); 168 DCHECK(render_loop_->BelongsToCurrentThread());
169 preload_ = preload; 169 preload_ = preload;
170 } 170 }
171 171
172 bool BufferedDataSource::HasSingleOrigin() { 172 bool BufferedDataSource::HasSingleOrigin() {
173 DCHECK(MessageLoop::current() == render_loop_); 173 DCHECK(render_loop_->BelongsToCurrentThread());
174 DCHECK(init_cb_.is_null() && loader_.get()) 174 DCHECK(init_cb_.is_null() && loader_.get())
175 << "Initialize() must complete before calling HasSingleOrigin()"; 175 << "Initialize() must complete before calling HasSingleOrigin()";
176 return loader_->HasSingleOrigin(); 176 return loader_->HasSingleOrigin();
177 } 177 }
178 178
179 bool BufferedDataSource::DidPassCORSAccessCheck() const { 179 bool BufferedDataSource::DidPassCORSAccessCheck() const {
180 return loader_.get() && loader_->DidPassCORSAccessCheck(); 180 return loader_.get() && loader_->DidPassCORSAccessCheck();
181 } 181 }
182 182
183 void BufferedDataSource::Abort() { 183 void BufferedDataSource::Abort() {
184 DCHECK(MessageLoop::current() == render_loop_); 184 DCHECK(render_loop_->BelongsToCurrentThread());
185 { 185 {
186 base::AutoLock auto_lock(lock_); 186 base::AutoLock auto_lock(lock_);
187 StopInternal_Locked(); 187 StopInternal_Locked();
188 } 188 }
189 StopLoader(); 189 StopLoader();
190 frame_ = NULL; 190 frame_ = NULL;
191 } 191 }
192 192
193 ///////////////////////////////////////////////////////////////////////////// 193 /////////////////////////////////////////////////////////////////////////////
194 // media::DataSource implementation. 194 // media::DataSource implementation.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return false; 244 return false;
245 } 245 }
246 246
247 bool BufferedDataSource::IsStreaming() { 247 bool BufferedDataSource::IsStreaming() {
248 return streaming_; 248 return streaming_;
249 } 249 }
250 250
251 ///////////////////////////////////////////////////////////////////////////// 251 /////////////////////////////////////////////////////////////////////////////
252 // Render thread tasks. 252 // Render thread tasks.
253 void BufferedDataSource::ReadTask() { 253 void BufferedDataSource::ReadTask() {
254 DCHECK(MessageLoop::current() == render_loop_); 254 DCHECK(render_loop_->BelongsToCurrentThread());
255 ReadInternal(); 255 ReadInternal();
256 } 256 }
257 257
258 void BufferedDataSource::StopInternal_Locked() { 258 void BufferedDataSource::StopInternal_Locked() {
259 lock_.AssertAcquired(); 259 lock_.AssertAcquired();
260 if (stop_signal_received_) 260 if (stop_signal_received_)
261 return; 261 return;
262 262
263 stop_signal_received_ = true; 263 stop_signal_received_ = true;
264 264
265 // Initialize() isn't part of the DataSource interface so don't call it in 265 // Initialize() isn't part of the DataSource interface so don't call it in
266 // response to Stop(). 266 // response to Stop().
267 init_cb_.Reset(); 267 init_cb_.Reset();
268 268
269 if (read_op_) 269 if (read_op_)
270 ReadOperation::Run(read_op_.Pass(), kReadError); 270 ReadOperation::Run(read_op_.Pass(), kReadError);
271 } 271 }
272 272
273 void BufferedDataSource::StopLoader() { 273 void BufferedDataSource::StopLoader() {
274 DCHECK(MessageLoop::current() == render_loop_); 274 DCHECK(render_loop_->BelongsToCurrentThread());
275 275
276 if (loader_.get()) 276 if (loader_.get())
277 loader_->Stop(); 277 loader_->Stop();
278 } 278 }
279 279
280 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) { 280 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) {
281 DCHECK(MessageLoop::current() == render_loop_); 281 DCHECK(render_loop_->BelongsToCurrentThread());
282 DCHECK(loader_.get()); 282 DCHECK(loader_.get());
283 283
284 if (playback_rate != 0) 284 if (playback_rate != 0)
285 media_has_played_ = true; 285 media_has_played_ = true;
286 286
287 playback_rate_ = playback_rate; 287 playback_rate_ = playback_rate;
288 loader_->SetPlaybackRate(playback_rate); 288 loader_->SetPlaybackRate(playback_rate);
289 289
290 if (!loader_->range_supported()) { 290 if (!loader_->range_supported()) {
291 // 200 responses end up not being reused to satisfy future range requests, 291 // 200 responses end up not being reused to satisfy future range requests,
292 // and we don't want to get too far ahead of the read-head (and thus require 292 // and we don't want to get too far ahead of the read-head (and thus require
293 // a restart), so keep to the thresholds. 293 // a restart), so keep to the thresholds.
294 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 294 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
295 } else if (media_has_played_ && playback_rate == 0) { 295 } else if (media_has_played_ && playback_rate == 0) {
296 // If the playback has started (at which point the preload value is ignored) 296 // If the playback has started (at which point the preload value is ignored)
297 // and we're paused, then try to load as much as possible (the loader will 297 // and we're paused, then try to load as much as possible (the loader will
298 // fall back to kCapacityDefer if it knows the current response won't be 298 // fall back to kCapacityDefer if it knows the current response won't be
299 // useful from the cache in the future). 299 // useful from the cache in the future).
300 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer); 300 loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer);
301 } else { 301 } else {
302 // If media is currently playing or the page indicated preload=auto, 302 // If media is currently playing or the page indicated preload=auto,
303 // use threshold strategy to enable/disable deferring when the buffer 303 // use threshold strategy to enable/disable deferring when the buffer
304 // is full/depleted. 304 // is full/depleted.
305 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 305 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
306 } 306 }
307 } 307 }
308 308
309 void BufferedDataSource::SetBitrateTask(int bitrate) { 309 void BufferedDataSource::SetBitrateTask(int bitrate) {
310 DCHECK(MessageLoop::current() == render_loop_); 310 DCHECK(render_loop_->BelongsToCurrentThread());
311 DCHECK(loader_.get()); 311 DCHECK(loader_.get());
312 312
313 bitrate_ = bitrate; 313 bitrate_ = bitrate;
314 loader_->SetBitrate(bitrate); 314 loader_->SetBitrate(bitrate);
315 } 315 }
316 316
317 // This method is the place where actual read happens, |loader_| must be valid 317 // This method is the place where actual read happens, |loader_| must be valid
318 // prior to make this method call. 318 // prior to make this method call.
319 void BufferedDataSource::ReadInternal() { 319 void BufferedDataSource::ReadInternal() {
320 DCHECK(MessageLoop::current() == render_loop_); 320 DCHECK(render_loop_->BelongsToCurrentThread());
321 int64 position = 0; 321 int64 position = 0;
322 int size = 0; 322 int size = 0;
323 { 323 {
324 base::AutoLock auto_lock(lock_); 324 base::AutoLock auto_lock(lock_);
325 if (stop_signal_received_) 325 if (stop_signal_received_)
326 return; 326 return;
327 327
328 position = read_op_->position(); 328 position = read_op_->position();
329 size = read_op_->size(); 329 size = read_op_->size();
330 } 330 }
331 331
332 // First we prepare the intermediate read buffer for BufferedResourceLoader 332 // First we prepare the intermediate read buffer for BufferedResourceLoader
333 // to write to. 333 // to write to.
334 if (size > intermediate_read_buffer_size_) { 334 if (size > intermediate_read_buffer_size_) {
335 intermediate_read_buffer_.reset(new uint8[size]); 335 intermediate_read_buffer_.reset(new uint8[size]);
336 } 336 }
337 337
338 // Perform the actual read with BufferedResourceLoader. 338 // Perform the actual read with BufferedResourceLoader.
339 loader_->Read( 339 loader_->Read(
340 position, size, intermediate_read_buffer_.get(), 340 position, size, intermediate_read_buffer_.get(),
341 base::Bind(&BufferedDataSource::ReadCallback, this)); 341 base::Bind(&BufferedDataSource::ReadCallback, this));
342 } 342 }
343 343
344 344
345 ///////////////////////////////////////////////////////////////////////////// 345 /////////////////////////////////////////////////////////////////////////////
346 // BufferedResourceLoader callback methods. 346 // BufferedResourceLoader callback methods.
347 void BufferedDataSource::StartCallback( 347 void BufferedDataSource::StartCallback(
348 BufferedResourceLoader::Status status) { 348 BufferedResourceLoader::Status status) {
349 DCHECK(MessageLoop::current() == render_loop_); 349 DCHECK(render_loop_->BelongsToCurrentThread());
350 DCHECK(loader_.get()); 350 DCHECK(loader_.get());
351 351
352 bool init_cb_is_null = false; 352 bool init_cb_is_null = false;
353 { 353 {
354 base::AutoLock auto_lock(lock_); 354 base::AutoLock auto_lock(lock_);
355 init_cb_is_null = init_cb_.is_null(); 355 init_cb_is_null = init_cb_.is_null();
356 } 356 }
357 if (init_cb_is_null) { 357 if (init_cb_is_null) {
358 loader_->Stop(); 358 loader_->Stop();
359 return; 359 return;
(...skipping 23 matching lines...) Expand all
383 383
384 if (success) 384 if (success)
385 UpdateHostState_Locked(); 385 UpdateHostState_Locked();
386 386
387 base::ResetAndReturn(&init_cb_).Run(success); 387 base::ResetAndReturn(&init_cb_).Run(success);
388 } 388 }
389 } 389 }
390 390
391 void BufferedDataSource::PartialReadStartCallback( 391 void BufferedDataSource::PartialReadStartCallback(
392 BufferedResourceLoader::Status status) { 392 BufferedResourceLoader::Status status) {
393 DCHECK(MessageLoop::current() == render_loop_); 393 DCHECK(render_loop_->BelongsToCurrentThread());
394 DCHECK(loader_.get()); 394 DCHECK(loader_.get());
395 395
396 if (status == BufferedResourceLoader::kOk) { 396 if (status == BufferedResourceLoader::kOk) {
397 // Once the request has started successfully, we can proceed with 397 // Once the request has started successfully, we can proceed with
398 // reading from it. 398 // reading from it.
399 ReadInternal(); 399 ReadInternal();
400 return; 400 return;
401 } 401 }
402 402
403 // Stop the resource loader since we have received an error. 403 // Stop the resource loader since we have received an error.
404 loader_->Stop(); 404 loader_->Stop();
405 405
406 // TODO(scherkus): we shouldn't have to lock to signal host(), see 406 // TODO(scherkus): we shouldn't have to lock to signal host(), see
407 // http://crbug.com/113712 for details. 407 // http://crbug.com/113712 for details.
408 base::AutoLock auto_lock(lock_); 408 base::AutoLock auto_lock(lock_);
409 if (stop_signal_received_) 409 if (stop_signal_received_)
410 return; 410 return;
411 ReadOperation::Run(read_op_.Pass(), kReadError); 411 ReadOperation::Run(read_op_.Pass(), kReadError);
412 } 412 }
413 413
414 void BufferedDataSource::ReadCallback( 414 void BufferedDataSource::ReadCallback(
415 BufferedResourceLoader::Status status, 415 BufferedResourceLoader::Status status,
416 int bytes_read) { 416 int bytes_read) {
417 DCHECK(MessageLoop::current() == render_loop_); 417 DCHECK(render_loop_->BelongsToCurrentThread());
418 418
419 // TODO(scherkus): we shouldn't have to lock to signal host(), see 419 // TODO(scherkus): we shouldn't have to lock to signal host(), see
420 // http://crbug.com/113712 for details. 420 // http://crbug.com/113712 for details.
421 base::AutoLock auto_lock(lock_); 421 base::AutoLock auto_lock(lock_);
422 if (stop_signal_received_) 422 if (stop_signal_received_)
423 return; 423 return;
424 424
425 if (status != BufferedResourceLoader::kOk) { 425 if (status != BufferedResourceLoader::kOk) {
426 // Stop the resource load if it failed. 426 // Stop the resource load if it failed.
427 loader_->Stop(); 427 loader_->Stop();
(...skipping 30 matching lines...) Expand all
458 host()->SetTotalBytes(total_bytes_); 458 host()->SetTotalBytes(total_bytes_);
459 host()->AddBufferedByteRange(loader_->first_byte_position(), 459 host()->AddBufferedByteRange(loader_->first_byte_position(),
460 total_bytes_); 460 total_bytes_);
461 } 461 }
462 } 462 }
463 ReadOperation::Run(read_op_.Pass(), bytes_read); 463 ReadOperation::Run(read_op_.Pass(), bytes_read);
464 } 464 }
465 465
466 void BufferedDataSource::LoadingStateChangedCallback( 466 void BufferedDataSource::LoadingStateChangedCallback(
467 BufferedResourceLoader::LoadingState state) { 467 BufferedResourceLoader::LoadingState state) {
468 DCHECK(MessageLoop::current() == render_loop_); 468 DCHECK(render_loop_->BelongsToCurrentThread());
469 469
470 if (assume_fully_buffered_) 470 if (assume_fully_buffered_)
471 return; 471 return;
472 472
473 bool is_downloading_data; 473 bool is_downloading_data;
474 switch (state) { 474 switch (state) {
475 case BufferedResourceLoader::kLoading: 475 case BufferedResourceLoader::kLoading:
476 is_downloading_data = true; 476 is_downloading_data = true;
477 break; 477 break;
478 case BufferedResourceLoader::kLoadingDeferred: 478 case BufferedResourceLoader::kLoadingDeferred:
479 case BufferedResourceLoader::kLoadingFinished: 479 case BufferedResourceLoader::kLoadingFinished:
480 is_downloading_data = false; 480 is_downloading_data = false;
481 break; 481 break;
482 482
483 // TODO(scherkus): we don't signal network activity changes when loads 483 // TODO(scherkus): we don't signal network activity changes when loads
484 // fail to preserve existing behaviour when deferring is toggled, however 484 // fail to preserve existing behaviour when deferring is toggled, however
485 // we should consider changing DownloadingCB to also propagate loading 485 // we should consider changing DownloadingCB to also propagate loading
486 // state. For example there isn't any signal today to notify the client that 486 // state. For example there isn't any signal today to notify the client that
487 // loading has failed (we only get errors on subsequent reads). 487 // loading has failed (we only get errors on subsequent reads).
488 case BufferedResourceLoader::kLoadingFailed: 488 case BufferedResourceLoader::kLoadingFailed:
489 return; 489 return;
490 } 490 }
491 491
492 downloading_cb_.Run(is_downloading_data); 492 downloading_cb_.Run(is_downloading_data);
493 } 493 }
494 494
495 void BufferedDataSource::ProgressCallback(int64 position) { 495 void BufferedDataSource::ProgressCallback(int64 position) {
496 DCHECK(MessageLoop::current() == render_loop_); 496 DCHECK(render_loop_->BelongsToCurrentThread());
497 497
498 if (assume_fully_buffered_) 498 if (assume_fully_buffered_)
499 return; 499 return;
500 500
501 // TODO(scherkus): we shouldn't have to lock to signal host(), see 501 // TODO(scherkus): we shouldn't have to lock to signal host(), see
502 // http://crbug.com/113712 for details. 502 // http://crbug.com/113712 for details.
503 base::AutoLock auto_lock(lock_); 503 base::AutoLock auto_lock(lock_);
504 if (stop_signal_received_) 504 if (stop_signal_received_)
505 return; 505 return;
506 506
(...skipping 22 matching lines...) Expand all
529 if (total_bytes_ == kPositionNotSpecified) 529 if (total_bytes_ == kPositionNotSpecified)
530 return; 530 return;
531 531
532 host()->SetTotalBytes(total_bytes_); 532 host()->SetTotalBytes(total_bytes_);
533 533
534 if (assume_fully_buffered_) 534 if (assume_fully_buffered_)
535 host()->AddBufferedByteRange(0, total_bytes_); 535 host()->AddBufferedByteRange(0, total_bytes_);
536 } 536 }
537 537
538 } // namespace webkit_media 538 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/buffered_data_source.h ('k') | webkit/media/buffered_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698