Commit 8d2d53d6 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Commit Bot

Make MultiBufferReader::Wait to use OnceClosure instead of Closure.

Bug: 1007769
Change-Id: I85f8e4cda47ddfeac27b60d4f3b4c779de8e3f54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950376
Auto-Submit: Takashi Sakamoto <tasak@google.com>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722142}
parent 3c8ad158
......@@ -211,8 +211,8 @@ void MultibufferDataSource::Initialize(const InitializeCB& init_cb) {
FROM_HERE, base::BindOnce(&MultibufferDataSource::UpdateProgress,
weak_factory_.GetWeakPtr()));
} else {
reader_->Wait(1,
base::Bind(&MultibufferDataSource::StartCallback, weak_ptr_));
reader_->Wait(
1, base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_));
}
}
......@@ -249,8 +249,8 @@ void MultibufferDataSource::OnRedirect(
FROM_HERE,
base::BindOnce(&MultibufferDataSource::StartCallback, weak_ptr_));
} else {
reader_->Wait(
1, base::Bind(&MultibufferDataSource::StartCallback, weak_ptr_));
reader_->Wait(1, base::BindOnce(&MultibufferDataSource::StartCallback,
weak_ptr_));
}
} else if (read_op_) {
CreateResourceLoader(read_op_->position(), kPositionNotSpecified);
......@@ -259,8 +259,8 @@ void MultibufferDataSource::OnRedirect(
FROM_HERE,
base::BindOnce(&MultibufferDataSource::ReadTask, weak_ptr_));
} else {
reader_->Wait(1,
base::Bind(&MultibufferDataSource::ReadTask, weak_ptr_));
reader_->Wait(
1, base::BindOnce(&MultibufferDataSource::ReadTask, weak_ptr_));
}
}
}
......@@ -488,8 +488,8 @@ void MultibufferDataSource::ReadTask() {
SeekTask_Locked();
} else {
reader_->Seek(read_op_->position());
reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask,
weak_factory_.GetWeakPtr()));
reader_->Wait(1, base::BindOnce(&MultibufferDataSource::ReadTask,
weak_factory_.GetWeakPtr()));
UpdateLoadingState_Locked(false);
}
}
......
......@@ -113,7 +113,7 @@ int64_t MultiBufferReader::TryRead(uint8_t* data, int64_t len) {
return bytes_read;
}
int MultiBufferReader::Wait(int64_t len, const base::Closure& cb) {
int MultiBufferReader::Wait(int64_t len, base::OnceClosure cb) {
DCHECK_LE(pos_ + len, end_);
DCHECK_NE(Available(), -1);
DCHECK_LE(len, max_buffer_forward_);
......@@ -125,7 +125,7 @@ int MultiBufferReader::Wait(int64_t len, const base::Closure& cb) {
if (Available() >= current_wait_size_) {
return net::OK;
} else {
cb_ = cb;
cb_ = std::move(cb);
return net::ERR_IO_PENDING;
}
}
......@@ -155,8 +155,8 @@ void MultiBufferReader::CheckWait() {
}
}
void MultiBufferReader::Call(const base::Closure& cb) const {
cb.Run();
void MultiBufferReader::Call(base::OnceClosure cb) const {
std::move(cb).Run();
}
void MultiBufferReader::UpdateEnd(MultiBufferBlockId p) {
......
......@@ -71,7 +71,7 @@ class MEDIA_BLINK_EXPORT MultiBufferReader : public MultiBuffer::Reader {
// Returns net::OK if |len| bytes are already available, otherwise it will
// return net::ERR_IO_PENDING and call |cb| at some point later.
// |len| must be smaller or equal to max_buffer_forward.
int Wait(int64_t len, const base::Closure& cb);
int Wait(int64_t len, base::OnceClosure cb);
// Set how much data we try to preload into the cache ahead of our current
// location. Normally, we preload until we have preload_high bytes, then
......@@ -138,7 +138,7 @@ class MEDIA_BLINK_EXPORT MultiBufferReader : public MultiBuffer::Reader {
// Indirection function used to call callbacks. When we post a callback
// we indirect it through a weak_ptr and this function to make sure we
// don't call any callbacks after this object has been destroyed.
void Call(const base::Closure& cb) const;
void Call(base::OnceClosure cb) const;
// The multibuffer we're wrapping, not owned.
MultiBuffer* multibuffer_;
......@@ -179,7 +179,7 @@ class MEDIA_BLINK_EXPORT MultiBufferReader : public MultiBuffer::Reader {
// When Available() > current_wait_size_ we call cb_.
int64_t current_wait_size_;
base::Closure cb_;
base::OnceClosure cb_;
// Progress callback.
base::Callback<void(int64_t, int64_t)> progress_callback_;
......
......@@ -517,7 +517,7 @@ class ReadHelper {
read_size_ = std::min(1 + rnd_->Rand() % (max_read_size_ - 1), end_ - pos_);
if (!Read()) {
reader_.Wait(read_size_,
base::Bind(&ReadHelper::WaitCB, base::Unretained(this)));
base::BindOnce(&ReadHelper::WaitCB, base::Unretained(this)));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment