Commit 82fd87a4 authored by Jose Lopes's avatar Jose Lopes Committed by Commit Bot

Migrate new key callback.

This callback is meant to be called every time a new key is registered,
thus it must be a repeating callback, as documented in:
https://cs.chromium.org/chromium/src/media/base/decryptor.h?rcl=502d7a8bc634c4248b7cc2f43e2305eee7213d94&l=51

This is part of the base::Callback migration.

Context: https://cs.chromium.org/chromium/src/docs/callback.md?rcl=9fcc3764aea8f97e9f6de4a9ee61d554e67edcda&l=40

Bug: 714018
Change-Id: Ib852f03ab2f862d02d0e09be95626090cee60d75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035960
Commit-Queue: Jose Lopes <jabolopes@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743063}
parent 40478e29
......@@ -46,7 +46,7 @@ class MEDIA_EXPORT Decryptor {
// Indicates that a new key has been added to the ContentDecryptionModule
// object associated with the Decryptor.
typedef base::Callback<void()> NewKeyCB;
using NewKeyCB = base::RepeatingClosure;
// Registers a NewKeyCB which should be called when a new key is added to the
// decryptor. Only one NewKeyCB can be registered for one |stream_type|.
......@@ -55,7 +55,7 @@ class MEDIA_EXPORT Decryptor {
// registering a null callback cancels the originally registered callback.
// TODO(crbug.com/821288): Replace this with CdmContext::RegisterEventCB().
virtual void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) = 0;
NewKeyCB key_added_cb) = 0;
// Indicates completion of a decryption operation.
//
......
......@@ -489,7 +489,7 @@ class MockDecryptor : public Decryptor {
~MockDecryptor() override;
MOCK_METHOD2(RegisterNewKeyCB,
void(StreamType stream_type, const NewKeyCB& new_key_cb));
void(StreamType stream_type, NewKeyCB new_key_cb));
MOCK_METHOD3(Decrypt,
void(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
......
......@@ -470,15 +470,15 @@ int AesDecryptor::GetCdmId() const {
}
void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) {
NewKeyCB new_key_cb) {
base::AutoLock auto_lock(new_key_cb_lock_);
switch (stream_type) {
case kAudio:
new_audio_key_cb_ = new_key_cb;
new_audio_key_cb_ = std::move(new_key_cb);
break;
case kVideo:
new_video_key_cb_ = new_key_cb;
new_video_key_cb_ = std::move(new_key_cb);
break;
default:
NOTREACHED();
......
......@@ -68,8 +68,7 @@ class MEDIA_EXPORT AesDecryptor : public ContentDecryptionModule,
int GetCdmId() const override;
// Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) override;
void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) override;
void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) override;
......
......@@ -438,15 +438,15 @@ int CdmAdapter::GetCdmId() const {
}
void CdmAdapter::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) {
NewKeyCB key_added_cb) {
DVLOG(3) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
switch (stream_type) {
case kAudio:
new_audio_key_cb_ = key_added_cb;
new_audio_key_cb_ = std::move(key_added_cb);
return;
case kVideo:
new_video_key_cb_ = key_added_cb;
new_video_key_cb_ = std::move(key_added_cb);
return;
}
......
......@@ -97,8 +97,7 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
int GetCdmId() const final;
// Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) final;
void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final;
......
......@@ -211,7 +211,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) {
new AudioTimestampHelper(config_.samples_per_second()));
decryptor_->RegisterNewKeyCB(
Decryptor::kAudio, BindToCurrentLoop(base::Bind(
Decryptor::kAudio, BindToCurrentLoop(base::BindRepeating(
&DecryptingAudioDecoder::OnKeyAdded, weak_this_)));
state_ = kIdle;
......
......@@ -64,8 +64,8 @@ void DecryptingDemuxerStream::Initialize(DemuxerStream* stream,
decryptor_->RegisterNewKeyCB(
GetDecryptorStreamType(),
BindToCurrentLoop(
base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
BindToCurrentLoop(base::BindRepeating(
&DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
state_ = kIdle;
std::move(init_cb_).Run(PIPELINE_OK);
......
......@@ -192,7 +192,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) {
}
decryptor_->RegisterNewKeyCB(
Decryptor::kVideo, BindToCurrentLoop(base::Bind(
Decryptor::kVideo, BindToCurrentLoop(base::BindRepeating(
&DecryptingVideoDecoder::OnKeyAdded, weak_this_)));
// Success!
......
......@@ -28,12 +28,12 @@ FuchsiaDecryptor::~FuchsiaDecryptor() {
}
void FuchsiaDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) {
NewKeyCB new_key_cb) {
if (stream_type != kAudio)
return;
base::AutoLock auto_lock(new_key_cb_lock_);
new_key_cb_ = new_key_cb;
new_key_cb_ = std::move(new_key_cb);
}
void FuchsiaDecryptor::Decrypt(StreamType stream_type,
......@@ -99,7 +99,7 @@ bool FuchsiaDecryptor::CanAlwaysDecrypt() {
void FuchsiaDecryptor::OnNewKey() {
base::AutoLock auto_lock(new_key_cb_lock_);
if (new_key_cb_)
new_key_cb_.Run();
std::move(new_key_cb_).Run();
}
} // namespace media
......@@ -33,8 +33,7 @@ class FuchsiaDecryptor : public Decryptor {
~FuchsiaDecryptor() override;
// media::Decryptor implementation:
void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) override;
void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) override;
void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) override;
......
......@@ -141,7 +141,7 @@ D3D11Decryptor::D3D11Decryptor(CdmProxyContext* cdm_proxy_context)
D3D11Decryptor::~D3D11Decryptor() {}
void D3D11Decryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) {
NewKeyCB new_key_cb) {
// TODO(crbug.com/821288): Use RegisterNewKeyCB() on CdmContext, and remove
// RegisterNewKeyCB from Decryptor interface.
NOTREACHED();
......
......@@ -23,8 +23,7 @@ class MEDIA_GPU_EXPORT D3D11Decryptor : public Decryptor {
~D3D11Decryptor() final;
// Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) final;
void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final;
......
......@@ -91,14 +91,14 @@ MojoDecryptor::~MojoDecryptor() {
}
void MojoDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) {
NewKeyCB key_added_cb) {
DCHECK(thread_checker_.CalledOnValidThread());
switch (stream_type) {
case kAudio:
new_audio_key_cb_ = key_added_cb;
new_audio_key_cb_ = std::move(key_added_cb);
break;
case kVideo:
new_video_key_cb_ = key_added_cb;
new_video_key_cb_ = std::move(key_added_cb);
break;
default:
NOTREACHED();
......
......@@ -34,8 +34,7 @@ class MojoDecryptor : public Decryptor {
~MojoDecryptor() final;
// Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) final;
void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final;
......
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