Chromium Code Reviews| Index: content/renderer/media/android/proxy_media_keys.h |
| diff --git a/content/renderer/media/android/proxy_media_keys.h b/content/renderer/media/android/proxy_media_keys.h |
| index d5157260e537229faacdd83eba70635c9e2d18f7..9ce0bcc6660ba5edfc682825c83e9ea7faf3b0bb 100644 |
| --- a/content/renderer/media/android/proxy_media_keys.h |
| +++ b/content/renderer/media/android/proxy_media_keys.h |
| @@ -5,7 +5,12 @@ |
| #ifndef CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_ |
| #define CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_ |
| +#include <map> |
| +#include <string> |
| + |
| #include "base/basictypes.h" |
| +#include "base/containers/hash_tables.h" |
| +#include "base/containers/scoped_ptr_hash_map.h" |
| #include "media/base/media_keys.h" |
| class GURL; |
| @@ -24,7 +29,6 @@ class ProxyMediaKeys : public media::MediaKeys { |
| const std::string& key_system, |
| const GURL& security_origin, |
| RendererMediaPlayerManager* manager, |
| - const media::SessionCreatedCB& session_created_cb, |
| const media::SessionMessageCB& session_message_cb, |
| const media::SessionReadyCB& session_ready_cb, |
| const media::SessionClosedCB& session_closed_cb, |
| @@ -33,16 +37,23 @@ class ProxyMediaKeys : public media::MediaKeys { |
| virtual ~ProxyMediaKeys(); |
| // MediaKeys implementation. |
| - virtual bool CreateSession(uint32 session_id, |
| - const std::string& content_type, |
| - const uint8* init_data, |
| - int init_data_length) OVERRIDE; |
| - virtual void LoadSession(uint32 session_id, |
| - const std::string& web_session_id) OVERRIDE; |
| - virtual void UpdateSession(uint32 session_id, |
| - const uint8* response, |
| - int response_length) OVERRIDE; |
| - virtual void ReleaseSession(uint32 session_id) OVERRIDE; |
| + virtual void CreateSession( |
| + const std::string& init_data_type, |
| + const uint8* init_data, |
| + int init_data_length, |
| + SessionType session_type, |
| + scoped_ptr<media::NewSessionCdmPromise> promise) OVERRIDE; |
| + virtual void LoadSession( |
| + const std::string& web_session_id, |
| + scoped_ptr<media::NewSessionCdmPromise> promise) OVERRIDE; |
| + virtual void UpdateSession( |
| + const std::string& web_session_id, |
| + const uint8* response, |
| + int response_length, |
| + scoped_ptr<media::SimpleCdmPromise> promise) OVERRIDE; |
| + virtual void ReleaseSession( |
| + const std::string& web_session_id, |
| + scoped_ptr<media::SimpleCdmPromise> promise) OVERRIDE; |
| // Callbacks. |
| void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| @@ -58,8 +69,19 @@ class ProxyMediaKeys : public media::MediaKeys { |
| int GetCdmId() const; |
| private: |
| + // The Android-specific code that handles sessions uses integer session ids |
| + // (basically a reference id), but media::MediaKeys bases everything on |
| + // web_session_id (a string representing the actual session id as generated |
| + // by the CDM). SessionIdMap is used to map between the web_session_id and |
| + // the session_id used by the Android-specific code. |
| + typedef base::hash_map<std::string, uint32_t> SessionIdMap; |
| + |
| + // The following types keep track of Promises. The index is the |
| + // Android-specific session_id, so that returning results can be matched to |
| + // the corresponding promise. |
| + typedef base::ScopedPtrHashMap<uint32_t, media::CdmPromise> PromiseMap; |
| + |
| ProxyMediaKeys(RendererMediaPlayerManager* manager, |
| - const media::SessionCreatedCB& session_created_cb, |
| const media::SessionMessageCB& session_message_cb, |
| const media::SessionReadyCB& session_ready_cb, |
| const media::SessionClosedCB& session_closed_cb, |
| @@ -68,18 +90,41 @@ class ProxyMediaKeys : public media::MediaKeys { |
| void InitializeCdm(const std::string& key_system, |
| const GURL& security_origin); |
| + // These functions keep track of Android-specific session_ids <-> |
| + // web_session_ids mappings. |
| + // TODO(jrummell): Remove this once the Android-specific code changes to |
| + // support string web session ids. |
| + uint32_t CreateSessionId() const; |
| + void AssignWebSessionId(const uint32_t session_id, |
|
xhwang
2014/05/29 23:44:38
no need to use "const" for a integer that's passed
jrummell
2014/05/30 18:04:25
Done.
|
| + const std::string& web_session_id); |
| + uint32_t LookupSessionId(const std::string& web_session_id) const; |
| + std::string LookupWebSessionId(const uint32_t session_id) const; |
|
xhwang
2014/05/29 23:44:38
ditto
jrummell
2014/05/30 18:04:25
Done.
|
| + void DropWebSessionId(const std::string& web_session_id); |
| + |
| + // Helper function to keep track of promises. Adding takes ownership of the |
| + // promise, transferred back to caller on take. |
| + void SavePromise(const uint32_t session_id, |
|
xhwang
2014/05/29 23:44:38
ditto
jrummell
2014/05/30 18:04:25
Done.
|
| + scoped_ptr<media::CdmPromise> promise); |
| + scoped_ptr<media::CdmPromise> TakePromise(const uint32_t session_id); |
| + |
| // CDM ID should be unique per renderer process. |
| // TODO(xhwang): Use uint32 to prevent undefined overflow behavior. |
| static int next_cdm_id_; |
| RendererMediaPlayerManager* manager_; |
| int cdm_id_; |
| - media::SessionCreatedCB session_created_cb_; |
| media::SessionMessageCB session_message_cb_; |
| media::SessionReadyCB session_ready_cb_; |
| media::SessionClosedCB session_closed_cb_; |
| media::SessionErrorCB session_error_cb_; |
| + // Android-specific. See comment above CreateSessionId(). |
| + uint32_t next_session_id_; |
| + SessionIdMap web_session_to_session_id_map_; |
| + |
| + // Keep track of outstanding promises. This map owns the promise object. |
| + PromiseMap session_id_to_promise_map_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys); |
| }; |