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

Side by Side Diff: media/blink/cdm_session_adapter.h

Issue 1070853004: media: CdmFactory creates CDM (MediaKeys) asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ScopedVector Created 5 years, 8 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/base/cdm_factory.h ('k') | media/blink/cdm_session_adapter.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BLINK_CDM_SESSION_ADAPTER_H_ 5 #ifndef MEDIA_BLINK_CDM_SESSION_ADAPTER_H_
6 #define MEDIA_BLINK_CDM_SESSION_ADAPTER_H_ 6 #define MEDIA_BLINK_CDM_SESSION_ADAPTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "media/base/media_keys.h" 15 #include "media/base/media_keys.h"
16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h " 17 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h "
17 18
18 class GURL; 19 class GURL;
19 20
20 namespace media { 21 namespace media {
21 22
22 class CdmFactory; 23 class CdmFactory;
23 class WebContentDecryptionModuleSessionImpl; 24 class WebContentDecryptionModuleSessionImpl;
24 25
25 // Owns the CDM instance and makes calls from session objects to the CDM. 26 // Owns the CDM instance and makes calls from session objects to the CDM.
26 // Forwards the session ID-based callbacks of the MediaKeys interface to the 27 // Forwards the session ID-based callbacks of the MediaKeys interface to the
27 // appropriate session object. Callers should hold references to this class 28 // appropriate session object. Callers should hold references to this class
28 // as long as they need the CDM instance. 29 // as long as they need the CDM instance.
29 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { 30 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
30 public: 31 public:
31 CdmSessionAdapter(); 32 CdmSessionAdapter();
32 33
33 // Returns true on success. 34 // Creates the CDM for |key_system| using |cdm_factory| and returns the result
34 bool Initialize(CdmFactory* cdm_factory, 35 // via |result|.
35 const std::string& key_system, 36 void CreateCdm(CdmFactory* cdm_factory,
36 bool allow_distinctive_identifier, 37 const std::string& key_system,
37 bool allow_persistent_state, 38 bool allow_distinctive_identifier,
38 const GURL& security_origin); 39 bool allow_persistent_state,
40 const GURL& security_origin,
41 blink::WebContentDecryptionModuleResult result);
39 42
40 // Provides a server certificate to be used to encrypt messages to the 43 // Provides a server certificate to be used to encrypt messages to the
41 // license server. 44 // license server.
42 void SetServerCertificate(const uint8* server_certificate, 45 void SetServerCertificate(const uint8* server_certificate,
43 int server_certificate_length, 46 int server_certificate_length,
44 scoped_ptr<SimpleCdmPromise> promise); 47 scoped_ptr<SimpleCdmPromise> promise);
45 48
46 // Creates a new session and adds it to the internal map. The caller owns the 49 // Creates a new session and adds it to the internal map. The caller owns the
47 // created session. RemoveSession() must be called when destroying it, if 50 // created session. RemoveSession() must be called when destroying it, if
48 // RegisterSession() was called. 51 // RegisterSession() was called.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 CdmContext* GetCdmContext(); 95 CdmContext* GetCdmContext();
93 96
94 // Returns the key system name. 97 // Returns the key system name.
95 const std::string& GetKeySystem() const; 98 const std::string& GetKeySystem() const;
96 99
97 // Returns a prefix to use for UMAs. 100 // Returns a prefix to use for UMAs.
98 const std::string& GetKeySystemUMAPrefix() const; 101 const std::string& GetKeySystemUMAPrefix() const;
99 102
100 private: 103 private:
101 friend class base::RefCounted<CdmSessionAdapter>; 104 friend class base::RefCounted<CdmSessionAdapter>;
105
106 // Session ID to WebContentDecryptionModuleSessionImpl mapping.
102 typedef base::hash_map<std::string, 107 typedef base::hash_map<std::string,
103 base::WeakPtr<WebContentDecryptionModuleSessionImpl> > 108 base::WeakPtr<WebContentDecryptionModuleSessionImpl> >
104 SessionMap; 109 SessionMap;
105 110
106 ~CdmSessionAdapter(); 111 ~CdmSessionAdapter();
107 112
113 // Callback for CreateCdm().
114 void OnCdmCreated(const std::string& key_system,
115 blink::WebContentDecryptionModuleResult result,
116 scoped_ptr<MediaKeys> cdm);
117
108 // Callbacks for firing session events. 118 // Callbacks for firing session events.
109 void OnSessionMessage(const std::string& session_id, 119 void OnSessionMessage(const std::string& session_id,
110 MediaKeys::MessageType message_type, 120 MediaKeys::MessageType message_type,
111 const std::vector<uint8>& message, 121 const std::vector<uint8>& message,
112 const GURL& legacy_destination_url); 122 const GURL& legacy_destination_url);
113 void OnSessionKeysChange(const std::string& session_id, 123 void OnSessionKeysChange(const std::string& session_id,
114 bool has_additional_usable_key, 124 bool has_additional_usable_key,
115 CdmKeysInfo keys_info); 125 CdmKeysInfo keys_info);
116 void OnSessionExpirationUpdate(const std::string& session_id, 126 void OnSessionExpirationUpdate(const std::string& session_id,
117 const base::Time& new_expiry_time); 127 const base::Time& new_expiry_time);
118 void OnSessionClosed(const std::string& session_id); 128 void OnSessionClosed(const std::string& session_id);
119 void OnLegacySessionError(const std::string& session_id, 129 void OnLegacySessionError(const std::string& session_id,
120 MediaKeys::Exception exception_code, 130 MediaKeys::Exception exception_code,
121 uint32 system_code, 131 uint32 system_code,
122 const std::string& error_message); 132 const std::string& error_message);
123 133
124 // Helper function of the callbacks. 134 // Helper function of the callbacks.
125 WebContentDecryptionModuleSessionImpl* GetSession( 135 WebContentDecryptionModuleSessionImpl* GetSession(
126 const std::string& session_id); 136 const std::string& session_id);
127 137
128 scoped_ptr<MediaKeys> media_keys_; 138 scoped_ptr<MediaKeys> cdm_;
129 139
130 SessionMap sessions_; 140 SessionMap sessions_;
131 141
132 std::string key_system_; 142 std::string key_system_;
133 std::string key_system_uma_prefix_; 143 std::string key_system_uma_prefix_;
134 144
135 // NOTE: Weak pointers must be invalidated before all other member variables. 145 // NOTE: Weak pointers must be invalidated before all other member variables.
136 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; 146 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_;
137 147
138 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); 148 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter);
139 }; 149 };
140 150
141 } // namespace media 151 } // namespace media
142 152
143 #endif // MEDIA_BLINK_CDM_SESSION_ADAPTER_H_ 153 #endif // MEDIA_BLINK_CDM_SESSION_ADAPTER_H_
OLDNEW
« no previous file with comments | « media/base/cdm_factory.h ('k') | media/blink/cdm_session_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698