Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1218)

Unified Diff: media/cdm/aes_decryptor.cc

Issue 1002193005: Properly determine if a new key was added in AesDecryptor::Update() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix pipeline test Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cdm/aes_decryptor.h ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/aes_decryptor.cc
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index 1506f7fc32b2b9f736837fdf659f995fd8d96ce0..2468c748b5f7b725e20691218218d7212475be95 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -334,6 +334,7 @@ void AesDecryptor::UpdateSession(const std::string& session_id,
return;
}
+ bool key_added = false;
for (KeyIdAndKeyPairs::iterator it = keys.begin(); it != keys.end(); ++it) {
if (it->second.length() !=
static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) {
@@ -341,6 +342,12 @@ void AesDecryptor::UpdateSession(const std::string& session_id,
promise->reject(INVALID_ACCESS_ERROR, 0, "Invalid key length.");
return;
}
+
+ // If this key_id doesn't currently exist in this session,
+ // a new key is added.
+ if (!HasKey(session_id, it->first))
+ key_added = true;
+
if (!AddDecryptionKey(session_id, it->first, it->second)) {
promise->reject(INVALID_ACCESS_ERROR, 0, "Unable to add key.");
return;
@@ -374,9 +381,7 @@ void AesDecryptor::UpdateSession(const std::string& session_id,
}
}
- // Assume that at least 1 new key has been successfully added and thus
- // sending true for |has_additional_usable_key|. http://crbug.com/448219.
- session_keys_change_cb_.Run(session_id, true, keys_info.Pass());
+ session_keys_change_cb_.Run(session_id, key_added, keys_info.Pass());
}
void AesDecryptor::CloseSession(const std::string& session_id,
@@ -546,6 +551,16 @@ AesDecryptor::DecryptionKey* AesDecryptor::GetKey(
return key_id_found->second->LatestDecryptionKey();
}
+bool AesDecryptor::HasKey(const std::string& session_id,
+ const std::string& key_id) {
+ base::AutoLock auto_lock(key_map_lock_);
+ KeyIdToSessionKeysMap::const_iterator key_id_found = key_map_.find(key_id);
+ if (key_id_found == key_map_.end())
+ return false;
+
+ return key_id_found->second->Contains(session_id);
+}
+
void AesDecryptor::DeleteKeysForSession(const std::string& session_id) {
base::AutoLock auto_lock(key_map_lock_);
« no previous file with comments | « media/cdm/aes_decryptor.h ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698