Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 5 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 79 |
| 80 // The key used to perform the integrity check. Currently the HMAC key is | 80 // The key used to perform the integrity check. Currently the HMAC key is |
| 81 // defined by the WebM encrypted specification. Current encrypted WebM | 81 // defined by the WebM encrypted specification. Current encrypted WebM |
| 82 // request for comments specification is here | 82 // request for comments specification is here |
| 83 // http://wiki.webmproject.org/encryption/webm-encryption-rfc | 83 // http://wiki.webmproject.org/encryption/webm-encryption-rfc |
| 84 std::string hmac_key_; | 84 std::string hmac_key_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); | 86 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 void SetKey(const std::string& key_id, scoped_ptr<DecryptionKey> key); | |
|
ddorwin
2012/07/26 21:24:07
Should note that this object takes ownership of ke
xhwang
2012/07/26 23:36:47
Since scopted_ptr<> is move only, by passing in a
| |
| 90 DecryptionKey* GetKey(const std::string& key_id) const; | |
|
ddorwin
2012/07/26 21:24:07
Who owns the key? If it's not a copy, should that
xhwang
2012/07/26 23:36:47
Added a comment that the AesDecryptor still owns t
| |
| 91 | |
| 89 // KeyMap owns the DecryptionKey* and must delete them when they are | 92 // KeyMap owns the DecryptionKey* and must delete them when they are |
| 90 // not needed any more. | 93 // not needed any more. |
| 91 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; | 94 typedef base::hash_map<std::string, DecryptionKey*> KeyMap; |
| 92 | 95 |
| 93 // Since only Decrypt() is called off the renderer thread, we only need to | 96 // Since only Decrypt() is called off the renderer thread, we only need to |
| 94 // protect |key_map_|, the only member variable that is shared between | 97 // protect |key_map_|, the only member variable that is shared between |
| 95 // Decrypt() and other methods. | 98 // Decrypt() and other methods. |
| 96 KeyMap key_map_; // Protected by the |key_map_lock_|. | 99 KeyMap key_map_; // Protected by the |key_map_lock_|. |
| 97 base::Lock key_map_lock_; // Protects the |key_map_|. | 100 mutable base::Lock key_map_lock_; // Protects the |key_map_|. |
| 98 | 101 |
| 99 // Make session ID unique per renderer by making it static. | 102 // Make session ID unique per renderer by making it static. |
| 100 // TODO(xhwang): Make session ID more strictly defined if needed: | 103 // TODO(xhwang): Make session ID more strictly defined if needed: |
| 101 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 | 104 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 |
| 102 static uint32 next_session_id_; | 105 static uint32 next_session_id_; |
| 103 | 106 |
| 104 DecryptorClient* const client_; | 107 DecryptorClient* const client_; |
| 105 | 108 |
| 106 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); | 109 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 } // namespace media | 112 } // namespace media |
| 110 | 113 |
| 111 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ | 114 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ |
| OLD | NEW |