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

Unified Diff: media/base/media_keys_session_promise.h

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
Index: media/base/media_keys_session_promise.h
diff --git a/media/base/media_keys_session_promise.h b/media/base/media_keys_session_promise.h
new file mode 100644
index 0000000000000000000000000000000000000000..328c7a23892ba7522e05700fd59ca2cb73ecd8cd
--- /dev/null
+++ b/media/base/media_keys_session_promise.h
@@ -0,0 +1,67 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_MEDIA_KEYS_SESSION_PROMISE_H_
+#define MEDIA_BASE_MEDIA_KEYS_SESSION_PROMISE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+typedef base::Callback<void()> PromiseResolvedCB;
+
+typedef base::Callback<void(const std::string& web_session_id)>
+ PromiseResolvedWithSessionCB;
+
+typedef base::Callback<void(const std::string& error_name,
+ uint32 system_code,
+ const std::string& error_message)>
+ PromiseRejectedCB;
+
+// Interface for promises being resolved/rejected in response to various
+// session actions. These may be called synchronously or asynchronously.
ddorwin 2014/05/05 18:35:42 Sync is fine as long as we enforce async, which we
+// Only one method may be called on any promise. It is expected that the
+// caller free the promise once it is resolved/rejected.
+class MEDIA_EXPORT MediaKeysSessionPromise {
ddorwin 2014/05/05 18:35:42 The non-session promises are on MKS, but the sessi
ddorwin 2014/05/05 18:44:45 FYI, MediaKeys.setServerCertificate() is now an ex
+ public:
+ MediaKeysSessionPromise(PromiseResolvedCB resolve_cb,
ddorwin 2014/05/05 18:35:42 It's odd to be passing two different resolve optio
jrummell 2014/05/08 23:37:45 Done.
+ PromiseResolvedWithSessionCB resolve_with_session_cb,
+ PromiseRejectedCB rejected_cb);
+ virtual ~MediaKeysSessionPromise();
ddorwin 2014/05/05 18:35:42 None of these need to be virtual.
jrummell 2014/05/08 23:37:45 The promises are overridden in a couple of places
+
+ // Used to indicate that UpdateSession()/ReleaseSession() has successfully
+ // completed.
+ virtual void resolve();
+
+ // Used to indicate that CreateSession()/LoadSession() has successfully
+ // completed. |web_session_id| is the ID of the new session created.
+ virtual void resolve(const std::string& web_session_id);
xhwang 2014/05/05 20:46:42 It's odd to pass Promises with two resolve() funct
jrummell 2014/05/08 23:37:45 Done.
+
+ // Used to indicate that the operation failed. |error_name| should match one
+ // of the W3C DOM error names (http://www.w3.org/TR/dom/#error-names-table).
+ // |system_code| is a Key System-specific value for the error that occurred,
+ // or 0 if there is no associated status code or such status codes are not
+ // supported by the Key System. |error_message| is optional.
+ virtual void reject(const std::string& error_name,
+ uint32 system_code,
+ const std::string& error_message);
+
+ protected:
+ MediaKeysSessionPromise();
+
+ private:
+ PromiseResolvedCB resolve_cb_;
+ PromiseResolvedWithSessionCB resolve_with_session_cb_;
+ PromiseRejectedCB rejected_cb_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaKeysSessionPromise);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_MEDIA_KEYS_SESSION_PROMISE_H_

Powered by Google App Engine
This is Rietveld 408576698