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 { ...@@ -46,7 +46,7 @@ class MEDIA_EXPORT Decryptor {
// Indicates that a new key has been added to the ContentDecryptionModule // Indicates that a new key has been added to the ContentDecryptionModule
// object associated with the Decryptor. // 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 // 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|. // decryptor. Only one NewKeyCB can be registered for one |stream_type|.
...@@ -55,7 +55,7 @@ class MEDIA_EXPORT Decryptor { ...@@ -55,7 +55,7 @@ class MEDIA_EXPORT Decryptor {
// registering a null callback cancels the originally registered callback. // registering a null callback cancels the originally registered callback.
// TODO(crbug.com/821288): Replace this with CdmContext::RegisterEventCB(). // TODO(crbug.com/821288): Replace this with CdmContext::RegisterEventCB().
virtual void RegisterNewKeyCB(StreamType stream_type, virtual void RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) = 0; NewKeyCB key_added_cb) = 0;
// Indicates completion of a decryption operation. // Indicates completion of a decryption operation.
// //
......
...@@ -489,7 +489,7 @@ class MockDecryptor : public Decryptor { ...@@ -489,7 +489,7 @@ class MockDecryptor : public Decryptor {
~MockDecryptor() override; ~MockDecryptor() override;
MOCK_METHOD2(RegisterNewKeyCB, MOCK_METHOD2(RegisterNewKeyCB,
void(StreamType stream_type, const NewKeyCB& new_key_cb)); void(StreamType stream_type, NewKeyCB new_key_cb));
MOCK_METHOD3(Decrypt, MOCK_METHOD3(Decrypt,
void(StreamType stream_type, void(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
......
...@@ -470,15 +470,15 @@ int AesDecryptor::GetCdmId() const { ...@@ -470,15 +470,15 @@ int AesDecryptor::GetCdmId() const {
} }
void AesDecryptor::RegisterNewKeyCB(StreamType stream_type, void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) { NewKeyCB new_key_cb) {
base::AutoLock auto_lock(new_key_cb_lock_); base::AutoLock auto_lock(new_key_cb_lock_);
switch (stream_type) { switch (stream_type) {
case kAudio: case kAudio:
new_audio_key_cb_ = new_key_cb; new_audio_key_cb_ = std::move(new_key_cb);
break; break;
case kVideo: case kVideo:
new_video_key_cb_ = new_key_cb; new_video_key_cb_ = std::move(new_key_cb);
break; break;
default: default:
NOTREACHED(); NOTREACHED();
......
...@@ -68,8 +68,7 @@ class MEDIA_EXPORT AesDecryptor : public ContentDecryptionModule, ...@@ -68,8 +68,7 @@ class MEDIA_EXPORT AesDecryptor : public ContentDecryptionModule,
int GetCdmId() const override; int GetCdmId() const override;
// Decryptor implementation. // Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type, void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) override;
const NewKeyCB& key_added_cb) override;
void Decrypt(StreamType stream_type, void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) override; const DecryptCB& decrypt_cb) override;
......
...@@ -438,15 +438,15 @@ int CdmAdapter::GetCdmId() const { ...@@ -438,15 +438,15 @@ int CdmAdapter::GetCdmId() const {
} }
void CdmAdapter::RegisterNewKeyCB(StreamType stream_type, void CdmAdapter::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) { NewKeyCB key_added_cb) {
DVLOG(3) << __func__; DVLOG(3) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
switch (stream_type) { switch (stream_type) {
case kAudio: case kAudio:
new_audio_key_cb_ = key_added_cb; new_audio_key_cb_ = std::move(key_added_cb);
return; return;
case kVideo: case kVideo:
new_video_key_cb_ = key_added_cb; new_video_key_cb_ = std::move(key_added_cb);
return; return;
} }
......
...@@ -97,8 +97,7 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule, ...@@ -97,8 +97,7 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
int GetCdmId() const final; int GetCdmId() const final;
// Decryptor implementation. // Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type, void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
const NewKeyCB& key_added_cb) final;
void Decrypt(StreamType stream_type, void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final; const DecryptCB& decrypt_cb) final;
......
...@@ -211,7 +211,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) { ...@@ -211,7 +211,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) {
new AudioTimestampHelper(config_.samples_per_second())); new AudioTimestampHelper(config_.samples_per_second()));
decryptor_->RegisterNewKeyCB( decryptor_->RegisterNewKeyCB(
Decryptor::kAudio, BindToCurrentLoop(base::Bind( Decryptor::kAudio, BindToCurrentLoop(base::BindRepeating(
&DecryptingAudioDecoder::OnKeyAdded, weak_this_))); &DecryptingAudioDecoder::OnKeyAdded, weak_this_)));
state_ = kIdle; state_ = kIdle;
......
...@@ -64,8 +64,8 @@ void DecryptingDemuxerStream::Initialize(DemuxerStream* stream, ...@@ -64,8 +64,8 @@ void DecryptingDemuxerStream::Initialize(DemuxerStream* stream,
decryptor_->RegisterNewKeyCB( decryptor_->RegisterNewKeyCB(
GetDecryptorStreamType(), GetDecryptorStreamType(),
BindToCurrentLoop( BindToCurrentLoop(base::BindRepeating(
base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_))); &DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
state_ = kIdle; state_ = kIdle;
std::move(init_cb_).Run(PIPELINE_OK); std::move(init_cb_).Run(PIPELINE_OK);
......
...@@ -192,7 +192,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) { ...@@ -192,7 +192,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) {
} }
decryptor_->RegisterNewKeyCB( decryptor_->RegisterNewKeyCB(
Decryptor::kVideo, BindToCurrentLoop(base::Bind( Decryptor::kVideo, BindToCurrentLoop(base::BindRepeating(
&DecryptingVideoDecoder::OnKeyAdded, weak_this_))); &DecryptingVideoDecoder::OnKeyAdded, weak_this_)));
// Success! // Success!
......
...@@ -28,12 +28,12 @@ FuchsiaDecryptor::~FuchsiaDecryptor() { ...@@ -28,12 +28,12 @@ FuchsiaDecryptor::~FuchsiaDecryptor() {
} }
void FuchsiaDecryptor::RegisterNewKeyCB(StreamType stream_type, void FuchsiaDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) { NewKeyCB new_key_cb) {
if (stream_type != kAudio) if (stream_type != kAudio)
return; return;
base::AutoLock auto_lock(new_key_cb_lock_); 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, void FuchsiaDecryptor::Decrypt(StreamType stream_type,
...@@ -99,7 +99,7 @@ bool FuchsiaDecryptor::CanAlwaysDecrypt() { ...@@ -99,7 +99,7 @@ bool FuchsiaDecryptor::CanAlwaysDecrypt() {
void FuchsiaDecryptor::OnNewKey() { void FuchsiaDecryptor::OnNewKey() {
base::AutoLock auto_lock(new_key_cb_lock_); base::AutoLock auto_lock(new_key_cb_lock_);
if (new_key_cb_) if (new_key_cb_)
new_key_cb_.Run(); std::move(new_key_cb_).Run();
} }
} // namespace media } // namespace media
...@@ -33,8 +33,7 @@ class FuchsiaDecryptor : public Decryptor { ...@@ -33,8 +33,7 @@ class FuchsiaDecryptor : public Decryptor {
~FuchsiaDecryptor() override; ~FuchsiaDecryptor() override;
// media::Decryptor implementation: // media::Decryptor implementation:
void RegisterNewKeyCB(StreamType stream_type, void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) override;
const NewKeyCB& key_added_cb) override;
void Decrypt(StreamType stream_type, void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) override; const DecryptCB& decrypt_cb) override;
......
...@@ -141,7 +141,7 @@ D3D11Decryptor::D3D11Decryptor(CdmProxyContext* cdm_proxy_context) ...@@ -141,7 +141,7 @@ D3D11Decryptor::D3D11Decryptor(CdmProxyContext* cdm_proxy_context)
D3D11Decryptor::~D3D11Decryptor() {} D3D11Decryptor::~D3D11Decryptor() {}
void D3D11Decryptor::RegisterNewKeyCB(StreamType stream_type, 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 // TODO(crbug.com/821288): Use RegisterNewKeyCB() on CdmContext, and remove
// RegisterNewKeyCB from Decryptor interface. // RegisterNewKeyCB from Decryptor interface.
NOTREACHED(); NOTREACHED();
......
...@@ -23,8 +23,7 @@ class MEDIA_GPU_EXPORT D3D11Decryptor : public Decryptor { ...@@ -23,8 +23,7 @@ class MEDIA_GPU_EXPORT D3D11Decryptor : public Decryptor {
~D3D11Decryptor() final; ~D3D11Decryptor() final;
// Decryptor implementation. // Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type, void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
const NewKeyCB& key_added_cb) final;
void Decrypt(StreamType stream_type, void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final; const DecryptCB& decrypt_cb) final;
......
...@@ -91,14 +91,14 @@ MojoDecryptor::~MojoDecryptor() { ...@@ -91,14 +91,14 @@ MojoDecryptor::~MojoDecryptor() {
} }
void MojoDecryptor::RegisterNewKeyCB(StreamType stream_type, void MojoDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& key_added_cb) { NewKeyCB key_added_cb) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
switch (stream_type) { switch (stream_type) {
case kAudio: case kAudio:
new_audio_key_cb_ = key_added_cb; new_audio_key_cb_ = std::move(key_added_cb);
break; break;
case kVideo: case kVideo:
new_video_key_cb_ = key_added_cb; new_video_key_cb_ = std::move(key_added_cb);
break; break;
default: default:
NOTREACHED(); NOTREACHED();
......
...@@ -34,8 +34,7 @@ class MojoDecryptor : public Decryptor { ...@@ -34,8 +34,7 @@ class MojoDecryptor : public Decryptor {
~MojoDecryptor() final; ~MojoDecryptor() final;
// Decryptor implementation. // Decryptor implementation.
void RegisterNewKeyCB(StreamType stream_type, void RegisterNewKeyCB(StreamType stream_type, NewKeyCB key_added_cb) final;
const NewKeyCB& key_added_cb) final;
void Decrypt(StreamType stream_type, void Decrypt(StreamType stream_type,
scoped_refptr<DecoderBuffer> encrypted, scoped_refptr<DecoderBuffer> encrypted,
const DecryptCB& decrypt_cb) final; 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