Chromium Code Reviews| Index: content/renderer/media/cdm_session_adapter.h |
| diff --git a/content/renderer/media/cdm_session_adapter.h b/content/renderer/media/cdm_session_adapter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..537d8b741ae0805d97aa3c4d05e5b2235600685b |
| --- /dev/null |
| +++ b/content/renderer/media/cdm_session_adapter.h |
| @@ -0,0 +1,92 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| +#define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "media/base/media_keys.h" |
| +#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.
|
| + |
| +namespace content { |
| +class WebContentDecryptionModuleSessionImpl; |
| + |
| +// 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.
|
| +// 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.
|
| +// WebContentDecryptionModuleSessionImpl will hold references to this object. |
| +class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { |
| + public: |
| + CdmSessionAdapter(); |
| + |
| + // On success returns true. |
|
ddorwin
2014/02/19 01:41:53
nit: Returns true on success.
jrummell
2014/02/19 20:42:10
Done.
|
| + bool Initialize(const std::string& key_system); |
| + |
| + // Creates a new session and adds it to the internal map. The caller owns the |
| + // created session. |
|
ddorwin
2014/02/19 01:41:53
RemoveSession() must be called when destroying it.
jrummell
2014/02/19 20:42:10
Done.
|
| + 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.
|
| + blink::WebContentDecryptionModuleSession::Client* client); |
| + |
| + // Removes a session from the internal map. |
| + void RemoveSession(uint32 session_id); |
| + |
| + // Creates a session with the |content_type| and |init_data| provided. |
| + 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.
|
| + const std::string& content_type, |
| + const uint8* init_data, |
| + int init_data_length); |
| + |
| + // 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.
|
| + void UpdateSession(uint32 session_id, |
| + const uint8* response, |
| + int response_length); |
| + |
| + // Releases the session specified by |session_id|. |
| + void ReleaseSession(uint32 session_id); |
| + |
| + // Returns the Decryptor associated with this CDM. May be NULL if no |
| + // Decryptor associated with the MediaKeys object. |
|
ddorwin
2014/02/19 01:41:53
nit: _is_ associated
jrummell
2014/02/19 20:42:10
Done.
|
| + // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor |
| + // after WebContentDecryptionModule is freed. http://crbug.com/330324 |
| + 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
|
| + |
| + private: |
| + friend class base::RefCounted<CdmSessionAdapter>; |
| + typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap; |
| + |
| + ~CdmSessionAdapter(); |
| + |
| + // Callbacks for firing session events. |
| + void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| + void OnSessionMessage(uint32 session_id, |
| + const std::vector<uint8>& message, |
| + const std::string& destination_url); |
| + void OnSessionReady(uint32 session_id); |
| + void OnSessionClosed(uint32 session_id); |
| + void OnSessionError(uint32 session_id, |
| + media::MediaKeys::KeyError error_code, |
| + int system_code); |
| + |
| + // Helper function of the callbacks. |
| + WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id); |
| + |
| + // Keep ownership of MediaKeys. |
|
ddorwin
2014/02/19 01:41:53
Redundant.
jrummell
2014/02/19 20:42:10
Done.
|
| + scoped_ptr<media::MediaKeys> media_keys_; |
| + |
| + base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; |
| + |
| + SessionMap sessions_; |
| + |
| + // Session ID should be unique per renderer process for debugging purposes. |
| + static uint32 next_session_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |