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

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

Issue 2446993003: EME Clear Key: Run Session Closed algorithm before resolving returned promise (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp » ('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 #include <list> 8 #include <list>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (item.second->Contains(session_id)) { 389 if (item.second->Contains(session_id)) {
390 keys_info.push_back( 390 keys_info.push_back(
391 new CdmKeyInformation(item.first, CdmKeyInformation::USABLE, 0)); 391 new CdmKeyInformation(item.first, CdmKeyInformation::USABLE, 0));
392 } 392 }
393 } 393 }
394 } 394 }
395 395
396 session_keys_change_cb_.Run(session_id, key_added, std::move(keys_info)); 396 session_keys_change_cb_.Run(session_id, key_added, std::move(keys_info));
397 } 397 }
398 398
399 // Runs the parallel steps from https://w3c.github.io/encrypted-media/#close.
399 void AesDecryptor::CloseSession(const std::string& session_id, 400 void AesDecryptor::CloseSession(const std::string& session_id,
400 std::unique_ptr<SimpleCdmPromise> promise) { 401 std::unique_ptr<SimpleCdmPromise> promise) {
401 // Validate that this is a reference to an active session and then forget it. 402 // Validate that this is a reference to an active session and then forget it.
402 std::set<std::string>::iterator it = valid_sessions_.find(session_id); 403 std::set<std::string>::iterator it = valid_sessions_.find(session_id);
403 DCHECK(it != valid_sessions_.end()); 404 DCHECK(it != valid_sessions_.end());
404 405
406 // 5.1. Let cdm be the CDM instance represented by session's cdm instance
407 // value.
408 // 5.2. Use cdm to close the session associated with session.
405 valid_sessions_.erase(it); 409 valid_sessions_.erase(it);
410 DeleteKeysForSession(session_id);
406 411
407 // Close the session. 412 // 5.3. Queue a task to run the following steps:
408 DeleteKeysForSession(session_id); 413 // 5.3.1. Run the Session Closed algorithm on the session.
414 session_closed_cb_.Run(session_id);
415 // 5.3.2. Resolve promise.
409 promise->resolve(); 416 promise->resolve();
410
411 // Resolve the closed attribute.
412 session_closed_cb_.Run(session_id);
413 } 417 }
414 418
415 void AesDecryptor::RemoveSession(const std::string& session_id, 419 void AesDecryptor::RemoveSession(const std::string& session_id,
416 std::unique_ptr<SimpleCdmPromise> promise) { 420 std::unique_ptr<SimpleCdmPromise> promise) {
417 NOTIMPLEMENTED() << "Need to address https://crbug.com/616166."; 421 NOTIMPLEMENTED() << "Need to address https://crbug.com/616166.";
418 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist."); 422 promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist.");
419 } 423 }
420 424
421 CdmContext* AesDecryptor::GetCdmContext() { 425 CdmContext* AesDecryptor::GetCdmContext() {
422 return this; 426 return this;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 bool AesDecryptor::DecryptionKey::Init() { 596 bool AesDecryptor::DecryptionKey::Init() {
593 CHECK(!secret_.empty()); 597 CHECK(!secret_.empty());
594 decryption_key_ = 598 decryption_key_ =
595 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_); 599 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_);
596 if (!decryption_key_) 600 if (!decryption_key_)
597 return false; 601 return false;
598 return true; 602 return true;
599 } 603 }
600 604
601 } // namespace media 605 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698