Commit f9006b3b authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

[Code Health] NewExpectedClosure is OnceClosure

NewExpectedClosure returns a base::OnceClosure now and
NewExpectedBoolCB returns a base::OnceCallback.

Bug: 1007799
Change-Id: Ic0fbcbd1b70c1e81920efdf095ba89d6f905c37f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972816Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726230}
parent 65b6a35e
...@@ -45,16 +45,16 @@ class MockCallback : public base::RefCountedThreadSafe<MockCallback> { ...@@ -45,16 +45,16 @@ class MockCallback : public base::RefCountedThreadSafe<MockCallback> {
MockCallback::MockCallback() = default; MockCallback::MockCallback() = default;
MockCallback::~MockCallback() = default; MockCallback::~MockCallback() = default;
base::Closure NewExpectedClosure() { base::OnceClosure NewExpectedClosure() {
StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
EXPECT_CALL(*callback, Run()); EXPECT_CALL(*callback, Run());
return base::Bind(&MockCallback::Run, WrapRefCounted(callback)); return base::BindOnce(&MockCallback::Run, WrapRefCounted(callback));
} }
base::Callback<void(bool)> NewExpectedBoolCB(bool success) { base::OnceCallback<void(bool)> NewExpectedBoolCB(bool success) {
StrictMock<MockCallback>* callback = new StrictMock<MockCallback>(); StrictMock<MockCallback>* callback = new StrictMock<MockCallback>();
EXPECT_CALL(*callback, RunWithBool(success)); EXPECT_CALL(*callback, RunWithBool(success));
return base::Bind(&MockCallback::RunWithBool, WrapRefCounted(callback)); return base::BindOnce(&MockCallback::RunWithBool, WrapRefCounted(callback));
} }
PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) {
......
...@@ -36,8 +36,8 @@ class DecoderBuffer; ...@@ -36,8 +36,8 @@ class DecoderBuffer;
class MockDemuxerStream; class MockDemuxerStream;
// Return a callback that expects to be run once. // Return a callback that expects to be run once.
base::Closure NewExpectedClosure(); base::OnceClosure NewExpectedClosure();
base::Callback<void(bool)> NewExpectedBoolCB(bool success); base::OnceCallback<void(bool)> NewExpectedBoolCB(bool success);
PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); PipelineStatusCB NewExpectedStatusCB(PipelineStatus status);
// Helper class for running a message loop until a callback has run. Useful for // Helper class for running a message loop until a callback has run. Useful for
......
...@@ -88,13 +88,13 @@ bool DecryptingDemuxerStream::IsReadPending() const { ...@@ -88,13 +88,13 @@ bool DecryptingDemuxerStream::IsReadPending() const {
return !read_cb_.is_null(); return !read_cb_.is_null();
} }
void DecryptingDemuxerStream::Reset(const base::Closure& closure) { void DecryptingDemuxerStream::Reset(base::OnceClosure closure) {
DVLOG(2) << __func__ << " - state: " << state_; DVLOG(2) << __func__ << " - state: " << state_;
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ != kUninitialized) << state_; DCHECK(state_ != kUninitialized) << state_;
DCHECK(!reset_cb_); DCHECK(!reset_cb_);
reset_cb_ = BindToCurrentLoop(closure); reset_cb_ = BindToCurrentLoop(std::move(closure));
decryptor_->CancelDecrypt(GetDecryptorStreamType()); decryptor_->CancelDecrypt(GetDecryptorStreamType());
......
...@@ -49,7 +49,7 @@ class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream { ...@@ -49,7 +49,7 @@ class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream {
// kPendingDemuxerRead or kPendingDecrypt state, waits for the pending // kPendingDemuxerRead or kPendingDecrypt state, waits for the pending
// operation to finish before satisfying |closure|. Sets the state to // operation to finish before satisfying |closure|. Sets the state to
// kUninitialized if |this| hasn't been initialized, or to kIdle otherwise. // kUninitialized if |this| hasn't been initialized, or to kIdle otherwise.
void Reset(const base::Closure& closure); void Reset(base::OnceClosure closure);
// Returns the name of this class for logging purpose. // Returns the name of this class for logging purpose.
std::string GetDisplayName() const; std::string GetDisplayName() const;
...@@ -151,7 +151,7 @@ class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream { ...@@ -151,7 +151,7 @@ class MEDIA_EXPORT DecryptingDemuxerStream : public DemuxerStream {
PipelineStatusCB init_cb_; PipelineStatusCB init_cb_;
ReadCB read_cb_; ReadCB read_cb_;
base::Closure reset_cb_; base::OnceClosure reset_cb_;
// Pointer to the input demuxer stream that will feed us encrypted buffers. // Pointer to the input demuxer stream that will feed us encrypted buffers.
DemuxerStream* demuxer_stream_ = nullptr; DemuxerStream* demuxer_stream_ = nullptr;
......
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