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

Unified Diff: Source/modules/crypto/SubtleCrypto.cpp

Issue 26004002: Decouple ScriptPromise creation from ScriptPromiseResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 2 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: Source/modules/crypto/SubtleCrypto.cpp
diff --git a/Source/modules/crypto/SubtleCrypto.cpp b/Source/modules/crypto/SubtleCrypto.cpp
index 6044176151770ea081623a634636d0b876e79345..f8532a6fbd90287245dbafcc3c4e3e2daecedf39 100644
--- a/Source/modules/crypto/SubtleCrypto.cpp
+++ b/Source/modules/crypto/SubtleCrypto.cpp
@@ -77,7 +77,8 @@ ScriptPromise startCryptoOperation(const Dictionary& rawAlgorithm, Key* key, Alg
const unsigned char* data = static_cast<const unsigned char*>(dataBuffer->baseAddress());
unsigned dataSize = dataBuffer->byteLength();
- RefPtr<CryptoResultImpl> result = CryptoResultImpl::create();
+ ScriptPromise promise = ScriptPromise::createPending();
+ RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(promise);
switch (operationType) {
case Encrypt:
@@ -100,7 +101,7 @@ ScriptPromise startCryptoOperation(const Dictionary& rawAlgorithm, Key* key, Alg
return ScriptPromise();
}
- return result->promise();
+ return promise;
}
} // namespace
@@ -145,9 +146,10 @@ ScriptPromise SubtleCrypto::generateKey(const Dictionary& rawAlgorithm, bool ext
if (!normalizeAlgorithm(rawAlgorithm, GenerateKey, algorithm, es))
return ScriptPromise();
- RefPtr<CryptoResultImpl> result = CryptoResultImpl::create();
+ ScriptPromise promise = ScriptPromise::createPending();
+ RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(promise);
WebKit::Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages, result->result());
- return result->promise();
+ return promise;
}
ScriptPromise SubtleCrypto::importKey(const String& rawFormat, ArrayBufferView* keyData, const Dictionary& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages, ExceptionState& es)
@@ -171,9 +173,10 @@ ScriptPromise SubtleCrypto::importKey(const String& rawFormat, ArrayBufferView*
const unsigned char* keyDataBytes = static_cast<unsigned char*>(keyData->baseAddress());
- RefPtr<CryptoResultImpl> result = CryptoResultImpl::create();
+ ScriptPromise promise = ScriptPromise::createPending();
+ RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(promise);
WebKit::Platform::current()->crypto()->importKey(format, keyDataBytes, keyData->byteLength(), algorithm, extractable, keyUsages, result->result());
- return result->promise();
+ return promise;
}
ScriptPromise SubtleCrypto::exportKey(const String& rawFormat, Key* key, ExceptionState& es)
@@ -192,9 +195,10 @@ ScriptPromise SubtleCrypto::exportKey(const String& rawFormat, Key* key, Excepti
return ScriptPromise();
}
- RefPtr<CryptoResultImpl> result = CryptoResultImpl::create();
+ ScriptPromise promise = ScriptPromise::createPending();
+ RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(promise);
WebKit::Platform::current()->crypto()->exportKey(format, key->key(), result->result());
- return result->promise();
+ return promise;
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698