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

Unified Diff: third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp

Issue 2056053003: Change MediaKeys.setServerCertificate() to return Promise<boolean> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « no previous file | third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp
index 104fd8030bdaf676787d7b9d2eb61d806ebb266b..fb8f9d8a000e25e6e43dbdcc96a19565694cfb67 100644
--- a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp
+++ b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp
@@ -80,6 +80,33 @@ private:
const Member<DOMArrayBuffer> m_data;
};
+// This class wraps the promise resolver used when setting the certificate
+// and is passed to Chromium to fullfill the promise. This implementation of
+// complete() will resolve the promise with true, while completeWithError()
+// will reject the promise with an exception. completeWithSession()
+// is not expected to be called, and will reject the promise.
+class SetCertificateResultPromise : public ContentDecryptionModuleResultPromise {
+public:
+ SetCertificateResultPromise(ScriptState* scriptState)
+ : ContentDecryptionModuleResultPromise(scriptState)
+ {
+ }
+
+ ~SetCertificateResultPromise() override
+ {
+ }
+
+ // ContentDecryptionModuleResult implementation.
+ void complete() override
+ {
+ // TODO(jrummell): The EME spec specifies that "If the Key System
+ // implementation does not support server certificates, return a
+ // promise resolved with false." Need to have chromium return a bool
+ // so that resolving with false is possible. http://crbug.com/618800.
+ resolve(true);
xhwang 2016/06/10 21:40:11 Can we translate completeWithError(NOT_SUPPORTED_E
jrummell 2016/06/10 23:01:15 Done. I checked all the calls for SetServerCertifi
+ }
+};
+
MediaKeys* MediaKeys::create(ExecutionContext* context, const WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm)
{
MediaKeys* mediaKeys = new MediaKeys(context, supportedSessionTypes, std::move(cdm));
@@ -155,7 +182,7 @@ ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO
DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCertificate.data(), serverCertificate.byteLength());
// 4. Let promise be a new promise.
- SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryptionModuleResultPromise(scriptState);
+ SetCertificateResultPromise* result = new SetCertificateResultPromise(scriptState);
ScriptPromise promise = result->promise();
// 5. Run the following steps asynchronously (documented in timerFired()).
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698