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

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

Issue 2910553002: fully cache small audio/video (Closed)
Patch Set: tests fixed and added Created 3 years, 7 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
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 UpdateBufferSizes();
509
508 // Even if data is cached, say that we're loading at this point for 510 // Even if data is cached, say that we're loading at this point for
509 // compatibility. 511 // compatibility.
510 UpdateLoadingState_Locked(true); 512 UpdateLoadingState_Locked(true);
511 } 513 }
512 514
513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { 515 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; 516 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")";
515 DCHECK(render_task_runner_->BelongsToCurrentThread()); 517 DCHECK(render_task_runner_->BelongsToCurrentThread());
516 518
517 if (assume_fully_buffered()) 519 if (assume_fully_buffered())
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 int64_t pin_forward = std::max(preload_high, kDefaultPinSize); 605 int64_t pin_forward = std::max(preload_high, kDefaultPinSize);
604 606
605 // Note that the buffer size is advisory as only non-pinned data is allowed 607 // Note that the buffer size is advisory as only non-pinned data is allowed
606 // to be thrown away. Most of the time we pin a region that is larger than 608 // to be thrown away. Most of the time we pin a region that is larger than
607 // |buffer_size|, which only makes sense because most of the time, some of 609 // |buffer_size|, which only makes sense because most of the time, some of
608 // the data in pinned region is not present in the cache. 610 // the data in pinned region is not present in the cache.
609 int64_t buffer_size = 611 int64_t buffer_size =
610 std::min((kTargetSecondsBufferedAhead + kTargetSecondsBufferedBehind) * 612 std::min((kTargetSecondsBufferedAhead + kTargetSecondsBufferedBehind) *
611 bytes_per_second, 613 bytes_per_second,
612 preload_high + pin_backward); 614 preload_high + pin_backward);
615
616 if (url_data_->FullyCached() ||
617 (url_data_->length() != kPositionNotSpecified &&
618 url_data_->length() < kDefaultPinSize)) {
619 pin_forward = url_data_->length() * 2;
DaleCurtis 2017/05/26 16:43:57 Why x2?
hubbe 2017/05/26 17:39:45 I just wanted to avoid any problems at the edges.
DaleCurtis 2017/05/26 18:19:33 Okay, please add a comment to that effect since it
hubbe 2017/05/26 18:45:12 Done.
620 pin_backward = url_data_->length() * 2;
621 buffer_size = url_data_->length();
622 }
623
613 reader_->SetMaxBuffer(buffer_size); 624 reader_->SetMaxBuffer(buffer_size);
614 reader_->SetPinRange(pin_backward, pin_forward); 625 reader_->SetPinRange(pin_backward, pin_forward);
615 626
616 if (preload_ == METADATA) { 627 if (preload_ == METADATA) {
617 reader_->SetPreload(0, 0); 628 reader_->SetPreload(0, 0);
618 } else { 629 } else {
619 reader_->SetPreload(preload_high, preload); 630 reader_->SetPreload(preload_high, preload);
620 } 631 }
621 } 632 }
622 633
623 } // namespace media 634 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | media/blink/url_index.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698