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 afe1719b5739f99c7f3db2fb4bc2154f95893ad5..325c4f687ece362b9b18521536a8a8103df5bd88 100644 |
| --- a/content/renderer/media/android/proxy_media_keys.h |
| +++ b/content/renderer/media/android/proxy_media_keys.h |
| @@ -5,6 +5,9 @@ |
| #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 "media/base/media_keys.h" |
| @@ -24,7 +27,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 +35,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::MediaKeysSessionPromise> promise) OVERRIDE; |
|
xhwang
2014/05/05 20:46:42
Now "cdm" is the standard term in chromium and Med
|
| + virtual void LoadSession( |
| + const std::string& web_session_id, |
| + scoped_ptr<media::MediaKeysSessionPromise> promise) OVERRIDE; |
| + virtual void UpdateSession( |
| + const std::string& web_session_id, |
| + const uint8* response, |
| + int response_length, |
| + scoped_ptr<media::MediaKeysSessionPromise> promise) OVERRIDE; |
| + virtual void ReleaseSession( |
| + const std::string& web_session_id, |
| + scoped_ptr<media::MediaKeysSessionPromise> promise) OVERRIDE; |
| // Callbacks. |
| void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| @@ -59,7 +68,6 @@ class ProxyMediaKeys : public media::MediaKeys { |
| private: |
| 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 +76,36 @@ class ProxyMediaKeys : public media::MediaKeys { |
| void InitializeCdm(const std::string& key_system, |
| const GURL& security_origin); |
| + // Helper functions to keep track of session_ids <-> web_session_ids. |
|
xhwang
2014/05/05 20:46:42
Please add a comment that we are still keeping Ses
jrummell
2014/05/08 23:37:45
Done.
|
| + uint32_t CreateSessionId(); |
| + void AssignWebSessionId(uint32_t session_id, |
| + const std::string& web_session_id); |
| + uint32_t LookupSessionId(const std::string& web_session_id); |
| + std::string LookupWebSessionId(uint32_t session_id); |
| + void DropWebSessionId(std::string web_session_id); |
| + |
| + // Helper function to keep track of promises. Adding takes ownership of the |
| + // promise, transferred back to caller on lookup. |
| + void AddPromise(uint32_t session_id, |
|
xhwang
2014/05/05 20:46:42
To be consistent to CdmSessionAdapter, how about R
jrummell
2014/05/08 23:37:45
Done.
|
| + scoped_ptr<media::MediaKeysSessionPromise> promise); |
| + scoped_ptr<media::MediaKeysSessionPromise> LookupPromise(uint32_t session_id); |
|
xhwang
2014/05/05 20:46:42
"Lookup" usually is a const operation, but this is
jrummell
2014/05/08 23:37:45
Done.
|
| + |
| // 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_; |
| + uint32_t next_session_id_; |
| + std::map<std::string, uint32_t> web_session_to_session_id_map_; |
|
xhwang
2014/05/05 20:46:42
Since we use string as the key, use hash_map for b
jrummell
2014/05/08 23:37:45
Done.
|
| + std::map<uint32_t, media::MediaKeysSessionPromise*> |
| + session_id_to_promise_map_; |
|
xhwang
2014/05/05 20:46:42
Please comment that this map owns the promises.
jrummell
2014/05/08 23:37:45
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys); |
| }; |