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

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

Issue 10700125: Fold RestartLoadingTask() into ReadCallback() as the method is called on the render thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase tot Created 8 years, 5 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_resource_loader.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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "media/base/media_log.h" 9 #include "media/base/media_log.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 // We just need to stop the loader, so it stops activity. 248 // We just need to stop the loader, so it stops activity.
249 if (loader_.get()) 249 if (loader_.get())
250 loader_->Stop(); 250 loader_->Stop();
251 251
252 // Reset the parameters of the current read request. 252 // Reset the parameters of the current read request.
253 read_size_ = 0; 253 read_size_ = 0;
254 read_buffer_ = 0; 254 read_buffer_ = 0;
255 } 255 }
256 256
257 void BufferedDataSource::RestartLoadingTask() {
258 DCHECK(MessageLoop::current() == render_loop_);
259 if (stopped_on_render_loop_)
260 return;
261
262 {
263 // If there's no outstanding read then return early.
264 base::AutoLock auto_lock(lock_);
265 if (read_cb_.is_null())
266 return;
267 }
268
269 // Start reading from where we last left off until the end of the resource.
270 loader_.reset(CreateResourceLoader(last_read_start_, kPositionNotSpecified));
271 loader_->Start(
272 base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
273 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, this),
274 base::Bind(&BufferedDataSource::ProgressCallback, this),
275 frame_);
276 }
277
278 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) { 257 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) {
279 DCHECK(MessageLoop::current() == render_loop_); 258 DCHECK(MessageLoop::current() == render_loop_);
280 DCHECK(loader_.get()); 259 DCHECK(loader_.get());
281 260
282 if (playback_rate != 0) 261 if (playback_rate != 0)
283 media_has_played_ = true; 262 media_has_played_ = true;
284 263
285 playback_rate_ = playback_rate; 264 playback_rate_ = playback_rate;
286 loader_->SetPlaybackRate(playback_rate); 265 loader_->SetPlaybackRate(playback_rate);
287 266
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 int bytes_read) { 409 int bytes_read) {
431 DCHECK(MessageLoop::current() == render_loop_); 410 DCHECK(MessageLoop::current() == render_loop_);
432 411
433 if (status != BufferedResourceLoader::kOk) { 412 if (status != BufferedResourceLoader::kOk) {
434 // Stop the resource load if it failed. 413 // Stop the resource load if it failed.
435 loader_->Stop(); 414 loader_->Stop();
436 415
437 if (status == BufferedResourceLoader::kCacheMiss && 416 if (status == BufferedResourceLoader::kCacheMiss &&
438 cache_miss_retries_left_ > 0) { 417 cache_miss_retries_left_ > 0) {
439 cache_miss_retries_left_--; 418 cache_miss_retries_left_--;
440 render_loop_->PostTask(FROM_HERE, 419
441 base::Bind(&BufferedDataSource::RestartLoadingTask, this)); 420 // Recreate a loader starting from where we last left off until the
421 // end of the resource.
422 loader_.reset(CreateResourceLoader(
423 last_read_start_, kPositionNotSpecified));
424 loader_->Start(
425 base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
426 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, this),
427 base::Bind(&BufferedDataSource::ProgressCallback, this),
428 frame_);
442 return; 429 return;
443 } 430 }
444 431
445 // Fall through to signal a read error. 432 // Fall through to signal a read error.
446 bytes_read = kReadError; 433 bytes_read = kReadError;
447 } 434 }
448 435
449 // TODO(scherkus): we shouldn't have to lock to signal host(), see 436 // TODO(scherkus): we shouldn't have to lock to signal host(), see
450 // http://crbug.com/113712 for details. 437 // http://crbug.com/113712 for details.
451 base::AutoLock auto_lock(lock_); 438 base::AutoLock auto_lock(lock_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if (total_bytes_ == kPositionNotSpecified) 511 if (total_bytes_ == kPositionNotSpecified)
525 return; 512 return;
526 513
527 host()->SetTotalBytes(total_bytes_); 514 host()->SetTotalBytes(total_bytes_);
528 515
529 if (assume_fully_buffered_) 516 if (assume_fully_buffered_)
530 host()->AddBufferedByteRange(0, total_bytes_); 517 host()->AddBufferedByteRange(0, total_bytes_);
531 } 518 }
532 519
533 } // namespace webkit_media 520 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/buffered_data_source.h ('k') | webkit/media/buffered_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698