Commit 6c523d46 authored by Jose Lopes's avatar Jose Lopes Committed by Commit Bot

Replace base::Callback in multibuffer source.

The callback (init_cb_) is effectively called only once. This is guaranteed by the std::move():
https://cs.chromium.org/chromium/src/media/blink/multibuffer_data_source.cc?rcl=8d2d53d6df3c7347f9d4c32074540b990a8f1736&l=631

This is part of the base::Callback migration.

Context: https://cs.chromium.org/chromium/src/docs/callback.md?rcl=9fcc3764aea8f97e9f6de4a9ee61d554e67edcda&l=40
Change-Id: I1ba81f8b281339cf514baa7f6739425bb9b9988c
Bug: 714018
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2030962
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Auto-Submit: Jose Lopes <jabolopes@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741166}
parent d0c5a619
...@@ -190,12 +190,12 @@ void MultibufferDataSource::CreateResourceLoader_Locked( ...@@ -190,12 +190,12 @@ void MultibufferDataSource::CreateResourceLoader_Locked(
UpdateBufferSizes(); UpdateBufferSizes();
} }
void MultibufferDataSource::Initialize(const 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());
init_cb_ = init_cb; init_cb_ = std::move(init_cb);
CreateResourceLoader(0, kPositionNotSpecified); CreateResourceLoader(0, kPositionNotSpecified);
......
...@@ -66,8 +66,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource { ...@@ -66,8 +66,8 @@ class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
// Executes |init_cb| with the result of initialization when it has completed. // Executes |init_cb| with the result of initialization when it has completed.
// //
// Method called on the render thread. // Method called on the render thread.
typedef base::Callback<void(bool)> InitializeCB; using InitializeCB = base::OnceCallback<void(bool)>;
void Initialize(const InitializeCB& init_cb); void Initialize(InitializeCB init_cb);
// Adjusts the buffering algorithm based on the given preload value. // Adjusts the buffering algorithm based on the given preload value.
void SetPreload(Preload preload); void SetPreload(Preload preload);
......
...@@ -235,7 +235,7 @@ class MultibufferDataSourceTest : public testing::Test { ...@@ -235,7 +235,7 @@ class MultibufferDataSourceTest : public testing::Test {
response_generator_.reset(new TestResponseGenerator(gurl, file_size)); response_generator_.reset(new TestResponseGenerator(gurl, file_size));
EXPECT_CALL(*this, OnInitialize(expected)); EXPECT_CALL(*this, OnInitialize(expected));
data_source_->Initialize(base::Bind( data_source_->Initialize(base::BindOnce(
&MultibufferDataSourceTest::OnInitialize, base::Unretained(this))); &MultibufferDataSourceTest::OnInitialize, base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -1000,8 +1000,8 @@ TEST_F(MultibufferDataSourceTest, Http_ShareData) { ...@@ -1000,8 +1000,8 @@ 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::Bind(&MultibufferDataSourceTest::OnInitialize, source2.Initialize(base::BindOnce(&MultibufferDataSourceTest::OnInitialize,
base::Unretained(this))); base::Unretained(this)));
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
// Always loading after initialize. // Always loading after initialize.
...@@ -1362,8 +1362,8 @@ TEST_F(MultibufferDataSourceTest, SeekPastEOF) { ...@@ -1362,8 +1362,8 @@ TEST_F(MultibufferDataSourceTest, SeekPastEOF) {
response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1)); response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1));
EXPECT_CALL(*this, OnInitialize(true)); EXPECT_CALL(*this, OnInitialize(true));
data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, data_source_->Initialize(base::BindOnce(
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.
...@@ -1738,8 +1738,8 @@ TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) { ...@@ -1738,8 +1738,8 @@ TEST_F(MultibufferDataSourceTest, Http_CheckLoadingTransition) {
response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1)); response_generator_.reset(new TestResponseGenerator(gurl, kDataSize * 1));
EXPECT_CALL(*this, OnInitialize(true)); EXPECT_CALL(*this, OnInitialize(true));
data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, data_source_->Initialize(base::BindOnce(
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.
......
...@@ -733,7 +733,7 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type, ...@@ -733,7 +733,7 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type,
mb_data_source_->SetPreload(preload_); mb_data_source_->SetPreload(preload_);
mb_data_source_->SetIsClientAudioElement(client_->IsAudioElement()); mb_data_source_->SetIsClientAudioElement(client_->IsAudioElement());
mb_data_source_->Initialize( mb_data_source_->Initialize(
base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, weak_this_)); base::BindOnce(&WebMediaPlayerImpl::DataSourceInitialized, weak_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