Index: public/platform/WebCrypto.h |
diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h |
index 4b091d16929eccbd290a3af61ec04e6ba0eb4b08..0b8a5da8c895ef4aa5ab50e9465139b9b8bc0f31 100644 |
--- a/public/platform/WebCrypto.h |
+++ b/public/platform/WebCrypto.h |
@@ -32,12 +32,13 @@ |
#define WebCrypto_h |
#include "WebCommon.h" |
+#include "WebCryptoKey.h" |
namespace WebKit { |
class WebArrayBuffer; |
-class WebCryptoAlgorithm; |
-class WebCryptoKey; |
+class WebCryptoKeyOperation; |
+class WebCryptoKeyOperationResult; |
class WebCryptoOperation; |
class WebCryptoOperationResult; |
@@ -51,7 +52,7 @@ public: |
// |
// Let the WebCryptoOperationResult* be called "result". |
// |
- // Implementations can either: |
+ // Before returning, implementations can either: |
// |
// * Synchronously fail initialization by calling: |
// result->initializationFailed(errorDetails) |
@@ -86,6 +87,38 @@ public: |
// the cryptoOperation. |
virtual void digest(const WebCryptoAlgorithm&, WebCryptoOperationResult*) { } |
+ // The following methods begin an asynchronous single-part key operation. |
+ // |
+ // Let the WebCryptoKeyOperationResult* be called "result". |
+ // |
+ // Before returning, implementations can either: |
+ // |
+ // (a) Synchronously fail initialization by calling: |
+ // result->initializationFailed(errorDetails) |
+ // (this results in throwing a Javascript exception) |
+ // |
+ // (b) Synchronously complete the request (success or error) by calling: |
+ // result->completeWithXXX() |
+ // |
+ // (c) Defer completion by calling |
+ // result->initializationSucceeded(keyOperation) |
+ // |
+ // If asynchronous completion (c) was chosen, then the embedder can notify |
+ // completion after returning by calling result->completeWithXXX(). |
+ // |
+ // The keyOperation pointer MUST remain valid while it is "in progress". |
+ // The keyOperation is said to be "in progress" from the time after |
+ // result->initializationSucceded() has been called, up until either: |
+ // |
+ // - Blink calls keyOperation->abort() |
+ // OR |
+ // - Embedder calls result->completeWithXXX() |
+ // |
+ // Once the keyOperation is no longer "in progress" the "result" pointer |
+ // is no longer valid. At this time the embedder is responsible for freeing |
+ // the cryptoOperation. |
+ virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, size_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoKeyOperationResult*) { } |
+ |
protected: |
virtual ~WebCrypto() { } |
}; |
@@ -124,6 +157,28 @@ protected: |
virtual ~WebCryptoOperationResult() { } |
}; |
+class WebCryptoKeyOperation { |
+public: |
+ // Cancels the in-progress operation. |
+ // * Implementations should delete |this| after aborting. |
+ virtual void abort() = 0; |
+ |
+protected: |
+ virtual ~WebCryptoKeyOperation() { } |
+}; |
+ |
+class WebCryptoKeyOperationResult { |
+public: |
+ virtual void initializationFailed() = 0; |
+ virtual void initializationSucceeded(WebCryptoKeyOperation*) = 0; |
+ |
+ virtual void completeWithError() = 0; |
+ virtual void completeWithKey(const WebCryptoKey&) = 0; |
+ |
+protected: |
+ virtual ~WebCryptoKeyOperationResult() { } |
+}; |
+ |
} // namespace WebKit |
#endif |