Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "media/base/media_keys.h" | |
| 14 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" | |
|
ddorwin
2014/02/19 01:41:53
...Session.h?
jrummell
2014/02/19 20:42:10
Done.
| |
| 15 | |
| 16 namespace content { | |
| 17 class WebContentDecryptionModuleSessionImpl; | |
| 18 | |
| 19 // Forwards the session ID-based callbacks of the MediaKeys interface to the | |
|
ddorwin
2014/02/19 01:41:53
It also makes calls from the session objects to th
jrummell
2014/02/19 20:42:10
Done.
| |
| 20 // appropriate session object. Both WebContentDecryptionModuleImpl and | |
|
ddorwin
2014/02/19 01:41:53
I would say that this object owns the CDM instance
jrummell
2014/02/19 20:42:10
Done.
| |
| 21 // WebContentDecryptionModuleSessionImpl will hold references to this object. | |
| 22 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { | |
| 23 public: | |
| 24 CdmSessionAdapter(); | |
| 25 | |
| 26 // On success returns true. | |
|
ddorwin
2014/02/19 01:41:53
nit: Returns true on success.
jrummell
2014/02/19 20:42:10
Done.
| |
| 27 bool Initialize(const std::string& key_system); | |
| 28 | |
| 29 // Creates a new session and adds it to the internal map. The caller owns the | |
| 30 // created session. | |
|
ddorwin
2014/02/19 01:41:53
RemoveSession() must be called when destroying it.
jrummell
2014/02/19 20:42:10
Done.
| |
| 31 WebContentDecryptionModuleSessionImpl* NewSession( | |
|
ddorwin
2014/02/19 01:41:53
Create...
"New" is somewhat redundant, so we could
jrummell
2014/02/19 20:42:10
Done.
| |
| 32 blink::WebContentDecryptionModuleSession::Client* client); | |
| 33 | |
| 34 // Removes a session from the internal map. | |
| 35 void RemoveSession(uint32 session_id); | |
| 36 | |
| 37 // Creates a session with the |content_type| and |init_data| provided. | |
| 38 void CreateSession(uint32 session_id, | |
|
ddorwin
2014/02/19 01:41:53
I guess we're going to need to rename this to init
jrummell
2014/02/19 20:42:10
Done.
| |
| 39 const std::string& content_type, | |
| 40 const uint8* init_data, | |
| 41 int init_data_length); | |
| 42 | |
| 43 // Updates a session specified by |session_id| with |response|. | |
|
ddorwin
2014/02/19 01:41:53
s/a/the/
jrummell
2014/02/19 20:42:10
Done.
| |
| 44 void UpdateSession(uint32 session_id, | |
| 45 const uint8* response, | |
| 46 int response_length); | |
| 47 | |
| 48 // Releases the session specified by |session_id|. | |
| 49 void ReleaseSession(uint32 session_id); | |
| 50 | |
| 51 // Returns the Decryptor associated with this CDM. May be NULL if no | |
| 52 // Decryptor associated with the MediaKeys object. | |
|
ddorwin
2014/02/19 01:41:53
nit: _is_ associated
jrummell
2014/02/19 20:42:10
Done.
| |
| 53 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor | |
| 54 // after WebContentDecryptionModule is freed. http://crbug.com/330324 | |
| 55 media::Decryptor* GetDecryptor(); | |
|
ddorwin
2014/02/19 01:41:53
Who is calling this? We shouldn't need this in the
jrummell
2014/02/19 20:42:10
It is WebContentDecryptionModuleImpl, which no lon
| |
| 56 | |
| 57 private: | |
| 58 friend class base::RefCounted<CdmSessionAdapter>; | |
| 59 typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap; | |
| 60 | |
| 61 ~CdmSessionAdapter(); | |
| 62 | |
| 63 // Callbacks for firing session events. | |
| 64 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); | |
| 65 void OnSessionMessage(uint32 session_id, | |
| 66 const std::vector<uint8>& message, | |
| 67 const std::string& destination_url); | |
| 68 void OnSessionReady(uint32 session_id); | |
| 69 void OnSessionClosed(uint32 session_id); | |
| 70 void OnSessionError(uint32 session_id, | |
| 71 media::MediaKeys::KeyError error_code, | |
| 72 int system_code); | |
| 73 | |
| 74 // Helper function of the callbacks. | |
| 75 WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id); | |
| 76 | |
| 77 // Keep ownership of MediaKeys. | |
|
ddorwin
2014/02/19 01:41:53
Redundant.
jrummell
2014/02/19 20:42:10
Done.
| |
| 78 scoped_ptr<media::MediaKeys> media_keys_; | |
| 79 | |
| 80 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; | |
| 81 | |
| 82 SessionMap sessions_; | |
| 83 | |
| 84 // Session ID should be unique per renderer process for debugging purposes. | |
| 85 static uint32 next_session_id_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); | |
| 88 }; | |
| 89 | |
| 90 } // namespace content | |
| 91 | |
| 92 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | |
| OLD | NEW |