Chromium Code Reviews| Index: media/base/media_keys.h |
| diff --git a/media/base/media_keys.h b/media/base/media_keys.h |
| index 4af35815442224534617bcab63d37f1ad63ec3b1..192858cc651353efa8a342c934795ea7486eab76 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> NewSessionCdmPromise; |
| +typedef CdmPromise<void> SimpleCdmPromise; |
| + |
| // Performs media key operations. |
| // |
| // All key operations are called on the renderer thread. Therefore, these calls |
| @@ -37,35 +43,65 @@ class MEDIA_EXPORT MediaKeys { |
| kMaxKeyError // Must be last and greater than any legit value. |
| }; |
| + // Must be a superset of cdm::MediaKeyException. |
| + enum Exception { |
| + EXCEPTION_NO_MODIFICATION_ALLOWED_ERROR, |
| + EXCEPTION_NOT_FOUND_ERROR, |
| + EXCEPTION_NOT_SUPPORTED_ERROR, |
| + EXCEPTION_INVALID_STATE_ERROR, |
| + EXCEPTION_INVALID_MODIFICATION_ERROR, |
| + EXCEPTION_INVALID_ACCESS_ERROR, |
| + EXCEPTION_SECURITY_ERROR, |
| + EXCEPTION_ABORT_ERROR, |
| + EXCEPTION_QUOTA_EXCEEDED_ERROR, |
| + EXCEPTION_TIMEOUT_ERROR, |
| + EXCEPTION_UNKNOWN_ERROR, |
| + EXCEPTION_DATA_ERROR, |
| + EXCEPTION_VERSION_ERROR, |
| + EXCEPTION_NOT_READABLE_ERROR, |
| + EXCEPTION_OPERATION_ERROR, |
| + EXCEPTION_CLIENT_ERROR, |
| + EXCEPTION_OUTPUT_ERROR |
|
xhwang
2014/05/23 06:01:23
Hmm, DOM "exceptions" are all "error"s... Generall
ddorwin
2014/05/23 16:41:09
I don't think there is a general *requirement* for
xhwang
2014/05/23 16:47:36
I have no strong opinion on this one :)
jrummell
2014/05/29 00:54:40
Done.
jrummell
2014/05/29 00:54:40
Done.
|
| + }; |
| + |
| + // Type of license required when creating/loading a session. |
| + // Must be consistent with the values specified in the spec: |
| + // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#extensions |
| + enum SessionType { |
| + SESSION_TYPE_TEMPORARY, |
| + SESSION_TYPE_PERSISTENT |
| + }; |
| + |
| 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<NewSessionCdmPromise> 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<NewSessionCdmPromise> 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<SimpleCdmPromise> 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<SimpleCdmPromise> 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,23 +114,20 @@ 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; |
| - |
| // TODO(xhwang): Use GURL for |destination_url|. See http://crbug.com/372877 |
| -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::Exception exception_code, |
| + uint32 system_code, |
| + const std::string& error_message)> SessionErrorCB; |
| } // namespace media |