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

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: Created 7 years 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 DVLOG(1) << "Invalid key length: " << key_string.length(); 281 DVLOG(1) << "Invalid key length: " << key_string.length();
282 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); 282 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
283 return; 283 return;
284 } 284 }
285 if (!AddDecryptionKey(session_id, it->first, it->second)) { 285 if (!AddDecryptionKey(session_id, it->first, it->second)) {
286 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); 286 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
287 return; 287 return;
288 } 288 }
289 } 289 }
290 290
291 base::AutoLock auto_lock(key_cb_lock_);
ddorwin 2013/12/19 19:34:16 Should we put this in {} down to 298 so session_re
jrummell 2013/12/19 23:15:40 Done.
292
291 if (!new_audio_key_cb_.is_null()) 293 if (!new_audio_key_cb_.is_null())
292 new_audio_key_cb_.Run(); 294 new_audio_key_cb_.Run();
293 295
294 if (!new_video_key_cb_.is_null()) 296 if (!new_video_key_cb_.is_null())
295 new_video_key_cb_.Run(); 297 new_video_key_cb_.Run();
296 298
297 session_ready_cb_.Run(session_id); 299 session_ready_cb_.Run(session_id);
298 } 300 }
299 301
300 void AesDecryptor::ReleaseSession(uint32 session_id) { 302 void AesDecryptor::ReleaseSession(uint32 session_id) {
301 // Validate that this is a reference to an active session and then forget it. 303 // Validate that this is a reference to an active session and then forget it.
302 std::set<uint32>::iterator it = valid_sessions_.find(session_id); 304 std::set<uint32>::iterator it = valid_sessions_.find(session_id);
303 DCHECK(it != valid_sessions_.end()); 305 DCHECK(it != valid_sessions_.end());
304 valid_sessions_.erase(it); 306 valid_sessions_.erase(it);
305 307
306 DeleteKeysForSession(session_id); 308 DeleteKeysForSession(session_id);
307 session_closed_cb_.Run(session_id); 309 session_closed_cb_.Run(session_id);
308 } 310 }
309 311
310 Decryptor* AesDecryptor::GetDecryptor() { 312 Decryptor* AesDecryptor::GetDecryptor() {
311 return this; 313 return this;
312 } 314 }
313 315
314 void AesDecryptor::RegisterNewKeyCB(StreamType stream_type, 316 void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
315 const NewKeyCB& new_key_cb) { 317 const NewKeyCB& new_key_cb) {
318 base::AutoLock auto_lock(key_cb_lock_);
319
316 switch (stream_type) { 320 switch (stream_type) {
317 case kAudio: 321 case kAudio:
318 new_audio_key_cb_ = new_key_cb; 322 new_audio_key_cb_ = new_key_cb;
319 break; 323 break;
320 case kVideo: 324 case kVideo:
321 new_video_key_cb_ = new_key_cb; 325 new_video_key_cb_ = new_key_cb;
322 break; 326 break;
323 default: 327 default:
324 NOTREACHED(); 328 NOTREACHED();
325 } 329 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 bool AesDecryptor::DecryptionKey::Init() { 468 bool AesDecryptor::DecryptionKey::Init() {
465 CHECK(!secret_.empty()); 469 CHECK(!secret_.empty());
466 decryption_key_.reset(crypto::SymmetricKey::Import( 470 decryption_key_.reset(crypto::SymmetricKey::Import(
467 crypto::SymmetricKey::AES, secret_)); 471 crypto::SymmetricKey::AES, secret_));
468 if (!decryption_key_) 472 if (!decryption_key_)
469 return false; 473 return false;
470 return true; 474 return true;
471 } 475 }
472 476
473 } // namespace media 477 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698