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

Side by Side Diff: media/blink/multibuffer_data_source.cc

Issue 2357773003: Fix a timing bug in multibuffer. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | media/blink/multibuffer_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/blink/multibuffer_data_source.h" 5 #include "media/blink/multibuffer_data_source.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 UpdateLoadingState(true); 510 UpdateLoadingState(true);
511 } 511 }
512 512
513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { 513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; 514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")";
515 DCHECK(render_task_runner_->BelongsToCurrentThread()); 515 DCHECK(render_task_runner_->BelongsToCurrentThread());
516 516
517 if (assume_fully_buffered()) 517 if (assume_fully_buffered())
518 return; 518 return;
519 519
520 base::AutoLock auto_lock(lock_);
521
520 if (end > begin) { 522 if (end > begin) {
521 // TODO(scherkus): we shouldn't have to lock to signal host(), see 523 // TODO(scherkus): we shouldn't have to lock to signal host(), see
522 // http://crbug.com/113712 for details. 524 // http://crbug.com/113712 for details.
523 base::AutoLock auto_lock(lock_);
524 if (stop_signal_received_) 525 if (stop_signal_received_)
525 return; 526 return;
526 527
527 host_->AddBufferedByteRange(begin, end); 528 host_->AddBufferedByteRange(begin, end);
528 } 529 }
529 530
530 UpdateLoadingState(false); 531 UpdateLoadingState(false);
531 } 532 }
532 533
533 void MultibufferDataSource::UpdateLoadingState(bool force_loading) { 534 void MultibufferDataSource::UpdateLoadingState(bool force_loading) {
sandersd (OOO until July 31) 2016/09/21 01:13:39 Nit: Add _Locked suffix?
hubbe 2016/09/21 04:19:22 Done
534 DVLOG(1) << __func__; 535 DVLOG(1) << __func__;
536 lock_.AssertAcquired();
535 if (assume_fully_buffered()) 537 if (assume_fully_buffered())
536 return; 538 return;
537 // Update loading state. 539 // Update loading state.
538 bool is_loading = !!reader_ && reader_->IsLoading(); 540 bool is_loading = !!reader_ && reader_->IsLoading();
541 if (read_op_)
542 is_loading = true;
sandersd (OOO until July 31) 2016/09/21 01:13:39 This means nothing to me, but I'll believe you.
hubbe 2016/09/21 04:19:22 Well, basically we can't destroy reader_ if there
539 if (force_loading || is_loading != loading_) { 543 if (force_loading || is_loading != loading_) {
540 loading_ = is_loading || force_loading; 544 loading_ = is_loading || force_loading;
541 545
542 if (!loading_ && cancel_on_defer_) { 546 if (!loading_ && cancel_on_defer_) {
543 reader_.reset(nullptr); 547 reader_.reset(nullptr);
544 } 548 }
545 549
546 // Callback could kill us, be sure to call it last. 550 // Callback could kill us, be sure to call it last.
547 downloading_cb_.Run(loading_); 551 downloading_cb_.Run(loading_);
548 } 552 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); 601 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra);
598 602
599 if (preload_ == METADATA) { 603 if (preload_ == METADATA) {
600 reader_->SetPreload(0, 0); 604 reader_->SetPreload(0, 0);
601 } else { 605 } else {
602 reader_->SetPreload(preload_high, preload); 606 reader_->SetPreload(preload_high, preload);
603 } 607 }
604 } 608 }
605 609
606 } // namespace media 610 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698