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

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

Issue 105933004: AesDecryptor callbacks now used in a thread-safe manner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refresh Created 6 years, 11 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/cdm/aes_decryptor.h ('k') | tools/valgrind/tsan_v2/suppressions.txt » ('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 <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 DVLOG(1) << "Invalid key length: " << key_string.length(); 278 DVLOG(1) << "Invalid key length: " << key_string.length();
279 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); 279 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
280 return; 280 return;
281 } 281 }
282 if (!AddDecryptionKey(session_id, it->first, it->second)) { 282 if (!AddDecryptionKey(session_id, it->first, it->second)) {
283 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); 283 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
284 return; 284 return;
285 } 285 }
286 } 286 }
287 287
288 if (!new_audio_key_cb_.is_null()) 288 {
289 new_audio_key_cb_.Run(); 289 base::AutoLock auto_lock(new_key_cb_lock_);
290 290
291 if (!new_video_key_cb_.is_null()) 291 if (!new_audio_key_cb_.is_null())
292 new_video_key_cb_.Run(); 292 new_audio_key_cb_.Run();
293
294 if (!new_video_key_cb_.is_null())
295 new_video_key_cb_.Run();
296 }
293 297
294 session_ready_cb_.Run(session_id); 298 session_ready_cb_.Run(session_id);
295 } 299 }
296 300
297 void AesDecryptor::ReleaseSession(uint32 session_id) { 301 void AesDecryptor::ReleaseSession(uint32 session_id) {
298 // Validate that this is a reference to an active session and then forget it. 302 // Validate that this is a reference to an active session and then forget it.
299 std::set<uint32>::iterator it = valid_sessions_.find(session_id); 303 std::set<uint32>::iterator it = valid_sessions_.find(session_id);
300 DCHECK(it != valid_sessions_.end()); 304 DCHECK(it != valid_sessions_.end());
301 valid_sessions_.erase(it); 305 valid_sessions_.erase(it);
302 306
303 DeleteKeysForSession(session_id); 307 DeleteKeysForSession(session_id);
304 session_closed_cb_.Run(session_id); 308 session_closed_cb_.Run(session_id);
305 } 309 }
306 310
307 Decryptor* AesDecryptor::GetDecryptor() { 311 Decryptor* AesDecryptor::GetDecryptor() {
308 return this; 312 return this;
309 } 313 }
310 314
311 void AesDecryptor::RegisterNewKeyCB(StreamType stream_type, 315 void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
312 const NewKeyCB& new_key_cb) { 316 const NewKeyCB& new_key_cb) {
317 base::AutoLock auto_lock(new_key_cb_lock_);
318
313 switch (stream_type) { 319 switch (stream_type) {
314 case kAudio: 320 case kAudio:
315 new_audio_key_cb_ = new_key_cb; 321 new_audio_key_cb_ = new_key_cb;
316 break; 322 break;
317 case kVideo: 323 case kVideo:
318 new_video_key_cb_ = new_key_cb; 324 new_video_key_cb_ = new_key_cb;
319 break; 325 break;
320 default: 326 default:
321 NOTREACHED(); 327 NOTREACHED();
322 } 328 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 bool AesDecryptor::DecryptionKey::Init() { 466 bool AesDecryptor::DecryptionKey::Init() {
461 CHECK(!secret_.empty()); 467 CHECK(!secret_.empty());
462 decryption_key_.reset(crypto::SymmetricKey::Import( 468 decryption_key_.reset(crypto::SymmetricKey::Import(
463 crypto::SymmetricKey::AES, secret_)); 469 crypto::SymmetricKey::AES, secret_));
464 if (!decryption_key_) 470 if (!decryption_key_)
465 return false; 471 return false;
466 return true; 472 return true;
467 } 473 }
468 474
469 } // namespace media 475 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/aes_decryptor.h ('k') | tools/valgrind/tsan_v2/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698