Chromium Code Reviews| Index: media/base/media_keys.h |
| diff --git a/media/base/media_keys.h b/media/base/media_keys.h |
| index a6ef64ceee0ea8d62a4ad8e29b1401351c766963..73a6cb427768374e45e778897dd06cce3058031c 100644 |
| --- a/media/base/media_keys.h |
| +++ b/media/base/media_keys.h |
| @@ -17,6 +17,12 @@ namespace media { |
| class Decryptor; |
| +template <typename T> |
| +class CdmPromise; |
| + |
| +typedef CdmPromise<std::string> CdmNewSessionPromise; |
| +typedef CdmPromise<void> CdmChangeSessionPromise; |
|
ddorwin
2014/05/13 22:44:02
As earlier, "ChangeSession" is odd, and maybe not
jrummell
2014/05/15 22:38:09
Now SimpleCdmPromise (and NewSessionCdmPromise).
|
| + |
| // Performs media key operations. |
| // |
| // All key operations are called on the renderer thread. Therefore, these calls |
| @@ -37,35 +43,68 @@ class MEDIA_EXPORT MediaKeys { |
| kMaxKeyError // Must be last and greater than any legit value. |
| }; |
| + // Must be kept in sync with cdm::MediaKeyException (enforced in |
|
ddorwin
2014/05/13 22:44:02
This shouldn't be necessary. This must be a supers
jrummell
2014/05/15 22:38:09
Updated. Using a switch statement in clear_key_cdm
|
| + // clear_key_cdm.cc). |
| + enum MediaKeysException { |
| + MEDIA_KEYS_EXCEPTION_NO_MODIFICATION_ALLOWED_ERROR = 7, |
| + MEDIA_KEYS_EXCEPTION_NOT_FOUND_ERROR = 8, |
| + MEDIA_KEYS_EXCEPTION_NOT_SUPPORTED_ERROR = 9, |
| + MEDIA_KEYS_EXCEPTION_INVALID_STATE_ERROR = 11, |
| + MEDIA_KEYS_EXCEPTION_SYNTAX_ERROR = 12, |
| + MEDIA_KEYS_EXCEPTION_INVALID_MODIFICATION_ERROR = 13, |
| + MEDIA_KEYS_EXCEPTION_INVALID_ACCESS_ERROR = 15, |
| + MEDIA_KEYS_EXCEPTION_SECURITY_ERROR = 18, |
| + MEDIA_KEYS_EXCEPTION_ABORT_ERROR = 20, |
| + MEDIA_KEYS_EXCEPTION_QUOTA_EXCEEDED_ERROR = 22, |
| + MEDIA_KEYS_EXCEPTION_TIMEOUT_ERROR = 23, |
| + MEDIA_KEYS_EXCEPTION_UNKNOWN_ERROR = 30, |
|
ddorwin
2014/05/13 22:44:02
We don't actually need fixed integers for these si
jrummell
2014/05/15 22:38:09
Done.
|
| + MEDIA_KEYS_EXCEPTION_DATA_ERROR = 31, |
| + MEDIA_KEYS_EXCEPTION_VERSION_ERROR = 32, |
| + MEDIA_KEYS_EXCEPTION_NOT_READABLE_ERROR = 33, |
| + MEDIA_KEYS_EXCEPTION_OPERATION_ERROR = 34, |
| + MEDIA_KEYS_EXCEPTION_CLIENT_ERROR = 100, |
| + MEDIA_KEYS_EXCEPTION_OUTPUT_ERROR = 101 |
| + }; |
| + |
| + // Type of license required when creating/loading a session. |
| + // Must be kept in sync with the values specified in the spec: |
|
ddorwin
2014/05/13 22:44:02
What do you mean in sync? The integer values shoul
jrummell
2014/05/15 22:38:09
Changed.
|
| + // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#extensions |
| + // Must be kept in sync with cdm::SessionType (enforced in clear_key_cdm.cc). |
|
ddorwin
2014/05/13 22:44:02
ditto
jrummell
2014/05/15 22:38:09
Done.
|
| + enum SessionType { |
| + SESSION_TYPE_TEMPORARY = 0, |
| + SESSION_TYPE_PERSISTENT = 1 |
| + }; |
| + |
| const static uint32 kInvalidSessionId = 0; |
| MediaKeys(); |
| virtual ~MediaKeys(); |
| - // Creates a session with the |content_type| and |init_data| provided. |
| - // Returns true if a session is successfully created, false otherwise. |
| + // Creates a session with the |init_data_type|, |init_data| and |session_type| |
| + // provided. |
| // Note: UpdateSession() and ReleaseSession() should only be called after |
| - // SessionCreatedCB is fired. |
| - // TODO(jrummell): Remove return value when prefixed API is removed. |
| - // See http://crbug.com/342510 |
| - virtual bool CreateSession(uint32 session_id, |
| - const std::string& content_type, |
| + // |promise| is resolved. |
| + virtual void CreateSession(const std::string& init_data_type, |
| const uint8* init_data, |
| - int init_data_length) = 0; |
| + int init_data_length, |
| + SessionType session_type, |
| + scoped_ptr<CdmNewSessionPromise> promise) = 0; |
| // Loads a session with the |web_session_id| provided. |
| // Note: UpdateSession() and ReleaseSession() should only be called after |
| - // SessionCreatedCB is fired. |
| - virtual void LoadSession(uint32 session_id, |
| - const std::string& web_session_id) = 0; |
| + // |promise| is resolved. |
| + virtual void LoadSession(const std::string& web_session_id, |
| + scoped_ptr<CdmNewSessionPromise> promise) = 0; |
| - // Updates a session specified by |session_id| with |response|. |
| - virtual void UpdateSession(uint32 session_id, |
| + // Updates a session specified by |web_session_id| with |response|. |
| + virtual void UpdateSession(const std::string& web_session_id, |
| const uint8* response, |
| - int response_length) = 0; |
| + int response_length, |
| + scoped_ptr<CdmChangeSessionPromise> promise) = 0; |
| - // Releases the session specified by |session_id|. |
| - virtual void ReleaseSession(uint32 session_id) = 0; |
| + // Releases the session specified by |web_session_id|. |
| + virtual void ReleaseSession(const std::string& web_session_id, |
| + scoped_ptr<CdmChangeSessionPromise> promise) = 0; |
| // Gets the Decryptor object associated with the MediaKeys. Returns NULL if |
| // no Decryptor object is associated. The returned object is only guaranteed |
| @@ -78,22 +117,19 @@ class MEDIA_EXPORT MediaKeys { |
| // Key event callbacks. See the spec for details: |
| // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#event-summary |
| -typedef base::Callback< |
| - void(uint32 session_id, const std::string& web_session_id)> |
| - SessionCreatedCB; |
| - |
| -typedef base::Callback<void(uint32 session_id, |
| +typedef base::Callback<void(const std::string& web_session_id, |
| const std::vector<uint8>& message, |
| const std::string& destination_url)> |
| SessionMessageCB; |
| -typedef base::Callback<void(uint32 session_id)> SessionReadyCB; |
| +typedef base::Callback<void(const std::string& web_session_id)> SessionReadyCB; |
| -typedef base::Callback<void(uint32 session_id)> SessionClosedCB; |
| +typedef base::Callback<void(const std::string& web_session_id)> SessionClosedCB; |
| -typedef base::Callback<void(uint32 session_id, |
| - media::MediaKeys::KeyError error_code, |
| - uint32 system_code)> SessionErrorCB; |
| +typedef base::Callback<void(const std::string& web_session_id, |
| + MediaKeys::MediaKeysException exception_code, |
| + uint32 system_code, |
| + const std::string& error_message)> SessionErrorCB; |
| } // namespace media |