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

Side by Side Diff: media/cdm/aes_decryptor.cc

Issue 448893002: Update ClearKey to support CDM_6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cdm6
Patch Set: rebase now that CDM_6 in Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cdm/aes_decryptor.h" 5 #include "media/cdm/aes_decryptor.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Returns whether the list is empty 47 // Returns whether the list is empty
48 bool Empty() const { return key_list_.empty(); } 48 bool Empty() const { return key_list_.empty(); }
49 49
50 // Returns the last inserted DecryptionKey. 50 // Returns the last inserted DecryptionKey.
51 DecryptionKey* LatestDecryptionKey() { 51 DecryptionKey* LatestDecryptionKey() {
52 DCHECK(!key_list_.empty()); 52 DCHECK(!key_list_.empty());
53 return key_list_.begin()->second; 53 return key_list_.begin()->second;
54 } 54 }
55 55
56 bool Contains(const std::string& web_session_id) {
57 return Find(web_session_id) != key_list_.end();
58 }
59
56 private: 60 private:
57 // Searches the list for an element with |web_session_id|. 61 // Searches the list for an element with |web_session_id|.
58 KeyList::iterator Find(const std::string& web_session_id); 62 KeyList::iterator Find(const std::string& web_session_id);
59 63
60 // Deletes the entry pointed to by |position|. 64 // Deletes the entry pointed to by |position|.
61 void Erase(KeyList::iterator position); 65 void Erase(KeyList::iterator position);
62 66
63 KeyList key_list_; 67 KeyList key_list_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(SessionIdDecryptionKeyMap); 69 DISALLOW_COPY_AND_ASSIGN(SessionIdDecryptionKeyMap);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (!new_audio_key_cb_.is_null()) 312 if (!new_audio_key_cb_.is_null())
309 new_audio_key_cb_.Run(); 313 new_audio_key_cb_.Run();
310 314
311 if (!new_video_key_cb_.is_null()) 315 if (!new_video_key_cb_.is_null())
312 new_video_key_cb_.Run(); 316 new_video_key_cb_.Run();
313 } 317 }
314 318
315 promise->resolve(); 319 promise->resolve();
316 } 320 }
317 321
322 void AesDecryptor::GetUsableKeyIds(const std::string& web_session_id,
323 scoped_ptr<KeyIdsPromise> promise) {
324 KeyIdsVector keyids;
325 base::AutoLock auto_lock(key_map_lock_);
326 for (KeyIdToSessionKeysMap::iterator it = key_map_.begin();
327 it != key_map_.end();
328 ++it) {
329 if (it->second->Contains(web_session_id))
330 keyids.push_back(std::vector<uint8>(it->first.begin(), it->first.end()));
331 }
332 promise->resolve(keyids);
333 }
334
318 void AesDecryptor::ReleaseSession(const std::string& web_session_id, 335 void AesDecryptor::ReleaseSession(const std::string& web_session_id,
319 scoped_ptr<SimpleCdmPromise> promise) { 336 scoped_ptr<SimpleCdmPromise> promise) {
320 // Validate that this is a reference to an active session and then forget it. 337 // Validate that this is a reference to an active session and then forget it.
321 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id); 338 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id);
322 // TODO(jrummell): Convert back to a DCHECK once prefixed EME is removed. 339 // TODO(jrummell): Convert back to a DCHECK once prefixed EME is removed.
323 if (it == valid_sessions_.end()) { 340 if (it == valid_sessions_.end()) {
324 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist."); 341 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist.");
325 return; 342 return;
326 } 343 }
327 344
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bool AesDecryptor::DecryptionKey::Init() { 504 bool AesDecryptor::DecryptionKey::Init() {
488 CHECK(!secret_.empty()); 505 CHECK(!secret_.empty());
489 decryption_key_.reset(crypto::SymmetricKey::Import( 506 decryption_key_.reset(crypto::SymmetricKey::Import(
490 crypto::SymmetricKey::AES, secret_)); 507 crypto::SymmetricKey::AES, secret_));
491 if (!decryption_key_) 508 if (!decryption_key_)
492 return false; 509 return false;
493 return true; 510 return true;
494 } 511 }
495 512
496 } // namespace media 513 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698