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

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: 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // We just need to stop the loader, so it stops activity. 234 // We just need to stop the loader, so it stops activity.
235 if (loader_.get()) 235 if (loader_.get())
236 loader_->Stop(); 236 loader_->Stop();
237 237
238 // Reset the parameters of the current read request. 238 // Reset the parameters of the current read request.
239 read_size_ = 0; 239 read_size_ = 0;
240 read_buffer_ = 0; 240 read_buffer_ = 0;
241 } 241 }
242 242
243 void BufferedDataSource::RestartLoadingTask() {
244 DCHECK(MessageLoop::current() == render_loop_);
245 if (stopped_on_render_loop_)
246 return;
247
248 {
249 // If there's no outstanding read then return early.
250 base::AutoLock auto_lock(lock_);
251 if (read_cb_.is_null())
252 return;
253 }
254
255 // Start reading from where we last left off until the end of the resource.
256 loader_.reset(CreateResourceLoader(last_read_start_, kPositionNotSpecified));
257 loader_->Start(
258 base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
259 base::Bind(&BufferedDataSource::LoadingCallback, this),
260 base::Bind(&BufferedDataSource::ProgressCallback, this),
261 frame_);
262 }
263
264 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) { 243 void BufferedDataSource::SetPlaybackRateTask(float playback_rate) {
265 DCHECK(MessageLoop::current() == render_loop_); 244 DCHECK(MessageLoop::current() == render_loop_);
266 DCHECK(loader_.get()); 245 DCHECK(loader_.get());
267 246
268 if (playback_rate != 0) 247 if (playback_rate != 0)
269 media_has_played_ = true; 248 media_has_played_ = true;
270 249
271 playback_rate_ = playback_rate; 250 playback_rate_ = playback_rate;
272 loader_->SetPlaybackRate(playback_rate); 251 loader_->SetPlaybackRate(playback_rate);
273 252
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 int bytes_read) { 405 int bytes_read) {
427 DCHECK(MessageLoop::current() == render_loop_); 406 DCHECK(MessageLoop::current() == render_loop_);
428 407
429 if (status != BufferedResourceLoader::kOk) { 408 if (status != BufferedResourceLoader::kOk) {
430 // Stop the resource load if it failed. 409 // Stop the resource load if it failed.
431 loader_->Stop(); 410 loader_->Stop();
432 411
433 if (status == BufferedResourceLoader::kCacheMiss && 412 if (status == BufferedResourceLoader::kCacheMiss &&
434 cache_miss_retries_left_ > 0) { 413 cache_miss_retries_left_ > 0) {
435 cache_miss_retries_left_--; 414 cache_miss_retries_left_--;
436 render_loop_->PostTask(FROM_HERE, 415
437 base::Bind(&BufferedDataSource::RestartLoadingTask, this)); 416 // Recreate a loader starting from where we last left off until the
Ami GONE FROM CHROMIUM 2012/07/10 02:48:25 Why is it no longer necessary to test stopped_on_r
scherkus (not reviewing) 2012/07/10 03:15:16 Previously the only way that could happen is if Cl
417 // end of the resource.
418 loader_.reset(CreateResourceLoader(
419 last_read_start_, kPositionNotSpecified));
420 loader_->Start(
421 base::Bind(&BufferedDataSource::PartialReadStartCallback, this),
422 base::Bind(&BufferedDataSource::LoadingCallback, this),
423 base::Bind(&BufferedDataSource::ProgressCallback, this),
424 frame_);
438 return; 425 return;
439 } 426 }
440 427
441 // Fall through to signal a read error. 428 // Fall through to signal a read error.
442 bytes_read = kReadError; 429 bytes_read = kReadError;
443 } 430 }
444 431
445 // TODO(scherkus): we shouldn't have to lock to signal host(), see 432 // TODO(scherkus): we shouldn't have to lock to signal host(), see
446 // http://crbug.com/113712 for details. 433 // http://crbug.com/113712 for details.
447 base::AutoLock auto_lock(lock_); 434 base::AutoLock auto_lock(lock_);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if (!host()) 515 if (!host())
529 return; 516 return;
530 517
531 if (total_bytes_ != kPositionNotSpecified) 518 if (total_bytes_ != kPositionNotSpecified)
532 host()->SetTotalBytes(total_bytes_); 519 host()->SetTotalBytes(total_bytes_);
533 if (buffered_bytes_ > last_read_start_) 520 if (buffered_bytes_ > last_read_start_)
534 host()->AddBufferedByteRange(last_read_start_, buffered_bytes_); 521 host()->AddBufferedByteRange(last_read_start_, buffered_bytes_);
535 } 522 }
536 523
537 } // namespace webkit_media 524 } // 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