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

Unified Diff: Source/modules/crypto/CryptoOperation.h

Issue 19082002: WebCrypto: Add SHA-1 support to crypto.subtle.digest(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove an extra newline Created 7 years, 5 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/core/platform/chromium/support/WebArrayBuffer.cpp ('k') | Source/modules/crypto/CryptoOperation.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/CryptoOperation.h
diff --git a/Source/modules/crypto/CryptoOperation.h b/Source/modules/crypto/CryptoOperation.h
index 001747eb26e92fdea2ca96ba41e45434ac76e314..b26974dd9d66ca0e49bb83757d9af6833406e7f9 100644
--- a/Source/modules/crypto/CryptoOperation.h
+++ b/Source/modules/crypto/CryptoOperation.h
@@ -31,8 +31,10 @@
#ifndef CryptoOperation_h
#define CryptoOperation_h
+#include "bindings/v8/ScriptObject.h"
#include "bindings/v8/ScriptWrappable.h"
#include "modules/crypto/Algorithm.h"
+#include "public/platform/WebCrypto.h"
#include "public/platform/WebCryptoAlgorithm.h"
#include "wtf/Forward.h"
#include "wtf/PassRefPtr.h"
@@ -40,19 +42,59 @@
namespace WebCore {
+class ScriptPromiseResolver;
+
typedef int ExceptionCode;
class CryptoOperation : public ScriptWrappable, public RefCounted<CryptoOperation> {
public:
- static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm& algorithm) { return adoptRef(new CryptoOperation(algorithm)); }
+ ~CryptoOperation();
+ static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperation*);
+
+ CryptoOperation* process(ArrayBuffer* data);
+ CryptoOperation* process(ArrayBufferView* data);
+
+ ScriptObject finish();
+ ScriptObject abort();
Algorithm* algorithm();
private:
- explicit CryptoOperation(const WebKit::WebCryptoAlgorithm&);
+ class Result;
+ friend class Result;
+
+ enum State {
+ // Accepting calls to process().
+ Processing,
+
+ // finish() has been called, but the Promise has not been resolved yet.
+ Finishing,
+
+ // The operation either:
+ // - completed successfully
+ // - failed
+ // - was aborted
+ Done,
+ };
+
+ CryptoOperation(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperation*);
+
+ void process(const unsigned char*, size_t);
+
+ // Aborts and clears m_impl. If the operation has already comleted then
+ // returns false.
+ bool abortImpl();
+
+ ScriptPromiseResolver* promiseResolver();
WebKit::WebCryptoAlgorithm m_algorithm;
+ WebKit::WebCryptoOperation* m_impl;
RefPtr<Algorithm> m_algorithmNode;
+ State m_state;
+
+ RefPtr<ScriptPromiseResolver> m_promiseResolver;
+
+ OwnPtr<Result> m_result;
};
} // namespace WebCore
« no previous file with comments | « Source/core/platform/chromium/support/WebArrayBuffer.cpp ('k') | Source/modules/crypto/CryptoOperation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698