0

Use the correct case for MultiBuffer

Rename MultibufferDataSource and ResourceMultibufferDataProvider to use
an uppercase B in Buffer.

This is a precursor CL before moving media/blink/ to Blink, to ease the
review when renaming the files for these classes to
multi_buffer_data_source.* and resource_multi_buffer_data_provider.*.

Bug: 1198341
Change-Id: Ib4db5b10903fa62f9a5c094cba4ef84126dd55c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2910195
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: Will Cassella <cassew@google.com>
Reviewed-by: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#886684}
This commit is contained in:
Henrique Ferreiro
2021-05-26 12:04:23 +00:00
committed by Chromium LUCI CQ
parent 14754d54e0
commit 09cf3addfb
10 changed files with 201 additions and 201 deletions

@@ -132,7 +132,7 @@ class MEDIA_BLINK_EXPORT MultiBuffer {
virtual void SetDeferred(bool deferred) = 0; virtual void SetDeferred(bool deferred) = 0;
}; };
// Multibuffers use a global shared LRU to free memory. // MultiBuffers use a global shared LRU to free memory.
// This effectively means that recently used multibuffers can // This effectively means that recently used multibuffers can
// borrow memory from less recently used ones. // borrow memory from less recently used ones.
class MEDIA_BLINK_EXPORT GlobalLRU : public base::RefCounted<GlobalLRU> { class MEDIA_BLINK_EXPORT GlobalLRU : public base::RefCounted<GlobalLRU> {

@@ -64,7 +64,7 @@ constexpr base::TimeDelta kSeekDelay = base::TimeDelta::FromMilliseconds(20);
namespace media { namespace media {
class MultibufferDataSource::ReadOperation { class MultiBufferDataSource::ReadOperation {
public: public:
ReadOperation(int64_t position, ReadOperation(int64_t position,
int size, int size,
@@ -89,7 +89,7 @@ class MultibufferDataSource::ReadOperation {
DISALLOW_IMPLICIT_CONSTRUCTORS(ReadOperation); DISALLOW_IMPLICIT_CONSTRUCTORS(ReadOperation);
}; };
MultibufferDataSource::ReadOperation::ReadOperation(int64_t position, MultiBufferDataSource::ReadOperation::ReadOperation(int64_t position,
int size, int size,
uint8_t* data, uint8_t* data,
DataSource::ReadCB callback) DataSource::ReadCB callback)
@@ -100,18 +100,18 @@ MultibufferDataSource::ReadOperation::ReadOperation(int64_t position,
DCHECK(!callback_.is_null()); DCHECK(!callback_.is_null());
} }
MultibufferDataSource::ReadOperation::~ReadOperation() { MultiBufferDataSource::ReadOperation::~ReadOperation() {
DCHECK(callback_.is_null()); DCHECK(callback_.is_null());
} }
// static // static
void MultibufferDataSource::ReadOperation::Run( void MultiBufferDataSource::ReadOperation::Run(
std::unique_ptr<ReadOperation> read_op, std::unique_ptr<ReadOperation> read_op,
int result) { int result) {
std::move(read_op->callback_).Run(result); std::move(read_op->callback_).Run(result);
} }
MultibufferDataSource::MultibufferDataSource( MultiBufferDataSource::MultiBufferDataSource(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_refptr<UrlData> url_data_arg, scoped_refptr<UrlData> url_data_arg,
MediaLog* media_log, MediaLog* media_log,
@@ -140,41 +140,41 @@ MultibufferDataSource::MultibufferDataSource(
DCHECK(url_data_.get()); DCHECK(url_data_.get());
url_data_->Use(); url_data_->Use();
url_data_->OnRedirect( url_data_->OnRedirect(
base::BindOnce(&MultibufferDataSource::OnRedirected, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::OnRedirected, weak_ptr_));
} }
MultibufferDataSource::~MultibufferDataSource() { MultiBufferDataSource::~MultiBufferDataSource() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
} }
bool MultibufferDataSource::media_has_played() const { bool MultiBufferDataSource::media_has_played() const {
return media_has_played_; return media_has_played_;
} }
bool MultibufferDataSource::AssumeFullyBuffered() const { bool MultiBufferDataSource::AssumeFullyBuffered() const {
DCHECK(url_data_); DCHECK(url_data_);
return !url_data_->url().SchemeIsHTTPOrHTTPS(); return !url_data_->url().SchemeIsHTTPOrHTTPS();
} }
void MultibufferDataSource::SetReader(MultiBufferReader* reader) { void MultiBufferDataSource::SetReader(MultiBufferReader* reader) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
reader_.reset(reader); reader_.reset(reader);
} }
void MultibufferDataSource::CreateResourceLoader(int64_t first_byte_position, void MultiBufferDataSource::CreateResourceLoader(int64_t first_byte_position,
int64_t last_byte_position) { int64_t last_byte_position) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
SetReader(new MultiBufferReader( SetReader(new MultiBufferReader(
url_data_->multibuffer(), first_byte_position, last_byte_position, url_data_->multibuffer(), first_byte_position, last_byte_position,
base::BindRepeating(&MultibufferDataSource::ProgressCallback, weak_ptr_), base::BindRepeating(&MultiBufferDataSource::ProgressCallback, weak_ptr_),
render_task_runner_)); render_task_runner_));
reader_->SetIsClientAudioElement(is_client_audio_element_); reader_->SetIsClientAudioElement(is_client_audio_element_);
UpdateBufferSizes(); UpdateBufferSizes();
} }
void MultibufferDataSource::CreateResourceLoader_Locked( void MultiBufferDataSource::CreateResourceLoader_Locked(
int64_t first_byte_position, int64_t first_byte_position,
int64_t last_byte_position) { int64_t last_byte_position) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
@@ -182,12 +182,12 @@ void MultibufferDataSource::CreateResourceLoader_Locked(
reader_ = std::make_unique<MultiBufferReader>( reader_ = std::make_unique<MultiBufferReader>(
url_data_->multibuffer(), first_byte_position, last_byte_position, url_data_->multibuffer(), first_byte_position, last_byte_position,
base::BindRepeating(&MultibufferDataSource::ProgressCallback, weak_ptr_), base::BindRepeating(&MultiBufferDataSource::ProgressCallback, weak_ptr_),
render_task_runner_); render_task_runner_);
UpdateBufferSizes(); UpdateBufferSizes();
} }
void MultibufferDataSource::Initialize(InitializeCB init_cb) { void MultiBufferDataSource::Initialize(InitializeCB init_cb) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
DCHECK(init_cb); DCHECK(init_cb);
DCHECK(!reader_.get()); DCHECK(!reader_.get());
@@ -200,22 +200,22 @@ void MultibufferDataSource::Initialize(InitializeCB init_cb) {
if (reader_->Available()) { if (reader_->Available()) {
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::StartCallback, weak_ptr_));
// When the entire file is already in the cache, we won't get any more // When the entire file is already in the cache, we won't get any more
// progress callbacks, which breaks some expectations. Post a task to // progress callbacks, which breaks some expectations. Post a task to
// make sure that the client gets at least one call each for the progress // make sure that the client gets at least one call each for the progress
// and loading callbacks. // and loading callbacks.
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&MultibufferDataSource::UpdateProgress, FROM_HERE, base::BindOnce(&MultiBufferDataSource::UpdateProgress,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} else { } else {
reader_->Wait( reader_->Wait(
1, base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_)); 1, base::BindOnce(&MultiBufferDataSource::StartCallback, weak_ptr_));
} }
} }
void MultibufferDataSource::OnRedirected( void MultiBufferDataSource::OnRedirected(
const scoped_refptr<UrlData>& new_destination) { const scoped_refptr<UrlData>& new_destination) {
if (!new_destination) { if (!new_destination) {
// A failure occurred. // A failure occurred.
@@ -223,7 +223,7 @@ void MultibufferDataSource::OnRedirected(
if (init_cb_) { if (init_cb_) {
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::StartCallback, weak_ptr_));
} else { } else {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
StopInternal_Locked(); StopInternal_Locked();
@@ -238,27 +238,27 @@ void MultibufferDataSource::OnRedirected(
url_data_ = std::move(new_destination); url_data_ = std::move(new_destination);
url_data_->OnRedirect( url_data_->OnRedirect(
base::BindOnce(&MultibufferDataSource::OnRedirected, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::OnRedirected, weak_ptr_));
if (init_cb_) { if (init_cb_) {
CreateResourceLoader(0, kPositionNotSpecified); CreateResourceLoader(0, kPositionNotSpecified);
if (reader_->Available()) { if (reader_->Available()) {
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::StartCallback, weak_ptr_));
} else { } else {
reader_->Wait( reader_->Wait(
1, base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_)); 1, base::BindOnce(&MultiBufferDataSource::StartCallback, weak_ptr_));
} }
} else if (read_op_) { } else if (read_op_) {
CreateResourceLoader(read_op_->position(), kPositionNotSpecified); CreateResourceLoader(read_op_->position(), kPositionNotSpecified);
if (reader_->Available()) { if (reader_->Available()) {
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MultibufferDataSource::ReadTask, weak_ptr_)); base::BindOnce(&MultiBufferDataSource::ReadTask, weak_ptr_));
} else { } else {
reader_->Wait( reader_->Wait(
1, base::BindOnce(&MultibufferDataSource::ReadTask, weak_ptr_)); 1, base::BindOnce(&MultiBufferDataSource::ReadTask, weak_ptr_));
} }
} }
@@ -266,37 +266,37 @@ void MultibufferDataSource::OnRedirected(
redirect_cb_.Run(); redirect_cb_.Run();
} }
void MultibufferDataSource::SetPreload(Preload preload) { void MultiBufferDataSource::SetPreload(Preload preload) {
DVLOG(1) << __func__ << "(" << preload << ")"; DVLOG(1) << __func__ << "(" << preload << ")";
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
preload_ = preload; preload_ = preload;
UpdateBufferSizes(); UpdateBufferSizes();
} }
bool MultibufferDataSource::HasSingleOrigin() { bool MultiBufferDataSource::HasSingleOrigin() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
// Before initialization completes there is no risk of leaking data. Callers // Before initialization completes there is no risk of leaking data. Callers
// are required to order checks such that this isn't a race. // are required to order checks such that this isn't a race.
return single_origin_; return single_origin_;
} }
bool MultibufferDataSource::IsCorsCrossOrigin() const { bool MultiBufferDataSource::IsCorsCrossOrigin() const {
return url_data_->is_cors_cross_origin(); return url_data_->is_cors_cross_origin();
} }
void MultibufferDataSource::OnRedirect(RedirectCB callback) { void MultiBufferDataSource::OnRedirect(RedirectCB callback) {
redirect_cb_ = std::move(callback); redirect_cb_ = std::move(callback);
} }
bool MultibufferDataSource::HasAccessControl() const { bool MultiBufferDataSource::HasAccessControl() const {
return url_data_->has_access_control(); return url_data_->has_access_control();
} }
UrlData::CorsMode MultibufferDataSource::cors_mode() const { UrlData::CorsMode MultiBufferDataSource::cors_mode() const {
return url_data_->cors_mode(); return url_data_->cors_mode();
} }
void MultibufferDataSource::MediaPlaybackRateChanged(double playback_rate) { void MultiBufferDataSource::MediaPlaybackRateChanged(double playback_rate) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
if (playback_rate < 0 || playback_rate == playback_rate_) if (playback_rate < 0 || playback_rate == playback_rate_)
return; return;
@@ -306,7 +306,7 @@ void MultibufferDataSource::MediaPlaybackRateChanged(double playback_rate) {
UpdateBufferSizes(); UpdateBufferSizes();
} }
void MultibufferDataSource::MediaIsPlaying() { void MultiBufferDataSource::MediaIsPlaying() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
// Always clear this since it can be set by OnBufferingHaveEnough() calls at // Always clear this since it can be set by OnBufferingHaveEnough() calls at
@@ -325,7 +325,7 @@ void MultibufferDataSource::MediaIsPlaying() {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// DataSource implementation. // DataSource implementation.
void MultibufferDataSource::Stop() { void MultiBufferDataSource::Stop() {
{ {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
StopInternal_Locked(); StopInternal_Locked();
@@ -339,11 +339,11 @@ void MultibufferDataSource::Stop() {
} }
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&MultibufferDataSource::StopLoader, FROM_HERE, base::BindOnce(&MultiBufferDataSource::StopLoader,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void MultibufferDataSource::Abort() { void MultiBufferDataSource::Abort() {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
DCHECK(!init_cb_); DCHECK(!init_cb_);
if (read_op_) if (read_op_)
@@ -354,13 +354,13 @@ void MultibufferDataSource::Abort() {
// loader is necessary upon the seek or resume. // loader is necessary upon the seek or resume.
} }
void MultibufferDataSource::SetBitrate(int bitrate) { void MultiBufferDataSource::SetBitrate(int bitrate) {
render_task_runner_->PostTask( render_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&MultibufferDataSource::SetBitrateTask, FROM_HERE, base::BindOnce(&MultiBufferDataSource::SetBitrateTask,
weak_factory_.GetWeakPtr(), bitrate)); weak_factory_.GetWeakPtr(), bitrate));
} }
void MultibufferDataSource::OnBufferingHaveEnough(bool always_cancel) { void MultiBufferDataSource::OnBufferingHaveEnough(bool always_cancel) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
if (reader_ && (always_cancel || (preload_ == METADATA && if (reader_ && (always_cancel || (preload_ == METADATA &&
!media_has_played_ && !IsStreaming()))) { !media_has_played_ && !IsStreaming()))) {
@@ -379,17 +379,17 @@ void MultibufferDataSource::OnBufferingHaveEnough(bool always_cancel) {
} }
} }
int64_t MultibufferDataSource::GetMemoryUsage() { int64_t MultiBufferDataSource::GetMemoryUsage() {
// TODO(hubbe): Make more accurate when url_data_ is shared. // TODO(hubbe): Make more accurate when url_data_ is shared.
return base::checked_cast<int64_t>(url_data_->CachedSize()) return base::checked_cast<int64_t>(url_data_->CachedSize())
<< url_data_->multibuffer()->block_size_shift(); << url_data_->multibuffer()->block_size_shift();
} }
GURL MultibufferDataSource::GetUrlAfterRedirects() const { GURL MultiBufferDataSource::GetUrlAfterRedirects() const {
return url_data_->url(); return url_data_->url();
} }
void MultibufferDataSource::Read(int64_t position, void MultiBufferDataSource::Read(int64_t position,
int size, int size,
uint8_t* data, uint8_t* data,
DataSource::ReadCB read_cb) { DataSource::ReadCB read_cb) {
@@ -418,7 +418,7 @@ void MultibufferDataSource::Read(int64_t position,
if (seek_positions_.size() == 1) { if (seek_positions_.size() == 1) {
render_task_runner_->PostDelayedTask( render_task_runner_->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MultibufferDataSource::SeekTask, base::BindOnce(&MultiBufferDataSource::SeekTask,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
kSeekDelay); kSeekDelay);
} }
@@ -432,11 +432,11 @@ void MultibufferDataSource::Read(int64_t position,
} }
render_task_runner_->PostTask(FROM_HERE, render_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&MultibufferDataSource::ReadTask, base::BindOnce(&MultiBufferDataSource::ReadTask,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
bool MultibufferDataSource::GetSize(int64_t* size_out) { bool MultiBufferDataSource::GetSize(int64_t* size_out) {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
if (total_bytes_ != kPositionNotSpecified) { if (total_bytes_ != kPositionNotSpecified) {
*size_out = total_bytes_; *size_out = total_bytes_;
@@ -446,13 +446,13 @@ bool MultibufferDataSource::GetSize(int64_t* size_out) {
return false; return false;
} }
bool MultibufferDataSource::IsStreaming() { bool MultiBufferDataSource::IsStreaming() {
return streaming_; return streaming_;
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// This method is the place where actual read happens, // This method is the place where actual read happens,
void MultibufferDataSource::ReadTask() { void MultiBufferDataSource::ReadTask() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
@@ -493,19 +493,19 @@ void MultibufferDataSource::ReadTask() {
SeekTask_Locked(); SeekTask_Locked();
} else { } else {
reader_->Seek(read_op_->position()); reader_->Seek(read_op_->position());
reader_->Wait(1, base::BindOnce(&MultibufferDataSource::ReadTask, reader_->Wait(1, base::BindOnce(&MultiBufferDataSource::ReadTask,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
UpdateLoadingState_Locked(false); UpdateLoadingState_Locked(false);
} }
} }
void MultibufferDataSource::SeekTask() { void MultiBufferDataSource::SeekTask() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
SeekTask_Locked(); SeekTask_Locked();
} }
void MultibufferDataSource::SeekTask_Locked() { void MultiBufferDataSource::SeekTask_Locked() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
lock_.AssertAcquired(); lock_.AssertAcquired();
@@ -554,7 +554,7 @@ void MultibufferDataSource::SeekTask_Locked() {
UpdateLoadingState_Locked(false); UpdateLoadingState_Locked(false);
} }
void MultibufferDataSource::StopInternal_Locked() { void MultiBufferDataSource::StopInternal_Locked() {
lock_.AssertAcquired(); lock_.AssertAcquired();
if (stop_signal_received_) if (stop_signal_received_)
return; return;
@@ -569,12 +569,12 @@ void MultibufferDataSource::StopInternal_Locked() {
ReadOperation::Run(std::move(read_op_), kReadError); ReadOperation::Run(std::move(read_op_), kReadError);
} }
void MultibufferDataSource::StopLoader() { void MultiBufferDataSource::StopLoader() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
SetReader(nullptr); SetReader(nullptr);
} }
void MultibufferDataSource::SetBitrateTask(int bitrate) { void MultiBufferDataSource::SetBitrateTask(int bitrate) {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
bitrate_ = bitrate; bitrate_ = bitrate;
@@ -583,7 +583,7 @@ void MultibufferDataSource::SetBitrateTask(int bitrate) {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BufferedResourceLoader callback methods. // BufferedResourceLoader callback methods.
void MultibufferDataSource::StartCallback() { void MultiBufferDataSource::StartCallback() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
if (!init_cb_) { if (!init_cb_) {
@@ -642,7 +642,7 @@ void MultibufferDataSource::StartCallback() {
UpdateLoadingState_Locked(true); UpdateLoadingState_Locked(true);
} }
void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { void MultiBufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; DVLOG(1) << __func__ << "(" << begin << ", " << end << ")";
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
@@ -664,7 +664,7 @@ void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
UpdateLoadingState_Locked(false); UpdateLoadingState_Locked(false);
} }
void MultibufferDataSource::UpdateLoadingState_Locked(bool force_loading) { void MultiBufferDataSource::UpdateLoadingState_Locked(bool force_loading) {
DVLOG(1) << __func__; DVLOG(1) << __func__;
lock_.AssertAcquired(); lock_.AssertAcquired();
if (AssumeFullyBuffered()) if (AssumeFullyBuffered())
@@ -690,7 +690,7 @@ void MultibufferDataSource::UpdateLoadingState_Locked(bool force_loading) {
} }
} }
void MultibufferDataSource::UpdateProgress() { void MultiBufferDataSource::UpdateProgress() {
DCHECK(render_task_runner_->BelongsToCurrentThread()); DCHECK(render_task_runner_->BelongsToCurrentThread());
if (reader_) { if (reader_) {
uint64_t available = reader_->Available(); uint64_t available = reader_->Available();
@@ -699,7 +699,7 @@ void MultibufferDataSource::UpdateProgress() {
} }
} }
void MultibufferDataSource::UpdateBufferSizes() { void MultiBufferDataSource::UpdateBufferSizes() {
DVLOG(1) << __func__; DVLOG(1) << __func__;
if (!reader_) if (!reader_)
return; return;

@@ -35,9 +35,9 @@ class MultiBufferReader;
// A data source capable of loading URLs and buffering the data using an // A data source capable of loading URLs and buffering the data using an
// in-memory sliding window. // in-memory sliding window.
// //
// MultibufferDataSource must be created and destroyed on the thread associated // MultiBufferDataSource must be created and destroyed on the thread associated
// with the |task_runner| passed in the constructor. // with the |task_runner| passed in the constructor.
class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource { class MEDIA_BLINK_EXPORT MultiBufferDataSource : public DataSource {
public: public:
using DownloadingCB = base::RepeatingCallback<void(bool)>; using DownloadingCB = base::RepeatingCallback<void(bool)>;
using RedirectCB = base::RepeatingCallback<void()>; using RedirectCB = base::RepeatingCallback<void()>;
@@ -58,13 +58,13 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// |url| and |cors_mode| are passed to the object. Buffered byte range changes // |url| and |cors_mode| are passed to the object. Buffered byte range changes
// will be reported to |host|. |downloading_cb| will be called whenever the // will be reported to |host|. |downloading_cb| will be called whenever the
// downloading/paused state of the source changes. // downloading/paused state of the source changes.
MultibufferDataSource( MultiBufferDataSource(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_refptr<UrlData> url_data, scoped_refptr<UrlData> url_data,
MediaLog* media_log, MediaLog* media_log,
BufferedDataSourceHost* host, BufferedDataSourceHost* host,
DownloadingCB downloading_cb); DownloadingCB downloading_cb);
~MultibufferDataSource() override; ~MultiBufferDataSource() override;
// Executes |init_cb| with the result of initialization when it has completed. // Executes |init_cb| with the result of initialization when it has completed.
// //
@@ -148,7 +148,7 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// Set reader_ while asserting proper locking. // Set reader_ while asserting proper locking.
void SetReader(MultiBufferReader* reader); void SetReader(MultiBufferReader* reader);
friend class MultibufferDataSourceTest; friend class MultiBufferDataSourceTest;
// Task posted to perform actual reading on the render thread. // Task posted to perform actual reading on the render thread.
void ReadTask(); void ReadTask();
@@ -277,20 +277,20 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
DownloadingCB downloading_cb_; DownloadingCB downloading_cb_;
// Preload this many seconds of data by default. // Preload this many seconds of data by default.
media::Tuneable<int> preload_seconds_ = {"SrcMediaMultibufferPreloadSeconds", media::Tuneable<int> preload_seconds_ = {"SrcMediaMultiBufferPreloadSeconds",
0, 10, 60}; 0, 10, 60};
// Keep this many seconds of data for going back by default. // Keep this many seconds of data for going back by default.
media::Tuneable<int> keep_after_playback_seconds_ = { media::Tuneable<int> keep_after_playback_seconds_ = {
"SrcMediaMultibufferKeepAfterPlaybackSeconds", 0, 2, 60}; "SrcMediaMultiBufferKeepAfterPlaybackSeconds", 0, 2, 60};
// Disallow rebinding WeakReference ownership to a different thread by keeping // Disallow rebinding WeakReference ownership to a different thread by keeping
// a persistent reference. This avoids problems with the thread-safety of // a persistent reference. This avoids problems with the thread-safety of
// reaching into this class from multiple threads to attain a WeakPtr. // reaching into this class from multiple threads to attain a WeakPtr.
base::WeakPtr<MultibufferDataSource> weak_ptr_; base::WeakPtr<MultiBufferDataSource> weak_ptr_;
base::WeakPtrFactory<MultibufferDataSource> weak_factory_{this}; base::WeakPtrFactory<MultiBufferDataSource> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); DISALLOW_COPY_AND_ASSIGN(MultiBufferDataSource);
}; };
} // namespace media } // namespace media

@@ -202,18 +202,18 @@ class MockBufferedDataSourceHost : public BufferedDataSourceHost {
DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSourceHost); DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSourceHost);
}; };
class MockMultibufferDataSource : public MultibufferDataSource { class MockMultiBufferDataSource : public MultiBufferDataSource {
public: public:
MockMultibufferDataSource( MockMultiBufferDataSource(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
scoped_refptr<UrlData> url_data, scoped_refptr<UrlData> url_data,
BufferedDataSourceHost* host) BufferedDataSourceHost* host)
: MultibufferDataSource( : MultiBufferDataSource(
task_runner, task_runner,
std::move(url_data), std::move(url_data),
&media_log_, &media_log_,
host, host,
base::BindRepeating(&MockMultibufferDataSource::set_downloading, base::BindRepeating(&MockMultiBufferDataSource::set_downloading,
base::Unretained(this))), base::Unretained(this))),
downloading_(false) {} downloading_(false) {}
@@ -227,7 +227,7 @@ class MockMultibufferDataSource : public MultibufferDataSource {
bool downloading_; bool downloading_;
NullMediaLog media_log_; NullMediaLog media_log_;
DISALLOW_COPY_AND_ASSIGN(MockMultibufferDataSource); DISALLOW_COPY_AND_ASSIGN(MockMultiBufferDataSource);
}; };
static const int64_t kFileSize = 5000000; static const int64_t kFileSize = 5000000;
@@ -239,9 +239,9 @@ static const char kFileUrl[] = "file:///tmp/bar.webm";
static const char kHttpDifferentPathUrl[] = "http://localhost/bar.webm"; static const char kHttpDifferentPathUrl[] = "http://localhost/bar.webm";
static const char kHttpDifferentOriginUrl[] = "http://127.0.0.1/foo.webm"; static const char kHttpDifferentOriginUrl[] = "http://127.0.0.1/foo.webm";
class MultibufferDataSourceTest : public testing::Test { class MultiBufferDataSourceTest : public testing::Test {
public: public:
MultibufferDataSourceTest() : preload_(MultibufferDataSource::AUTO) { MultiBufferDataSourceTest() : preload_(MultiBufferDataSource::AUTO) {
ON_CALL(fetch_context_, CreateUrlLoader(_)) ON_CALL(fetch_context_, CreateUrlLoader(_))
.WillByDefault(Invoke([](const blink::WebAssociatedURLLoaderOptions&) { .WillByDefault(Invoke([](const blink::WebAssociatedURLLoaderOptions&) {
return std::make_unique<NiceMock<MockWebAssociatedURLLoader>>(); return std::make_unique<NiceMock<MockWebAssociatedURLLoader>>();
@@ -255,7 +255,7 @@ class MultibufferDataSourceTest : public testing::Test {
UrlData::CorsMode cors_mode, UrlData::CorsMode cors_mode,
size_t file_size = kFileSize) { size_t file_size = kFileSize) {
GURL gurl(url); GURL gurl(url);
data_source_ = std::make_unique<MockMultibufferDataSource>( data_source_ = std::make_unique<MockMultiBufferDataSource>(
task_runner_, url_index_.GetByUrl(gurl, cors_mode, UrlIndex::kNormal), task_runner_, url_index_.GetByUrl(gurl, cors_mode, UrlIndex::kNormal),
&host_); &host_);
data_source_->SetPreload(preload_); data_source_->SetPreload(preload_);
@@ -264,7 +264,7 @@ class MultibufferDataSourceTest : public testing::Test {
std::make_unique<TestResponseGenerator>(gurl, file_size); std::make_unique<TestResponseGenerator>(gurl, file_size);
EXPECT_CALL(*this, OnInitialize(expected)); EXPECT_CALL(*this, OnInitialize(expected));
data_source_->Initialize(base::BindOnce( data_source_->Initialize(base::BindOnce(
&MultibufferDataSourceTest::OnInitialize, base::Unretained(this))); &MultiBufferDataSourceTest::OnInitialize, base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Not really loading until after OnInitialize is called. // Not really loading until after OnInitialize is called.
@@ -364,7 +364,7 @@ class MultibufferDataSourceTest : public testing::Test {
void ReadAt(int64_t position, int64_t howmuch = kDataSize) { void ReadAt(int64_t position, int64_t howmuch = kDataSize) {
data_source_->Read(position, howmuch, buffer_, data_source_->Read(position, howmuch, buffer_,
base::BindOnce(&MultibufferDataSourceTest::ReadCallback, base::BindOnce(&MultiBufferDataSourceTest::ReadCallback,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
@@ -454,8 +454,8 @@ class MultibufferDataSourceTest : public testing::Test {
} }
bool loading() { return multibuffer()->loading(); } bool loading() { return multibuffer()->loading(); }
MultibufferDataSource::Preload preload() { return data_source_->preload_; } MultiBufferDataSource::Preload preload() { return data_source_->preload_; }
void set_preload(MultibufferDataSource::Preload preload) { void set_preload(MultiBufferDataSource::Preload preload) {
preload_ = preload; preload_ = preload;
} }
int64_t preload_high() { int64_t preload_high() {
@@ -480,26 +480,26 @@ class MultibufferDataSourceTest : public testing::Test {
} }
protected: protected:
MultibufferDataSource::Preload preload_; MultiBufferDataSource::Preload preload_;
NiceMock<MockResourceFetchContext> fetch_context_; NiceMock<MockResourceFetchContext> fetch_context_;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_ = const scoped_refptr<base::SingleThreadTaskRunner> task_runner_ =
BlinkPlatformWithTaskEnvironment::GetTaskEnvironment() BlinkPlatformWithTaskEnvironment::GetTaskEnvironment()
->GetMainThreadTaskRunner(); ->GetMainThreadTaskRunner();
TestUrlIndex url_index_{&fetch_context_, task_runner_}; TestUrlIndex url_index_{&fetch_context_, task_runner_};
std::unique_ptr<MockMultibufferDataSource> data_source_; std::unique_ptr<MockMultiBufferDataSource> data_source_;
std::unique_ptr<TestResponseGenerator> response_generator_; std::unique_ptr<TestResponseGenerator> response_generator_;
StrictMock<MockBufferedDataSourceHost> host_; StrictMock<MockBufferedDataSourceHost> host_;
// Used for calling MultibufferDataSource::Read(). // Used for calling MultiBufferDataSource::Read().
uint8_t buffer_[kDataSize * 2]; uint8_t buffer_[kDataSize * 2];
DISALLOW_COPY_AND_ASSIGN(MultibufferDataSourceTest); DISALLOW_COPY_AND_ASSIGN(MultiBufferDataSourceTest);
}; };
TEST_F(MultibufferDataSourceTest, Range_Supported) { TEST_F(MultiBufferDataSourceTest, Range_Supported) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_TRUE(loading()); EXPECT_TRUE(loading());
@@ -507,7 +507,7 @@ TEST_F(MultibufferDataSourceTest, Range_Supported) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_InstanceSizeUnknown) { TEST_F(MultiBufferDataSourceTest, Range_InstanceSizeUnknown) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
Respond(response_generator_->Generate206( Respond(response_generator_->Generate206(
@@ -521,7 +521,7 @@ TEST_F(MultibufferDataSourceTest, Range_InstanceSizeUnknown) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_NotFound) { TEST_F(MultiBufferDataSourceTest, Range_NotFound) {
Initialize(kHttpUrl, false); Initialize(kHttpUrl, false);
Respond(response_generator_->Generate404()); Respond(response_generator_->Generate404());
@@ -529,7 +529,7 @@ TEST_F(MultibufferDataSourceTest, Range_NotFound) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_NotSupported) { TEST_F(MultiBufferDataSourceTest, Range_NotSupported) {
InitializeWith200Response(); InitializeWith200Response();
EXPECT_TRUE(loading()); EXPECT_TRUE(loading());
@@ -537,7 +537,7 @@ TEST_F(MultibufferDataSourceTest, Range_NotSupported) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_NotSatisfiable) { TEST_F(MultiBufferDataSourceTest, Range_NotSatisfiable) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
Respond(response_generator_->GenerateResponse(416)); Respond(response_generator_->GenerateResponse(416));
@@ -547,7 +547,7 @@ TEST_F(MultibufferDataSourceTest, Range_NotSatisfiable) {
// Special carve-out for Apache versions that choose to return a 200 for // Special carve-out for Apache versions that choose to return a 200 for
// Range:0- ("because it's more efficient" than a 206) // Range:0- ("because it's more efficient" than a 206)
TEST_F(MultibufferDataSourceTest, Range_SupportedButReturned200) { TEST_F(MultiBufferDataSourceTest, Range_SupportedButReturned200) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
WebURLResponse response = response_generator_->Generate200(); WebURLResponse response = response_generator_->Generate200();
@@ -563,7 +563,7 @@ TEST_F(MultibufferDataSourceTest, Range_SupportedButReturned200) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_MissingContentRange) { TEST_F(MultiBufferDataSourceTest, Range_MissingContentRange) {
Initialize(kHttpUrl, false); Initialize(kHttpUrl, false);
Respond(response_generator_->Generate206( Respond(response_generator_->Generate206(
0, TestResponseGenerator::kNoContentRange)); 0, TestResponseGenerator::kNoContentRange));
@@ -572,7 +572,7 @@ TEST_F(MultibufferDataSourceTest, Range_MissingContentRange) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_MissingContentLength) { TEST_F(MultiBufferDataSourceTest, Range_MissingContentLength) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
// It'll manage without a Content-Length response. // It'll manage without a Content-Length response.
@@ -588,7 +588,7 @@ TEST_F(MultibufferDataSourceTest, Range_MissingContentLength) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Range_WrongContentRange) { TEST_F(MultiBufferDataSourceTest, Range_WrongContentRange) {
Initialize(kHttpUrl, false); Initialize(kHttpUrl, false);
// Now it's done and will fail. // Now it's done and will fail.
@@ -600,7 +600,7 @@ TEST_F(MultibufferDataSourceTest, Range_WrongContentRange) {
// Test the case where the initial response from the server indicates that // Test the case where the initial response from the server indicates that
// Range requests are supported, but a later request prove otherwise. // Range requests are supported, but a later request prove otherwise.
TEST_F(MultibufferDataSourceTest, Range_ServerLied) { TEST_F(MultiBufferDataSourceTest, Range_ServerLied) {
InitializeWith206Response(); InitializeWith206Response();
// Read causing a new request to be made, we will discard the data that // Read causing a new request to be made, we will discard the data that
@@ -615,7 +615,7 @@ TEST_F(MultibufferDataSourceTest, Range_ServerLied) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_AbortWhileReading) { TEST_F(MultiBufferDataSourceTest, Http_AbortWhileReading) {
InitializeWith206Response(); InitializeWith206Response();
// Make sure there's a pending read -- we'll expect it to error. // Make sure there's a pending read -- we'll expect it to error.
@@ -630,7 +630,7 @@ TEST_F(MultibufferDataSourceTest, Http_AbortWhileReading) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_AbortWhileReading) { TEST_F(MultiBufferDataSourceTest, File_AbortWhileReading) {
InitializeWithFileResponse(); InitializeWithFileResponse();
// Make sure there's a pending read -- we'll expect it to error. // Make sure there's a pending read -- we'll expect it to error.
@@ -645,7 +645,7 @@ TEST_F(MultibufferDataSourceTest, File_AbortWhileReading) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_Retry) { TEST_F(MultiBufferDataSourceTest, Http_Retry) {
InitializeWith206Response(); InitializeWith206Response();
// Read to advance our position. // Read to advance our position.
@@ -667,7 +667,7 @@ TEST_F(MultibufferDataSourceTest, Http_Retry) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_RetryOnError) { TEST_F(MultiBufferDataSourceTest, Http_RetryOnError) {
InitializeWith206Response(); InitializeWith206Response();
// Read to advance our position. // Read to advance our position.
@@ -690,7 +690,7 @@ TEST_F(MultibufferDataSourceTest, Http_RetryOnError) {
} }
// Make sure that we prefetch across partial responses. (crbug.com/516589) // Make sure that we prefetch across partial responses. (crbug.com/516589)
TEST_F(MultibufferDataSourceTest, Http_PartialResponsePrefetch) { TEST_F(MultiBufferDataSourceTest, Http_PartialResponsePrefetch) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
@@ -717,7 +717,7 @@ TEST_F(MultibufferDataSourceTest, Http_PartialResponsePrefetch) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_PartialResponse) { TEST_F(MultiBufferDataSourceTest, Http_PartialResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
@@ -728,7 +728,7 @@ TEST_F(MultibufferDataSourceTest, Http_PartialResponse) {
ExecuteMixedResponseSuccessTest(response1, response2); ExecuteMixedResponseSuccessTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_RedirectedToDifferentPathResponse) { Http_MixedResponse_RedirectedToDifferentPathResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -741,7 +741,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseSuccessTest(response1, response2); ExecuteMixedResponseSuccessTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_RedirectedToDifferentOriginResponse) { Http_MixedResponse_RedirectedToDifferentOriginResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -754,7 +754,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseFailureTest(response1, response2); ExecuteMixedResponseFailureTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_ServiceWorkerGeneratedResponseAndNormalResponse) { Http_MixedResponse_ServiceWorkerGeneratedResponseAndNormalResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -767,7 +767,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseFailureTest(response1, response2); ExecuteMixedResponseFailureTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_ServiceWorkerProxiedAndSameURLResponse) { Http_MixedResponse_ServiceWorkerProxiedAndSameURLResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -782,7 +782,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseSuccessTest(response1, response2); ExecuteMixedResponseSuccessTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_ServiceWorkerProxiedAndDifferentPathResponse) { Http_MixedResponse_ServiceWorkerProxiedAndDifferentPathResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -797,7 +797,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseSuccessTest(response1, response2); ExecuteMixedResponseSuccessTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponse) { Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponse) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
WebURLResponse response1 = WebURLResponse response1 =
@@ -812,7 +812,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseFailureTest(response1, response2); ExecuteMixedResponseFailureTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponseCors) { Http_MixedResponse_ServiceWorkerProxiedAndDifferentOriginResponseCors) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
WebURLResponse response1 = WebURLResponse response1 =
@@ -827,7 +827,7 @@ TEST_F(MultibufferDataSourceTest,
ExecuteMixedResponseSuccessTest(response1, response2); ExecuteMixedResponseSuccessTest(response1, response2);
} }
TEST_F(MultibufferDataSourceTest, File_Retry) { TEST_F(MultiBufferDataSourceTest, File_Retry) {
InitializeWithFileResponse(); InitializeWithFileResponse();
// Read to advance our position. // Read to advance our position.
@@ -848,7 +848,7 @@ TEST_F(MultibufferDataSourceTest, File_Retry) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_TooManyRetries) { TEST_F(MultiBufferDataSourceTest, Http_TooManyRetries) {
InitializeWith206Response(); InitializeWith206Response();
// Make sure there's a pending read -- we'll expect it to error. // Make sure there's a pending read -- we'll expect it to error.
@@ -871,7 +871,7 @@ TEST_F(MultibufferDataSourceTest, Http_TooManyRetries) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_TooManyRetries) { TEST_F(MultiBufferDataSourceTest, File_TooManyRetries) {
InitializeWithFileResponse(); InitializeWithFileResponse();
// Make sure there's a pending read -- we'll expect it to error. // Make sure there's a pending read -- we'll expect it to error.
@@ -894,7 +894,7 @@ TEST_F(MultibufferDataSourceTest, File_TooManyRetries) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_InstanceSizeUnknown) { TEST_F(MultiBufferDataSourceTest, File_InstanceSizeUnknown) {
Initialize(kFileUrl, false); Initialize(kFileUrl, false);
Respond( Respond(
@@ -906,7 +906,7 @@ TEST_F(MultibufferDataSourceTest, File_InstanceSizeUnknown) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_Successful) { TEST_F(MultiBufferDataSourceTest, File_Successful) {
InitializeWithFileResponse(); InitializeWithFileResponse();
EXPECT_TRUE(loading()); EXPECT_TRUE(loading());
@@ -914,12 +914,12 @@ TEST_F(MultibufferDataSourceTest, File_Successful) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, StopDuringRead) { TEST_F(MultiBufferDataSourceTest, StopDuringRead) {
InitializeWith206Response(); InitializeWith206Response();
uint8_t buffer[256]; uint8_t buffer[256];
data_source_->Read(kDataSize, base::size(buffer), buffer, data_source_->Read(kDataSize, base::size(buffer), buffer,
base::BindOnce(&MultibufferDataSourceTest::ReadCallback, base::BindOnce(&MultiBufferDataSourceTest::ReadCallback,
base::Unretained(this))); base::Unretained(this)));
// The outstanding read should fail before the stop callback runs. // The outstanding read should fail before the stop callback runs.
@@ -931,11 +931,11 @@ TEST_F(MultibufferDataSourceTest, StopDuringRead) {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
TEST_F(MultibufferDataSourceTest, DefaultValues) { TEST_F(MultiBufferDataSourceTest, DefaultValues) {
InitializeWith206Response(); InitializeWith206Response();
// Ensure we have sane values for default loading scenario. // Ensure we have sane values for default loading scenario.
EXPECT_EQ(MultibufferDataSource::AUTO, preload()); EXPECT_EQ(MultiBufferDataSource::AUTO, preload());
EXPECT_EQ(2 << 20, preload_low()); EXPECT_EQ(2 << 20, preload_low());
EXPECT_EQ(3 << 20, preload_high()); EXPECT_EQ(3 << 20, preload_high());
@@ -946,7 +946,7 @@ TEST_F(MultibufferDataSourceTest, DefaultValues) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, SetBitrate) { TEST_F(MultiBufferDataSourceTest, SetBitrate) {
InitializeWith206Response(); InitializeWith206Response();
data_source_->SetBitrate(1234); data_source_->SetBitrate(1234);
@@ -966,7 +966,7 @@ TEST_F(MultibufferDataSourceTest, SetBitrate) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, MediaPlaybackRateChanged) { TEST_F(MultiBufferDataSourceTest, MediaPlaybackRateChanged) {
InitializeWith206Response(); InitializeWith206Response();
data_source_->MediaPlaybackRateChanged(2.0); data_source_->MediaPlaybackRateChanged(2.0);
@@ -986,7 +986,7 @@ TEST_F(MultibufferDataSourceTest, MediaPlaybackRateChanged) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_Read) { TEST_F(MultiBufferDataSourceTest, Http_Read) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_CALL(*this, ReadCallback(kDataSize)); EXPECT_CALL(*this, ReadCallback(kDataSize));
@@ -1004,7 +1004,7 @@ TEST_F(MultibufferDataSourceTest, Http_Read) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_ShareData) { TEST_F(MultiBufferDataSourceTest, Http_ShareData) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_CALL(*this, ReadCallback(kDataSize)); EXPECT_CALL(*this, ReadCallback(kDataSize));
@@ -1021,7 +1021,7 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) {
EXPECT_TRUE(data_source_->downloading()); EXPECT_TRUE(data_source_->downloading());
StrictMock<MockBufferedDataSourceHost> host2; StrictMock<MockBufferedDataSourceHost> host2;
MockMultibufferDataSource source2( MockMultiBufferDataSource source2(
task_runner_, task_runner_,
url_index_.GetByUrl(GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED, url_index_.GetByUrl(GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED,
UrlIndex::kNormal), UrlIndex::kNormal),
@@ -1033,7 +1033,7 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) {
// This call would not be expected if we were not sharing data. // This call would not be expected if we were not sharing data.
EXPECT_CALL(host2, SetTotalBytes(response_generator_->content_length())); EXPECT_CALL(host2, SetTotalBytes(response_generator_->content_length()));
EXPECT_CALL(host2, AddBufferedByteRange(0, kDataSize * 2)); EXPECT_CALL(host2, AddBufferedByteRange(0, kDataSize * 2));
source2.Initialize(base::BindOnce(&MultibufferDataSourceTest::OnInitialize, source2.Initialize(base::BindOnce(&MultiBufferDataSourceTest::OnInitialize,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
@@ -1043,7 +1043,7 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_Read_Seek) { TEST_F(MultiBufferDataSourceTest, Http_Read_Seek) {
InitializeWith206Response(); InitializeWith206Response();
// Read a bit from the beginning. // Read a bit from the beginning.
@@ -1067,7 +1067,7 @@ TEST_F(MultibufferDataSourceTest, Http_Read_Seek) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_Read) { TEST_F(MultiBufferDataSourceTest, File_Read) {
InitializeWithFileResponse(); InitializeWithFileResponse();
EXPECT_CALL(*this, ReadCallback(kDataSize)); EXPECT_CALL(*this, ReadCallback(kDataSize));
@@ -1080,7 +1080,7 @@ TEST_F(MultibufferDataSourceTest, File_Read) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_FinishLoading) { TEST_F(MultiBufferDataSourceTest, Http_FinishLoading) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_TRUE(data_source_->downloading()); EXPECT_TRUE(data_source_->downloading());
@@ -1091,7 +1091,7 @@ TEST_F(MultibufferDataSourceTest, Http_FinishLoading) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, File_FinishLoading) { TEST_F(MultiBufferDataSourceTest, File_FinishLoading) {
InitializeWithFileResponse(); InitializeWithFileResponse();
ReceiveData(kDataSize); ReceiveData(kDataSize);
@@ -1104,10 +1104,10 @@ TEST_F(MultibufferDataSourceTest, File_FinishLoading) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, LocalResource_DeferStrategy) { TEST_F(MultiBufferDataSourceTest, LocalResource_DeferStrategy) {
InitializeWithFileResponse(); InitializeWithFileResponse();
EXPECT_EQ(MultibufferDataSource::AUTO, preload()); EXPECT_EQ(MultiBufferDataSource::AUTO, preload());
EXPECT_TRUE(is_local_source()); EXPECT_TRUE(is_local_source());
CheckCapacityDefer(); CheckCapacityDefer();
@@ -1117,11 +1117,11 @@ TEST_F(MultibufferDataSourceTest, LocalResource_DeferStrategy) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) { TEST_F(MultiBufferDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWithFileResponse(); InitializeWithFileResponse();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_TRUE(is_local_source()); EXPECT_TRUE(is_local_source());
CheckReadThenDefer(); CheckReadThenDefer();
@@ -1131,10 +1131,10 @@ TEST_F(MultibufferDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, ExternalResource_Reponse200_DeferStrategy) { TEST_F(MultiBufferDataSourceTest, ExternalResource_Reponse200_DeferStrategy) {
InitializeWith200Response(); InitializeWith200Response();
EXPECT_EQ(MultibufferDataSource::AUTO, preload()); EXPECT_EQ(MultiBufferDataSource::AUTO, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_FALSE(data_source_->range_supported()); EXPECT_FALSE(data_source_->range_supported());
CheckCapacityDefer(); CheckCapacityDefer();
@@ -1145,12 +1145,12 @@ TEST_F(MultibufferDataSourceTest, ExternalResource_Reponse200_DeferStrategy) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response200_PreloadMetadata_DeferStrategy) { ExternalResource_Response200_PreloadMetadata_DeferStrategy) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith200Response(); InitializeWith200Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_FALSE(data_source_->range_supported()); EXPECT_FALSE(data_source_->range_supported());
CheckReadThenDefer(); CheckReadThenDefer();
@@ -1161,10 +1161,10 @@ TEST_F(MultibufferDataSourceTest,
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, ExternalResource_Reponse206_DeferStrategy) { TEST_F(MultiBufferDataSourceTest, ExternalResource_Reponse206_DeferStrategy) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::AUTO, preload()); EXPECT_EQ(MultiBufferDataSource::AUTO, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
CheckCapacityDefer(); CheckCapacityDefer();
@@ -1179,12 +1179,12 @@ TEST_F(MultibufferDataSourceTest, ExternalResource_Reponse206_DeferStrategy) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response206_PreloadMetadata_DeferStrategy) { ExternalResource_Response206_PreloadMetadata_DeferStrategy) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
CheckReadThenDefer(); CheckReadThenDefer();
@@ -1202,11 +1202,11 @@ TEST_F(MultibufferDataSourceTest,
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, ExternalResource_Response206_VerifyDefer) { TEST_F(MultiBufferDataSourceTest, ExternalResource_Response206_VerifyDefer) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
CheckReadThenDefer(); CheckReadThenDefer();
@@ -1222,12 +1222,12 @@ TEST_F(MultibufferDataSourceTest, ExternalResource_Response206_VerifyDefer) {
EXPECT_TRUE(data_provider()->deferred()); EXPECT_TRUE(data_provider()->deferred());
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response206_CancelAfterDefer) { ExternalResource_Response206_CancelAfterDefer) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
@@ -1253,12 +1253,12 @@ TEST_F(MultibufferDataSourceTest,
// This test tries to trigger an edge case where the read callback // This test tries to trigger an edge case where the read callback
// never happens because the reader is deleted before that happens. // never happens because the reader is deleted before that happens.
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response206_CancelAfterDefer2) { ExternalResource_Response206_CancelAfterDefer2) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
@@ -1290,12 +1290,12 @@ TEST_F(MultibufferDataSourceTest,
// This test tries to trigger an edge case where the read callback // This test tries to trigger an edge case where the read callback
// never happens because the reader is deleted before that happens. // never happens because the reader is deleted before that happens.
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response206_CancelAfterDefer3) { ExternalResource_Response206_CancelAfterDefer3) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
@@ -1315,7 +1315,7 @@ TEST_F(MultibufferDataSourceTest,
ReceiveData(kDataSize); ReceiveData(kDataSize);
EXPECT_EQ(data_source_->downloading(), false); EXPECT_EQ(data_source_->downloading(), false);
data_source_->Read(kDataSize * 10, kDataSize, buffer_, data_source_->Read(kDataSize * 10, kDataSize, buffer_,
base::BindOnce(&MultibufferDataSourceTest::ReadCallback, base::BindOnce(&MultiBufferDataSourceTest::ReadCallback,
base::Unretained(this))); base::Unretained(this)));
data_source_->OnBufferingHaveEnough(false); data_source_->OnBufferingHaveEnough(false);
EXPECT_TRUE(active_loader_allownull()); EXPECT_TRUE(active_loader_allownull());
@@ -1323,12 +1323,12 @@ TEST_F(MultibufferDataSourceTest,
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, TEST_F(MultiBufferDataSourceTest,
ExternalResource_Response206_CancelAfterPlay) { ExternalResource_Response206_CancelAfterPlay) {
set_preload(MultibufferDataSource::METADATA); set_preload(MultiBufferDataSource::METADATA);
InitializeWith206Response(); InitializeWith206Response();
EXPECT_EQ(MultibufferDataSource::METADATA, preload()); EXPECT_EQ(MultiBufferDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source()); EXPECT_FALSE(is_local_source());
EXPECT_TRUE(data_source_->range_supported()); EXPECT_TRUE(data_source_->range_supported());
@@ -1386,9 +1386,9 @@ TEST_F(MultibufferDataSourceTest,
} }
} }
TEST_F(MultibufferDataSourceTest, SeekPastEOF) { TEST_F(MultiBufferDataSourceTest, SeekPastEOF) {
GURL gurl(kHttpUrl); GURL gurl(kHttpUrl);
data_source_ = std::make_unique<MockMultibufferDataSource>( data_source_ = std::make_unique<MockMultiBufferDataSource>(
task_runner_, task_runner_,
url_index_.GetByUrl(gurl, UrlData::CORS_UNSPECIFIED, UrlIndex::kNormal), url_index_.GetByUrl(gurl, UrlData::CORS_UNSPECIFIED, UrlIndex::kNormal),
&host_); &host_);
@@ -1398,7 +1398,7 @@ TEST_F(MultibufferDataSourceTest, SeekPastEOF) {
std::make_unique<TestResponseGenerator>(gurl, kDataSize + 1); std::make_unique<TestResponseGenerator>(gurl, kDataSize + 1);
EXPECT_CALL(*this, OnInitialize(true)); EXPECT_CALL(*this, OnInitialize(true));
data_source_->Initialize(base::BindOnce( data_source_->Initialize(base::BindOnce(
&MultibufferDataSourceTest::OnInitialize, base::Unretained(this))); &MultiBufferDataSourceTest::OnInitialize, base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Not really loading until after OnInitialize is called. // Not really loading until after OnInitialize is called.
@@ -1423,7 +1423,7 @@ TEST_F(MultibufferDataSourceTest, SeekPastEOF) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) { TEST_F(MultiBufferDataSourceTest, Http_RetryThenRedirect) {
InitializeWith206Response(); InitializeWith206Response();
// Read to advance our position. // Read to advance our position.
@@ -1453,7 +1453,7 @@ TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_NotStreamingAfterRedirect) { TEST_F(MultiBufferDataSourceTest, Http_NotStreamingAfterRedirect) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
// Server responds with a redirect. // Server responds with a redirect.
@@ -1475,7 +1475,7 @@ TEST_F(MultibufferDataSourceTest, Http_NotStreamingAfterRedirect) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) { TEST_F(MultiBufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
// Server responds with a redirect. // Server responds with a redirect.
@@ -1489,7 +1489,7 @@ TEST_F(MultibufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_404AfterRedirect) { TEST_F(MultiBufferDataSourceTest, Http_404AfterRedirect) {
Initialize(kHttpUrl, false); Initialize(kHttpUrl, false);
// Server responds with a redirect. // Server responds with a redirect.
@@ -1502,7 +1502,7 @@ TEST_F(MultibufferDataSourceTest, Http_404AfterRedirect) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, LengthKnownAtEOF) { TEST_F(MultiBufferDataSourceTest, LengthKnownAtEOF) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
// Server responds without content-length. // Server responds without content-length.
WebURLResponse response = response_generator_->Generate200(); WebURLResponse response = response_generator_->Generate200();
@@ -1529,7 +1529,7 @@ TEST_F(MultibufferDataSourceTest, LengthKnownAtEOF) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, FileSizeLessThanBlockSize) { TEST_F(MultiBufferDataSourceTest, FileSizeLessThanBlockSize) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
GURL gurl(kHttpUrl); GURL gurl(kHttpUrl);
blink::WebURLResponse response(gurl); blink::WebURLResponse response(gurl);
@@ -1551,9 +1551,9 @@ TEST_F(MultibufferDataSourceTest, FileSizeLessThanBlockSize) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, ResponseTypeBasic) { TEST_F(MultiBufferDataSourceTest, ResponseTypeBasic) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
set_preload(MultibufferDataSource::NONE); set_preload(MultiBufferDataSource::NONE);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetType(network::mojom::FetchResponseType::kBasic); response1.SetType(network::mojom::FetchResponseType::kBasic);
@@ -1571,9 +1571,9 @@ TEST_F(MultibufferDataSourceTest, ResponseTypeBasic) {
FinishLoading(); FinishLoading();
} }
TEST_F(MultibufferDataSourceTest, ResponseTypeCors) { TEST_F(MultiBufferDataSourceTest, ResponseTypeCors) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
set_preload(MultibufferDataSource::NONE); set_preload(MultiBufferDataSource::NONE);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetType(network::mojom::FetchResponseType::kCors); response1.SetType(network::mojom::FetchResponseType::kCors);
@@ -1591,9 +1591,9 @@ TEST_F(MultibufferDataSourceTest, ResponseTypeCors) {
FinishLoading(); FinishLoading();
} }
TEST_F(MultibufferDataSourceTest, ResponseTypeDefault) { TEST_F(MultiBufferDataSourceTest, ResponseTypeDefault) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
set_preload(MultibufferDataSource::NONE); set_preload(MultiBufferDataSource::NONE);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetType(network::mojom::FetchResponseType::kDefault); response1.SetType(network::mojom::FetchResponseType::kDefault);
@@ -1611,9 +1611,9 @@ TEST_F(MultibufferDataSourceTest, ResponseTypeDefault) {
FinishLoading(); FinishLoading();
} }
TEST_F(MultibufferDataSourceTest, ResponseTypeOpaque) { TEST_F(MultiBufferDataSourceTest, ResponseTypeOpaque) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
set_preload(MultibufferDataSource::NONE); set_preload(MultiBufferDataSource::NONE);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetType(network::mojom::FetchResponseType::kOpaque); response1.SetType(network::mojom::FetchResponseType::kOpaque);
@@ -1631,9 +1631,9 @@ TEST_F(MultibufferDataSourceTest, ResponseTypeOpaque) {
FinishLoading(); FinishLoading();
} }
TEST_F(MultibufferDataSourceTest, ResponseTypeOpaqueRedirect) { TEST_F(MultiBufferDataSourceTest, ResponseTypeOpaqueRedirect) {
InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS); InitializeWithCors(kHttpUrl, true, UrlData::CORS_ANONYMOUS);
set_preload(MultibufferDataSource::NONE); set_preload(MultiBufferDataSource::NONE);
WebURLResponse response1 = WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1); response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetType(network::mojom::FetchResponseType::kOpaqueRedirect); response1.SetType(network::mojom::FetchResponseType::kOpaqueRedirect);
@@ -1651,7 +1651,7 @@ TEST_F(MultibufferDataSourceTest, ResponseTypeOpaqueRedirect) {
FinishLoading(); FinishLoading();
} }
TEST_F(MultibufferDataSourceTest, EtagTest) { TEST_F(MultiBufferDataSourceTest, EtagTest) {
Initialize(kHttpUrl, true); Initialize(kHttpUrl, true);
EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
@@ -1666,7 +1666,7 @@ TEST_F(MultibufferDataSourceTest, EtagTest) {
EXPECT_EQ(url_data()->etag(), etag); EXPECT_EQ(url_data()->etag(), etag);
} }
TEST_F(MultibufferDataSourceTest, CheckBufferSizes) { TEST_F(MultiBufferDataSourceTest, CheckBufferSizes) {
InitializeWith206Response(1 << 30); // 1 gb InitializeWith206Response(1 << 30); // 1 gb
data_source_->SetBitrate(1 << 20); // 1 mbit / s data_source_->SetBitrate(1 << 20); // 1 mbit / s
@@ -1715,7 +1715,7 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizes) {
EXPECT_EQ(71 << 20, buffer_size()); EXPECT_EQ(71 << 20, buffer_size());
} }
TEST_F(MultibufferDataSourceTest, CheckBufferSizeForSmallFiles) { TEST_F(MultiBufferDataSourceTest, CheckBufferSizeForSmallFiles) {
InitializeWith206Response(); InitializeWith206Response();
data_source_->SetBitrate(1 << 20); // 1 mbit / s data_source_->SetBitrate(1 << 20); // 1 mbit / s
@@ -1737,7 +1737,7 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizeForSmallFiles) {
EXPECT_EQ(5013504 /* file size rounded up to blocks size */, buffer_size()); EXPECT_EQ(5013504 /* file size rounded up to blocks size */, buffer_size());
} }
TEST_F(MultibufferDataSourceTest, CheckBufferSizeAfterReadingALot) { TEST_F(MultiBufferDataSourceTest, CheckBufferSizeAfterReadingALot) {
InitializeWith206Response(); InitializeWith206Response();
EXPECT_CALL(*this, ReadCallback(kDataSize)); EXPECT_CALL(*this, ReadCallback(kDataSize));
@@ -1765,9 +1765,9 @@ TEST_F(MultibufferDataSourceTest, CheckBufferSizeAfterReadingALot) {
// Provoke an edge case where the loading state may not end up transitioning // Provoke an edge case where the loading state may not end up transitioning
// back to "idle" when we're done loading. // back to "idle" when we're done loading.
TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) { TEST_F(MultiBufferDataSourceTest, Http_CheckLoadingTransition) {
GURL gurl(kHttpUrl); GURL gurl(kHttpUrl);
data_source_ = std::make_unique<MockMultibufferDataSource>( data_source_ = std::make_unique<MockMultiBufferDataSource>(
task_runner_, task_runner_,
url_index_.GetByUrl(gurl, UrlData::CORS_UNSPECIFIED, UrlIndex::kNormal), url_index_.GetByUrl(gurl, UrlData::CORS_UNSPECIFIED, UrlIndex::kNormal),
&host_); &host_);
@@ -1777,7 +1777,7 @@ TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
std::make_unique<TestResponseGenerator>(gurl, kDataSize * 1); std::make_unique<TestResponseGenerator>(gurl, kDataSize * 1);
EXPECT_CALL(*this, OnInitialize(true)); EXPECT_CALL(*this, OnInitialize(true));
data_source_->Initialize(base::BindOnce( data_source_->Initialize(base::BindOnce(
&MultibufferDataSourceTest::OnInitialize, base::Unretained(this))); &MultiBufferDataSourceTest::OnInitialize, base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Not really loading until after OnInitialize is called. // Not really loading until after OnInitialize is called.
@@ -1796,7 +1796,7 @@ TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
EXPECT_CALL(*this, ReadCallback(1)); EXPECT_CALL(*this, ReadCallback(1));
data_source_->Read(kDataSize, 2, buffer_, data_source_->Read(kDataSize, 2, buffer_,
base::BindOnce(&MultibufferDataSourceTest::ReadCallback, base::BindOnce(&MultiBufferDataSourceTest::ReadCallback,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
@@ -1805,7 +1805,7 @@ TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
Stop(); Stop();
} }
TEST_F(MultibufferDataSourceTest, Http_Seek_Back) { TEST_F(MultiBufferDataSourceTest, Http_Seek_Back) {
InitializeWith206Response(); InitializeWith206Response();
// Read a bit from the beginning. // Read a bit from the beginning.

@@ -110,7 +110,7 @@ class MEDIA_BLINK_EXPORT MultiBufferReader : public MultiBuffer::Reader {
} }
private: private:
friend class MultibufferDataSourceTest; friend class MultiBufferDataSourceTest;
// Returns the block for a particular byte position. // Returns the block for a particular byte position.
MultiBufferBlockId block(int64_t byte_pos) const { MultiBufferBlockId block(int64_t byte_pos) const {

@@ -363,7 +363,7 @@ void ResourceMultiBufferDataProvider::DidReceiveResponse(
// Get the response URL since it can differ from the request URL when a // Get the response URL since it can differ from the request URL when a
// service worker provided the response. Normally we would just use // service worker provided the response. Normally we would just use
// ResponseUrl(), but ResourceMultibufferDataProvider disallows mixing // ResponseUrl(), but ResourceMultiBufferDataProvider disallows mixing
// constructed responses (new Response()) and native server responses, even if // constructed responses (new Response()) and native server responses, even if
// they have the same response URL. // they have the same response URL.
GURL response_url; GURL response_url;

@@ -68,7 +68,7 @@ class MEDIA_BLINK_EXPORT ResourceMultiBufferDataProvider
// Use protected instead of private for testing purposes. // Use protected instead of private for testing purposes.
protected: protected:
friend class MultibufferDataSourceTest; friend class MultiBufferDataSourceTest;
friend class ResourceMultiBufferDataProviderTest; friend class ResourceMultiBufferDataProviderTest;
friend class MockBufferedDataSource; friend class MockBufferedDataSource;

@@ -827,7 +827,7 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type,
auto url_data = url_index_->GetByUrl( auto url_data = url_index_->GetByUrl(
url, static_cast<UrlData::CorsMode>(cors_mode), url, static_cast<UrlData::CorsMode>(cors_mode),
is_cache_disabled ? UrlIndex::kCacheDisabled : UrlIndex::kNormal); is_cache_disabled ? UrlIndex::kCacheDisabled : UrlIndex::kNormal);
mb_data_source_ = new MultibufferDataSource( mb_data_source_ = new MultiBufferDataSource(
main_task_runner_, std::move(url_data), media_log_.get(), main_task_runner_, std::move(url_data), media_log_.get(),
buffered_data_source_host_.get(), buffered_data_source_host_.get(),
base::BindRepeating(&WebMediaPlayerImpl::NotifyDownloading, base::BindRepeating(&WebMediaPlayerImpl::NotifyDownloading,
@@ -1085,16 +1085,16 @@ bool WebMediaPlayerImpl::SetSinkId(
return true; return true;
} }
STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadNone, MultibufferDataSource::NONE); STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadNone, MultiBufferDataSource::NONE);
STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadMetaData, STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadMetaData,
MultibufferDataSource::METADATA); MultiBufferDataSource::METADATA);
STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadAuto, MultibufferDataSource::AUTO); STATIC_ASSERT_ENUM(WebMediaPlayer::kPreloadAuto, MultiBufferDataSource::AUTO);
void WebMediaPlayerImpl::SetPreload(WebMediaPlayer::Preload preload) { void WebMediaPlayerImpl::SetPreload(WebMediaPlayer::Preload preload) {
DVLOG(1) << __func__ << "(" << preload << ")"; DVLOG(1) << __func__ << "(" << preload << ")";
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
preload_ = static_cast<MultibufferDataSource::Preload>(preload); preload_ = static_cast<MultiBufferDataSource::Preload>(preload);
if (mb_data_source_) if (mb_data_source_)
mb_data_source_->SetPreload(preload_); mb_data_source_->SetPreload(preload_);
} }
@@ -1667,7 +1667,7 @@ void WebMediaPlayerImpl::OnPipelineSuspended() {
// will cancel upon destruction of this class and |mb_data_source_| is // will cancel upon destruction of this class and |mb_data_source_| is
// gauranteeed to outlive us. // gauranteeed to outlive us.
have_enough_after_lazy_load_cb_.Reset( have_enough_after_lazy_load_cb_.Reset(
base::BindOnce(&MultibufferDataSource::OnBufferingHaveEnough, base::BindOnce(&MultiBufferDataSource::OnBufferingHaveEnough,
base::Unretained(mb_data_source_), true)); base::Unretained(mb_data_source_), true));
main_task_runner_->PostDelayedTask( main_task_runner_->PostDelayedTask(
FROM_HERE, have_enough_after_lazy_load_cb_.callback(), FROM_HERE, have_enough_after_lazy_load_cb_.callback(),
@@ -2614,9 +2614,9 @@ void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
} }
// No point in preloading data as we'll probably just throw it away anyways. // No point in preloading data as we'll probably just throw it away anyways.
if (IsStreaming() && preload_ > MultibufferDataSource::METADATA && if (IsStreaming() && preload_ > MultiBufferDataSource::METADATA &&
mb_data_source_) { mb_data_source_) {
mb_data_source_->SetPreload(MultibufferDataSource::METADATA); mb_data_source_->SetPreload(MultiBufferDataSource::METADATA);
} }
StartPipeline(); StartPipeline();
@@ -2837,7 +2837,7 @@ void WebMediaPlayerImpl::StartPipeline() {
// If possible attempt to avoid decoder spool up until playback starts. // If possible attempt to avoid decoder spool up until playback starts.
Pipeline::StartType start_type = Pipeline::StartType::kNormal; Pipeline::StartType start_type = Pipeline::StartType::kNormal;
if (!chunk_demuxer_ && preload_ == MultibufferDataSource::METADATA && if (!chunk_demuxer_ && preload_ == MultiBufferDataSource::METADATA &&
!client_->CouldPlayIfEnoughData() && !IsStreaming()) { !client_->CouldPlayIfEnoughData() && !IsStreaming()) {
start_type = start_type =
(has_poster_ || base::FeatureList::IsEnabled(kPreloadMetadataLazyLoad)) (has_poster_ || base::FeatureList::IsEnabled(kPreloadMetadataLazyLoad))

@@ -634,7 +634,7 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl
WebMediaPlayer::kReadyStateHaveNothing; WebMediaPlayer::kReadyStateHaveNothing;
// Preload state for when |data_source_| is created after setPreload(). // Preload state for when |data_source_| is created after setPreload().
MultibufferDataSource::Preload preload_ = MultibufferDataSource::METADATA; MultiBufferDataSource::Preload preload_ = MultiBufferDataSource::METADATA;
// Poster state (for UMA reporting). // Poster state (for UMA reporting).
bool has_poster_ = false; bool has_poster_ = false;
@@ -750,7 +750,7 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl
// //
// |demuxer_| will contain the appropriate demuxer based on which resource // |demuxer_| will contain the appropriate demuxer based on which resource
// load strategy we're using. // load strategy we're using.
MultibufferDataSource* mb_data_source_ = nullptr; MultiBufferDataSource* mb_data_source_ = nullptr;
std::unique_ptr<DataSource> data_source_; std::unique_ptr<DataSource> data_source_;
std::unique_ptr<Demuxer> demuxer_; std::unique_ptr<Demuxer> demuxer_;
ChunkDemuxer* chunk_demuxer_ = nullptr; ChunkDemuxer* chunk_demuxer_ = nullptr;

@@ -685,7 +685,7 @@ class WebMediaPlayerImplTest
LoadType load_type = LoadType::kFullyBuffered) { LoadType load_type = LoadType::kFullyBuffered) {
const bool is_streaming = load_type == LoadType::kStreaming; const bool is_streaming = load_type == LoadType::kStreaming;
// The URL is used by MultibufferDataSource to determine if it should assume // The URL is used by MultiBufferDataSource to determine if it should assume
// the resource is fully buffered locally. We can use a fake one here since // the resource is fully buffered locally. We can use a fake one here since
// we're injecting the response artificially. It's value is unknown to the // we're injecting the response artificially. It's value is unknown to the
// underlying demuxer. // underlying demuxer.