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

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

Issue 2437273002: fix multibuffer "is loading" (Closed)
Patch Set: Created 4 years, 2 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 | « media/blink/multibuffer_data_source.h ('k') | no next file » | 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 media_log_->SetBooleanProperty("single_origin", single_origin_); 498 media_log_->SetBooleanProperty("single_origin", single_origin_);
499 media_log_->SetBooleanProperty("passed_cors_access_check", 499 media_log_->SetBooleanProperty("passed_cors_access_check",
500 DidPassCORSAccessCheck()); 500 DidPassCORSAccessCheck());
501 media_log_->SetBooleanProperty("range_header_supported", 501 media_log_->SetBooleanProperty("range_header_supported",
502 url_data_->range_supported()); 502 url_data_->range_supported());
503 } 503 }
504 504
505 render_task_runner_->PostTask( 505 render_task_runner_->PostTask(
506 FROM_HERE, base::Bind(base::ResetAndReturn(&init_cb_), success)); 506 FROM_HERE, base::Bind(base::ResetAndReturn(&init_cb_), success));
507 507
508 // When we tell our clients that we're loading below, it's possible that
509 // the entire file is already cashed. If that's true, then we won't get
510 // any progress callbacks later, so we'll never tell the client that we
511 // stopped loading. Post a task to make sure that we check the loading
512 // state at least once.
513 render_task_runner_->PostTask(
514 FROM_HERE, base::Bind(&MultibufferDataSource::UpdateLoadingState,
515 weak_factory_.GetWeakPtr()));
508 // Even if data is cached, say that we're loading at this point for 516 // Even if data is cached, say that we're loading at this point for
509 // compatibility. 517 // compatibility.
510 UpdateLoadingState_Locked(true); 518 UpdateLoadingState_Locked(true);
511 } 519 }
512 520
513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { 521 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; 522 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")";
515 DCHECK(render_task_runner_->BelongsToCurrentThread()); 523 DCHECK(render_task_runner_->BelongsToCurrentThread());
516 524
517 if (assume_fully_buffered()) 525 if (assume_fully_buffered())
(...skipping 27 matching lines...) Expand all
545 553
546 if (!loading_ && cancel_on_defer_) { 554 if (!loading_ && cancel_on_defer_) {
547 reader_.reset(nullptr); 555 reader_.reset(nullptr);
548 } 556 }
549 557
550 // Callback could kill us, be sure to call it last. 558 // Callback could kill us, be sure to call it last.
551 downloading_cb_.Run(loading_); 559 downloading_cb_.Run(loading_);
552 } 560 }
553 } 561 }
554 562
563 void MultibufferDataSource::UpdateLoadingState() {
564 DCHECK(render_task_runner_->BelongsToCurrentThread());
565 base::AutoLock auto_lock(lock_);
566 UpdateLoadingState_Locked(false);
567 }
568
555 void MultibufferDataSource::UpdateBufferSizes() { 569 void MultibufferDataSource::UpdateBufferSizes() {
556 DVLOG(1) << __func__; 570 DVLOG(1) << __func__;
557 if (!reader_) 571 if (!reader_)
558 return; 572 return;
559 573
560 if (!assume_fully_buffered()) { 574 if (!assume_fully_buffered()) {
561 // If the playback has started and the strategy is aggressive, then try to 575 // If the playback has started and the strategy is aggressive, then try to
562 // load as much as possible, assuming that the file is cacheable. (If not, 576 // load as much as possible, assuming that the file is cacheable. (If not,
563 // why bother?) 577 // why bother?)
564 bool aggressive = (buffering_strategy_ == BUFFERING_STRATEGY_AGGRESSIVE); 578 bool aggressive = (buffering_strategy_ == BUFFERING_STRATEGY_AGGRESSIVE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); 615 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra);
602 616
603 if (preload_ == METADATA) { 617 if (preload_ == METADATA) {
604 reader_->SetPreload(0, 0); 618 reader_->SetPreload(0, 0);
605 } else { 619 } else {
606 reader_->SetPreload(preload_high, preload); 620 reader_->SetPreload(preload_high, preload);
607 } 621 }
608 } 622 }
609 623
610 } // namespace media 624 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698