Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1021)

Unified Diff: media/base/media_keys.h

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more trybot issue Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/cdm_promise.cc ('k') | media/cdm/aes_decryptor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/media_keys.h
diff --git a/media/base/media_keys.h b/media/base/media_keys.h
index 3166063dd233b989871de7cb03d76129fe843c5d..d581ae4e8bd9cfb7d1bfcd1fc77fb4578393d179 100644
--- a/media/base/media_keys.h
+++ b/media/base/media_keys.h
@@ -18,6 +18,12 @@ namespace media {
class Decryptor;
+template <typename T>
+class CdmPromiseTemplate;
+
+typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise;
+typedef CdmPromiseTemplate<void> SimpleCdmPromise;
+
// Performs media key operations.
//
// All key operations are called on the renderer thread. Therefore, these calls
@@ -27,6 +33,8 @@ class MEDIA_EXPORT MediaKeys {
// Reported to UMA, so never reuse a value!
// Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode
// (enforced in webmediaplayer_impl.cc).
+ // TODO(jrummell): Can this be moved to proxy_decryptor as it should only be
+ // used by the prefixed EME code?
enum KeyError {
kUnknownError = 1,
kClientError,
@@ -38,35 +46,55 @@ class MEDIA_EXPORT MediaKeys {
kMaxKeyError // Must be last and greater than any legit value.
};
+ // Must be a superset of cdm::MediaKeyException.
+ enum Exception {
+ NOT_SUPPORTED_ERROR,
+ INVALID_STATE_ERROR,
+ INVALID_ACCESS_ERROR,
+ QUOTA_EXCEEDED_ERROR,
+ UNKNOWN_ERROR,
+ CLIENT_ERROR,
+ OUTPUT_ERROR
+ };
+
+ // 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 {
+ TEMPORARY_SESSION,
+ PERSISTENT_SESSION
+ };
+
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
@@ -79,21 +107,18 @@ 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 GURL& 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
« no previous file with comments | « media/base/cdm_promise.cc ('k') | media/cdm/aes_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698