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

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

Issue 1428753010: Add unit tests for CdmAdapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes for bots Created 5 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
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 output->writable_data()); 227 output->writable_data());
228 return output; 228 return output;
229 } 229 }
230 230
231 AesDecryptor::AesDecryptor(const GURL& /* security_origin */, 231 AesDecryptor::AesDecryptor(const GURL& /* security_origin */,
232 const SessionMessageCB& session_message_cb, 232 const SessionMessageCB& session_message_cb,
233 const SessionClosedCB& session_closed_cb, 233 const SessionClosedCB& session_closed_cb,
234 const SessionKeysChangeCB& session_keys_change_cb) 234 const SessionKeysChangeCB& session_keys_change_cb)
235 : session_message_cb_(session_message_cb), 235 : session_message_cb_(session_message_cb),
236 session_closed_cb_(session_closed_cb), 236 session_closed_cb_(session_closed_cb),
237 session_keys_change_cb_(session_keys_change_cb) { 237 session_keys_change_cb_(session_keys_change_cb),
238 empty_gurl_(new GURL()) {
238 // AesDecryptor doesn't keep any persistent data, so no need to do anything 239 // AesDecryptor doesn't keep any persistent data, so no need to do anything
239 // with |security_origin|. 240 // with |security_origin|.
240 DCHECK(!session_message_cb_.is_null()); 241 DCHECK(!session_message_cb_.is_null());
241 DCHECK(!session_closed_cb_.is_null()); 242 DCHECK(!session_closed_cb_.is_null());
242 DCHECK(!session_keys_change_cb_.is_null()); 243 DCHECK(!session_keys_change_cb_.is_null());
244 DCHECK(empty_gurl_->is_empty());
243 } 245 }
244 246
245 AesDecryptor::~AesDecryptor() { 247 AesDecryptor::~AesDecryptor() {
246 key_map_.clear(); 248 key_map_.clear();
247 } 249 }
248 250
249 void AesDecryptor::SetServerCertificate(const std::vector<uint8_t>& certificate, 251 void AesDecryptor::SetServerCertificate(const std::vector<uint8_t>& certificate,
250 scoped_ptr<SimpleCdmPromise> promise) { 252 scoped_ptr<SimpleCdmPromise> promise) {
251 promise->reject( 253 promise->reject(
252 NOT_SUPPORTED_ERROR, 0, "SetServerCertificate() is not supported."); 254 NOT_SUPPORTED_ERROR, 0, "SetServerCertificate() is not supported.");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 "init_data_type not supported."); 305 "init_data_type not supported.");
304 return; 306 return;
305 } 307 }
306 CreateLicenseRequest(keys, session_type, &message); 308 CreateLicenseRequest(keys, session_type, &message);
307 } 309 }
308 310
309 promise->resolve(session_id); 311 promise->resolve(session_id);
310 312
311 // No URL needed for license requests. 313 // No URL needed for license requests.
312 session_message_cb_.Run(session_id, LICENSE_REQUEST, message, 314 session_message_cb_.Run(session_id, LICENSE_REQUEST, message,
313 GURL::EmptyGURL()); 315 *empty_gurl_.get());
xhwang 2015/11/13 00:03:22 Can we just create a local one here? GURL empty_g
jrummell 2015/11/13 00:35:20 Done.
314 } 316 }
315 317
316 void AesDecryptor::LoadSession(SessionType session_type, 318 void AesDecryptor::LoadSession(SessionType session_type,
317 const std::string& session_id, 319 const std::string& session_id,
318 scoped_ptr<NewSessionCdmPromise> promise) { 320 scoped_ptr<NewSessionCdmPromise> promise) {
319 // TODO(xhwang): Change this to NOTREACHED() when blink checks for key systems 321 // TODO(xhwang): Change this to NOTREACHED() when blink checks for key systems
320 // that do not support loadSession. See http://crbug.com/342481 322 // that do not support loadSession. See http://crbug.com/342481
321 promise->reject(NOT_SUPPORTED_ERROR, 0, "LoadSession() is not supported."); 323 promise->reject(NOT_SUPPORTED_ERROR, 0, "LoadSession() is not supported.");
322 } 324 }
323 325
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 bool AesDecryptor::DecryptionKey::Init() { 606 bool AesDecryptor::DecryptionKey::Init() {
605 CHECK(!secret_.empty()); 607 CHECK(!secret_.empty());
606 decryption_key_.reset(crypto::SymmetricKey::Import( 608 decryption_key_.reset(crypto::SymmetricKey::Import(
607 crypto::SymmetricKey::AES, secret_)); 609 crypto::SymmetricKey::AES, secret_));
608 if (!decryption_key_) 610 if (!decryption_key_)
609 return false; 611 return false;
610 return true; 612 return true;
611 } 613 }
612 614
613 } // namespace media 615 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698