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

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

Issue 170243007: [webcrypto] Make all of the crypto.subtle method failures asynchronous. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | « Source/modules/crypto/Key.h ('k') | Source/modules/crypto/NormalizeAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/Key.cpp
diff --git a/Source/modules/crypto/Key.cpp b/Source/modules/crypto/Key.cpp
index 67811f2702c7c8d254787e65903042d03ed36009..dbc2fdc8eafc6a289dce96caafb6a86aaebec810 100644
--- a/Source/modules/crypto/Key.cpp
+++ b/Source/modules/crypto/Key.cpp
@@ -34,7 +34,9 @@
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "modules/crypto/Algorithm.h"
+#include "platform/CryptoResult.h"
#include "public/platform/WebCryptoAlgorithmParams.h"
+#include "public/platform/WebString.h"
namespace WebCore {
@@ -177,15 +179,15 @@ Vector<String> Key::usages() const
return result;
}
-bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, AlgorithmOperation op, String& errorDetails) const
+bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, AlgorithmOperation op, CryptoResult* result) const
{
if (!(m_key.usages() & toKeyUsage(op))) {
- errorDetails = "key.usages does not permit this operation";
+ result->completeWithError("key.usages does not permit this operation");
return false;
}
if (m_key.algorithm().id() != algorithm.id()) {
- errorDetails = "key.algorithm does not match that of operation";
+ result->completeWithError("key.algorithm does not match that of operation");
return false;
}
@@ -198,7 +200,7 @@ bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, Algo
blink::WebCryptoAlgorithmId keyHash;
blink::WebCryptoAlgorithmId algorithmHash;
if (!getHmacHashId(m_key.algorithm(), keyHash) || !getHmacHashId(algorithm, algorithmHash) || keyHash != algorithmHash) {
- errorDetails = "key.algorithm does not match that of operation (HMAC's hash differs)";
+ result->completeWithError("key.algorithm does not match that of operation (HMAC's hash differs)");
return false;
}
}
@@ -206,7 +208,7 @@ bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, Algo
return true;
}
-bool Key::parseFormat(const String& formatString, blink::WebCryptoKeyFormat& format, ExceptionState& exceptionState)
+bool Key::parseFormat(const String& formatString, blink::WebCryptoKeyFormat& format, CryptoResult* result)
{
// There are few enough values that testing serially is fast enough.
if (formatString == "raw") {
@@ -226,17 +228,17 @@ bool Key::parseFormat(const String& formatString, blink::WebCryptoKeyFormat& for
return true;
}
- exceptionState.throwTypeError("Invalid keyFormat argument");
+ result->completeWithError("Invalid keyFormat argument");
return false;
}
-bool Key::parseUsageMask(const Vector<String>& usages, blink::WebCryptoKeyUsageMask& mask, ExceptionState& exceptionState)
+bool Key::parseUsageMask(const Vector<String>& usages, blink::WebCryptoKeyUsageMask& mask, CryptoResult* result)
{
mask = 0;
for (size_t i = 0; i < usages.size(); ++i) {
blink::WebCryptoKeyUsageMask usage = keyUsageStringToMask(usages[i]);
if (!usage) {
- exceptionState.throwTypeError("Invalid keyUsages argument");
+ result->completeWithError("Invalid keyUsages argument");
return false;
}
mask |= usage;
« no previous file with comments | « Source/modules/crypto/Key.h ('k') | Source/modules/crypto/NormalizeAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698