Commit 3f19db7c authored by jrummell@chromium.org's avatar jrummell@chromium.org

AesDecryptor callbacks now used in a thread-safe manner

Add lock around use of callbacks.

BUG=329530
TEST=browser_tests for encrypted media pass
TBR=glider

Review URL: https://codereview.chromium.org/105933004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244056 0039d316-1c4b-4281-b951-d872f2087c98
parent a852ff2f
...@@ -285,11 +285,15 @@ void AesDecryptor::UpdateSession(uint32 session_id, ...@@ -285,11 +285,15 @@ void AesDecryptor::UpdateSession(uint32 session_id,
} }
} }
if (!new_audio_key_cb_.is_null()) {
new_audio_key_cb_.Run(); base::AutoLock auto_lock(new_key_cb_lock_);
if (!new_video_key_cb_.is_null()) if (!new_audio_key_cb_.is_null())
new_video_key_cb_.Run(); new_audio_key_cb_.Run();
if (!new_video_key_cb_.is_null())
new_video_key_cb_.Run();
}
session_ready_cb_.Run(session_id); session_ready_cb_.Run(session_id);
} }
...@@ -310,6 +314,8 @@ Decryptor* AesDecryptor::GetDecryptor() { ...@@ -310,6 +314,8 @@ Decryptor* AesDecryptor::GetDecryptor() {
void AesDecryptor::RegisterNewKeyCB(StreamType stream_type, void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) { const NewKeyCB& new_key_cb) {
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_ = new_key_cb;
......
...@@ -135,6 +135,10 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { ...@@ -135,6 +135,10 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
NewKeyCB new_audio_key_cb_; NewKeyCB new_audio_key_cb_;
NewKeyCB new_video_key_cb_; NewKeyCB new_video_key_cb_;
// Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the
// main thread but called on the media thread.
mutable base::Lock new_key_cb_lock_;
DISALLOW_COPY_AND_ASSIGN(AesDecryptor); DISALLOW_COPY_AND_ASSIGN(AesDecryptor);
}; };
......
...@@ -161,9 +161,6 @@ race:blink::currentTimeFunction ...@@ -161,9 +161,6 @@ race:blink::currentTimeFunction
# http://crbug.com/329460 # http://crbug.com/329460
race:extensions::InfoMap::AddExtension race:extensions::InfoMap::AddExtension
# http://crbug.com/329530
race:media::AesDecryptor::UpdateSession
# http://crbug.com/330528 # http://crbug.com/330528
race:v8::internal::MarkCompactCollector::SweepInParallel race:v8::internal::MarkCompactCollector::SweepInParallel
......
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