| Index: webkit/media/crypto/proxy_decryptor.h
|
| diff --git a/webkit/media/crypto/proxy_decryptor.h b/webkit/media/crypto/proxy_decryptor.h
|
| index 61360ebaceb5f33235cdef782ae9d719ba2bf6a7..a4638af01967c2e0d1c5a7255e12b1c56d46147b 100644
|
| --- a/webkit/media/crypto/proxy_decryptor.h
|
| +++ b/webkit/media/crypto/proxy_decryptor.h
|
| @@ -6,11 +6,16 @@
|
| #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "media/base/decryptor.h"
|
|
|
| +namespace base {
|
| +class MessageLoopProxy;
|
| +}
|
| +
|
| namespace media {
|
| class DecryptorClient;
|
| }
|
| @@ -33,6 +38,10 @@ class ProxyDecryptor : public media::Decryptor {
|
| WebKit::WebFrame* web_frame);
|
| virtual ~ProxyDecryptor();
|
|
|
| + void set_decryptor_for_testing(scoped_ptr<media::Decryptor> decryptor) {
|
| + decryptor_ = decryptor.Pass();
|
| + }
|
| +
|
| // media::Decryptor implementation.
|
| virtual void GenerateKeyRequest(const std::string& key_system,
|
| const uint8* init_data,
|
| @@ -47,26 +56,40 @@ class ProxyDecryptor : public media::Decryptor {
|
| const std::string& session_id) OVERRIDE;
|
| virtual void Decrypt(const scoped_refptr<media::DecoderBuffer>& encrypted,
|
| const DecryptCB& decrypt_cb) OVERRIDE;
|
| + virtual void Stop() OVERRIDE;
|
|
|
| private:
|
| scoped_ptr<media::Decryptor> CreatePpapiDecryptor(
|
| const std::string& key_system);
|
| scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system);
|
|
|
| + // Helper function that makes sure decryptor_->Decrypt() runs on the
|
| + // |message_loop|.
|
| + void DecryptOnMessageLoop(
|
| + const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
|
| + const scoped_refptr<media::DecoderBuffer>& encrypted,
|
| + const media::Decryptor::DecryptCB& decrypt_cb);
|
| +
|
| + // Callback used to pass into decryptor_->Decrypt().
|
| + void OnBufferDecrypted(
|
| + const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
|
| + const scoped_refptr<media::DecoderBuffer>& encrypted,
|
| + const media::Decryptor::DecryptCB& decrypt_cb,
|
| + media::Decryptor::DecryptStatus status,
|
| + const scoped_refptr<media::DecoderBuffer>& decrypted);
|
| +
|
| media::DecryptorClient* client_;
|
|
|
| // Needed to create the PpapiDecryptor.
|
| WebKit::WebMediaPlayerClient* web_media_player_client_;
|
| WebKit::WebFrame* web_frame_;
|
|
|
| - // Protects the |decryptor_|. The Decryptor interface specifies that the
|
| - // Decrypt() function will be called on the decoder thread and all other
|
| - // methods on the renderer thread. The |decryptor_| itself is thread safe
|
| - // when this rule is obeyed. This lock is solely to prevent the race condition
|
| - // between setting the |decryptor_| in GenerateKeyRequest() and using it in
|
| - // Decrypt().
|
| + // Protects the |decryptor_| and |pending_decrypt_closures_|. Note that
|
| + // |decryptor_| itself should be thread safe as per the Decryptor interface.
|
| base::Lock lock_;
|
| - scoped_ptr<media::Decryptor> decryptor_; // Protected by the |lock_|.
|
| + scoped_ptr<media::Decryptor> decryptor_;
|
| + std::vector<base::Closure> pending_decrypt_closures_;
|
| + bool stopped_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
|
| };
|
|
|