From 6a20673eac5bd4b1c661ed1ee14fc1667adfdfa6 Mon Sep 17 00:00:00 2001 From: "xhwang@chromium.org" Date: Wed, 29 Aug 2012 01:14:40 +0000 Subject: Add a bool return value to media::Decryptor::GenerateKeyRequest(). Add a bool return value in media::Decryptor::GenerateKeyRequest() call and add code in WebMeidaPlayerImpl to check this value. If GenerateKeyRequest() fails, prevent further calls to AddKey() and CancelKeyRequest(). BUG=145322 TEST=Called AddKey() after GenerateKeyRequest() fails and no crash. Review URL: https://chromiumcodereview.appspot.com/10896014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153818 0039d316-1c4b-4281-b951-d872f2087c98 --- media/crypto/aes_decryptor.cc | 3 ++- media/crypto/aes_decryptor.h | 2 +- media/crypto/aes_decryptor_unittest.cc | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'media/crypto') diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc index bbeab8c..777d79f 100644 --- a/media/crypto/aes_decryptor.cc +++ b/media/crypto/aes_decryptor.cc @@ -195,7 +195,7 @@ AesDecryptor::~AesDecryptor() { STLDeleteValues(&key_map_); } -void AesDecryptor::GenerateKeyRequest(const std::string& key_system, +bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, const uint8* init_data, int init_data_length) { std::string session_id_string(base::UintToString(next_session_id_++)); @@ -207,6 +207,7 @@ void AesDecryptor::GenerateKeyRequest(const std::string& key_system, client_->KeyMessage(key_system, session_id_string, message.Pass(), message_length, ""); + return true; } void AesDecryptor::AddKey(const std::string& key_system, diff --git a/media/crypto/aes_decryptor.h b/media/crypto/aes_decryptor.h index 0c96efc..d86d4bc 100644 --- a/media/crypto/aes_decryptor.h +++ b/media/crypto/aes_decryptor.h @@ -35,7 +35,7 @@ class MEDIA_EXPORT AesDecryptor : public Decryptor { virtual ~AesDecryptor(); // Decryptor implementation. - virtual void GenerateKeyRequest(const std::string& key_system, + virtual bool GenerateKeyRequest(const std::string& key_system, const uint8* init_data, int init_data_length) OVERRIDE; virtual void AddKey(const std::string& key_system, diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc index 373dd4b..95472f1 100644 --- a/media/crypto/aes_decryptor_unittest.cc +++ b/media/crypto/aes_decryptor_unittest.cc @@ -256,7 +256,8 @@ class AesDecryptorTest : public testing::Test { EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(std::string()), NotNull(), Gt(0), "")) .WillOnce(SaveArg<1>(&session_id_string_)); - decryptor_.GenerateKeyRequest(kClearKeySystem, key_id, key_id_size); + EXPECT_TRUE(decryptor_.GenerateKeyRequest(kClearKeySystem, + key_id, key_id_size)); } void AddKeyAndExpectToSucceed(const uint8* key_id, int key_id_size, -- cgit v1.1