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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « media/cast/test/utility/udp_proxy_main.cc ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8
9 #include <list> 8 #include <list>
9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "crypto/encryptor.h" 16 #include "crypto/encryptor.h"
17 #include "crypto/symmetric_key.h" 17 #include "crypto/symmetric_key.h"
18 #include "media/base/audio_decoder_config.h" 18 #include "media/base/audio_decoder_config.h"
19 #include "media/base/cdm_key_information.h" 19 #include "media/base/cdm_key_information.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 { 389 {
390 base::AutoLock auto_lock(key_map_lock_); 390 base::AutoLock auto_lock(key_map_lock_);
391 for (const auto& item : key_map_) { 391 for (const auto& item : key_map_) {
392 if (item.second->Contains(session_id)) { 392 if (item.second->Contains(session_id)) {
393 keys_info.push_back( 393 keys_info.push_back(
394 new CdmKeyInformation(item.first, CdmKeyInformation::USABLE, 0)); 394 new CdmKeyInformation(item.first, CdmKeyInformation::USABLE, 0));
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 session_keys_change_cb_.Run(session_id, key_added, keys_info.Pass()); 399 session_keys_change_cb_.Run(session_id, key_added, std::move(keys_info));
400 } 400 }
401 401
402 void AesDecryptor::CloseSession(const std::string& session_id, 402 void AesDecryptor::CloseSession(const std::string& session_id,
403 scoped_ptr<SimpleCdmPromise> promise) { 403 scoped_ptr<SimpleCdmPromise> promise) {
404 // Validate that this is a reference to an active session and then forget it. 404 // Validate that this is a reference to an active session and then forget it.
405 std::set<std::string>::iterator it = valid_sessions_.find(session_id); 405 std::set<std::string>::iterator it = valid_sessions_.find(session_id);
406 DCHECK(it != valid_sessions_.end()); 406 DCHECK(it != valid_sessions_.end());
407 407
408 valid_sessions_.erase(it); 408 valid_sessions_.erase(it);
409 409
410 // Close the session. 410 // Close the session.
411 DeleteKeysForSession(session_id); 411 DeleteKeysForSession(session_id);
412 promise->resolve(); 412 promise->resolve();
413 session_closed_cb_.Run(session_id); 413 session_closed_cb_.Run(session_id);
414 } 414 }
415 415
416 void AesDecryptor::RemoveSession(const std::string& session_id, 416 void AesDecryptor::RemoveSession(const std::string& session_id,
417 scoped_ptr<SimpleCdmPromise> promise) { 417 scoped_ptr<SimpleCdmPromise> promise) {
418 // AesDecryptor doesn't keep any persistent data, so this should be 418 // AesDecryptor doesn't keep any persistent data, so this should be
419 // NOT_REACHED(). 419 // NOT_REACHED().
420 // TODO(jrummell): Make sure persistent session types are rejected. 420 // TODO(jrummell): Make sure persistent session types are rejected.
421 // http://crbug.com/384152. 421 // http://crbug.com/384152.
422 // 422 //
423 // However, v0.1b calls to CancelKeyRequest() will call this, so close the 423 // However, v0.1b calls to CancelKeyRequest() will call this, so close the
424 // session, if it exists. 424 // session, if it exists.
425 // TODO(jrummell): Remove the close() call when prefixed EME is removed. 425 // TODO(jrummell): Remove the close() call when prefixed EME is removed.
426 // http://crbug.com/249976. 426 // http://crbug.com/249976.
427 if (valid_sessions_.find(session_id) != valid_sessions_.end()) { 427 if (valid_sessions_.find(session_id) != valid_sessions_.end()) {
428 CloseSession(session_id, promise.Pass()); 428 CloseSession(session_id, std::move(promise));
429 return; 429 return;
430 } 430 }
431 431
432 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist."); 432 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist.");
433 } 433 }
434 434
435 CdmContext* AesDecryptor::GetCdmContext() { 435 CdmContext* AesDecryptor::GetCdmContext() {
436 return this; 436 return this;
437 } 437 }
438 438
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 const std::string& key_string) { 537 const std::string& key_string) {
538 scoped_ptr<DecryptionKey> decryption_key(new DecryptionKey(key_string)); 538 scoped_ptr<DecryptionKey> decryption_key(new DecryptionKey(key_string));
539 if (!decryption_key->Init()) { 539 if (!decryption_key->Init()) {
540 DVLOG(1) << "Could not initialize decryption key."; 540 DVLOG(1) << "Could not initialize decryption key.";
541 return false; 541 return false;
542 } 542 }
543 543
544 base::AutoLock auto_lock(key_map_lock_); 544 base::AutoLock auto_lock(key_map_lock_);
545 KeyIdToSessionKeysMap::iterator key_id_entry = key_map_.find(key_id); 545 KeyIdToSessionKeysMap::iterator key_id_entry = key_map_.find(key_id);
546 if (key_id_entry != key_map_.end()) { 546 if (key_id_entry != key_map_.end()) {
547 key_id_entry->second->Insert(session_id, decryption_key.Pass()); 547 key_id_entry->second->Insert(session_id, std::move(decryption_key));
548 return true; 548 return true;
549 } 549 }
550 550
551 // |key_id| not found, so need to create new entry. 551 // |key_id| not found, so need to create new entry.
552 scoped_ptr<SessionIdDecryptionKeyMap> inner_map( 552 scoped_ptr<SessionIdDecryptionKeyMap> inner_map(
553 new SessionIdDecryptionKeyMap()); 553 new SessionIdDecryptionKeyMap());
554 inner_map->Insert(session_id, decryption_key.Pass()); 554 inner_map->Insert(session_id, std::move(decryption_key));
555 key_map_.add(key_id, inner_map.Pass()); 555 key_map_.add(key_id, std::move(inner_map));
556 return true; 556 return true;
557 } 557 }
558 558
559 AesDecryptor::DecryptionKey* AesDecryptor::GetKey_Locked( 559 AesDecryptor::DecryptionKey* AesDecryptor::GetKey_Locked(
560 const std::string& key_id) const { 560 const std::string& key_id) const {
561 key_map_lock_.AssertAcquired(); 561 key_map_lock_.AssertAcquired();
562 KeyIdToSessionKeysMap::const_iterator key_id_found = key_map_.find(key_id); 562 KeyIdToSessionKeysMap::const_iterator key_id_found = key_map_.find(key_id);
563 if (key_id_found == key_map_.end()) 563 if (key_id_found == key_map_.end())
564 return NULL; 564 return NULL;
565 565
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 bool AesDecryptor::DecryptionKey::Init() { 607 bool AesDecryptor::DecryptionKey::Init() {
608 CHECK(!secret_.empty()); 608 CHECK(!secret_.empty());
609 decryption_key_.reset(crypto::SymmetricKey::Import( 609 decryption_key_.reset(crypto::SymmetricKey::Import(
610 crypto::SymmetricKey::AES, secret_)); 610 crypto::SymmetricKey::AES, secret_));
611 if (!decryption_key_) 611 if (!decryption_key_)
612 return false; 612 return false;
613 return true; 613 return true;
614 } 614 }
615 615
616 } // namespace media 616 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/utility/udp_proxy_main.cc ('k') | media/cdm/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698