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

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

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 years, 7 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/blink/run_all_unittests.cc ('k') | media/cdm/aes_decryptor.cc » ('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 #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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/containers/scoped_ptr_hash_map.h" 15 #include "base/containers/scoped_ptr_hash_map.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "media/base/cdm_context.h" 19 #include "media/base/cdm_context.h"
20 #include "media/base/decryptor.h" 20 #include "media/base/decryptor.h"
21 #include "media/base/media_export.h" 21 #include "media/base/media_export.h"
22 #include "media/base/media_keys.h" 22 #include "media/base/media_keys.h"
23 23
24 class GURL; 24 class GURL;
25 25
26 namespace crypto { 26 namespace crypto {
27 class SymmetricKey; 27 class SymmetricKey;
28 } 28 }
29 29
30 namespace media { 30 namespace media {
31 31
32 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES 32 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES
33 // encryption must be CTR with a key size of 128bits. 33 // encryption must be CTR with a key size of 128bits.
34 class MEDIA_EXPORT AesDecryptor : public MediaKeys, 34 class MEDIA_EXPORT AesDecryptor : public MediaKeys,
35 public CdmContext, 35 public CdmContext,
36 public Decryptor { 36 public Decryptor {
37 public: 37 public:
38 AesDecryptor(const GURL& security_origin, 38 AesDecryptor(const GURL& security_origin,
39 const SessionMessageCB& session_message_cb, 39 const SessionMessageCB& session_message_cb,
40 const SessionClosedCB& session_closed_cb, 40 const SessionClosedCB& session_closed_cb,
41 const SessionKeysChangeCB& session_keys_change_cb); 41 const SessionKeysChangeCB& session_keys_change_cb);
42 42
43 // MediaKeys implementation. 43 // MediaKeys implementation.
44 void SetServerCertificate(const std::vector<uint8_t>& certificate, 44 void SetServerCertificate(const std::vector<uint8_t>& certificate,
45 scoped_ptr<SimpleCdmPromise> promise) override; 45 std::unique_ptr<SimpleCdmPromise> promise) override;
46 void CreateSessionAndGenerateRequest( 46 void CreateSessionAndGenerateRequest(
47 SessionType session_type, 47 SessionType session_type,
48 EmeInitDataType init_data_type, 48 EmeInitDataType init_data_type,
49 const std::vector<uint8_t>& init_data, 49 const std::vector<uint8_t>& init_data,
50 scoped_ptr<NewSessionCdmPromise> promise) override; 50 std::unique_ptr<NewSessionCdmPromise> promise) override;
51 void LoadSession(SessionType session_type, 51 void LoadSession(SessionType session_type,
52 const std::string& session_id, 52 const std::string& session_id,
53 scoped_ptr<NewSessionCdmPromise> promise) override; 53 std::unique_ptr<NewSessionCdmPromise> promise) override;
54 void UpdateSession(const std::string& session_id, 54 void UpdateSession(const std::string& session_id,
55 const std::vector<uint8_t>& response, 55 const std::vector<uint8_t>& response,
56 scoped_ptr<SimpleCdmPromise> promise) override; 56 std::unique_ptr<SimpleCdmPromise> promise) override;
57 void CloseSession(const std::string& session_id, 57 void CloseSession(const std::string& session_id,
58 scoped_ptr<SimpleCdmPromise> promise) override; 58 std::unique_ptr<SimpleCdmPromise> promise) override;
59 void RemoveSession(const std::string& session_id, 59 void RemoveSession(const std::string& session_id,
60 scoped_ptr<SimpleCdmPromise> promise) override; 60 std::unique_ptr<SimpleCdmPromise> promise) override;
61 CdmContext* GetCdmContext() override; 61 CdmContext* GetCdmContext() override;
62 62
63 // CdmContext implementation. 63 // CdmContext implementation.
64 Decryptor* GetDecryptor() override; 64 Decryptor* GetDecryptor() override;
65 int GetCdmId() const override; 65 int GetCdmId() const override;
66 66
67 // Decryptor implementation. 67 // Decryptor implementation.
68 void RegisterNewKeyCB(StreamType stream_type, 68 void RegisterNewKeyCB(StreamType stream_type,
69 const NewKeyCB& key_added_cb) override; 69 const NewKeyCB& key_added_cb) override;
70 void Decrypt(StreamType stream_type, 70 void Decrypt(StreamType stream_type,
(...skipping 23 matching lines...) Expand all
94 // Creates the encryption key. 94 // Creates the encryption key.
95 bool Init(); 95 bool Init();
96 96
97 crypto::SymmetricKey* decryption_key() { return decryption_key_.get(); } 97 crypto::SymmetricKey* decryption_key() { return decryption_key_.get(); }
98 98
99 private: 99 private:
100 // The base secret that is used to create the decryption key. 100 // The base secret that is used to create the decryption key.
101 const std::string secret_; 101 const std::string secret_;
102 102
103 // The key used to decrypt the data. 103 // The key used to decrypt the data.
104 scoped_ptr<crypto::SymmetricKey> decryption_key_; 104 std::unique_ptr<crypto::SymmetricKey> decryption_key_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(DecryptionKey); 106 DISALLOW_COPY_AND_ASSIGN(DecryptionKey);
107 }; 107 };
108 108
109 // Keep track of the keys for a key ID. If multiple sessions specify keys 109 // Keep track of the keys for a key ID. If multiple sessions specify keys
110 // for the same key ID, then the last key inserted is used. The structure is 110 // for the same key ID, then the last key inserted is used. The structure is
111 // optimized so that Decrypt() has fast access, at the cost of slow deletion 111 // optimized so that Decrypt() has fast access, at the cost of slow deletion
112 // of keys when a session is released. 112 // of keys when a session is released.
113 class SessionIdDecryptionKeyMap; 113 class SessionIdDecryptionKeyMap;
114 114
115 // Key ID <-> SessionIdDecryptionKeyMap map. 115 // Key ID <-> SessionIdDecryptionKeyMap map.
116 typedef base::ScopedPtrHashMap<std::string, 116 typedef base::ScopedPtrHashMap<std::string,
117 scoped_ptr<SessionIdDecryptionKeyMap>> 117 std::unique_ptr<SessionIdDecryptionKeyMap>>
118 KeyIdToSessionKeysMap; 118 KeyIdToSessionKeysMap;
119 119
120 ~AesDecryptor() override; 120 ~AesDecryptor() override;
121 121
122 // Creates a DecryptionKey using |key_string| and associates it with |key_id|. 122 // Creates a DecryptionKey using |key_string| and associates it with |key_id|.
123 // Returns true if successful. 123 // Returns true if successful.
124 bool AddDecryptionKey(const std::string& session_id, 124 bool AddDecryptionKey(const std::string& session_id,
125 const std::string& key_id, 125 const std::string& key_id,
126 const std::string& key_string); 126 const std::string& key_string);
127 127
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the 159 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the
160 // main thread but called on the media thread. 160 // main thread but called on the media thread.
161 mutable base::Lock new_key_cb_lock_; 161 mutable base::Lock new_key_cb_lock_;
162 162
163 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); 163 DISALLOW_COPY_AND_ASSIGN(AesDecryptor);
164 }; 164 };
165 165
166 } // namespace media 166 } // namespace media
167 167
168 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ 168 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_
OLDNEW
« no previous file with comments | « media/blink/run_all_unittests.cc ('k') | media/cdm/aes_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698