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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef CryptoOperation_h 31 #ifndef CryptoOperation_h
32 #define CryptoOperation_h 32 #define CryptoOperation_h
33 33
34 #include "bindings/v8/ScriptObject.h"
34 #include "bindings/v8/ScriptWrappable.h" 35 #include "bindings/v8/ScriptWrappable.h"
35 #include "modules/crypto/Algorithm.h" 36 #include "modules/crypto/Algorithm.h"
37 #include "public/platform/WebCrypto.h"
36 #include "public/platform/WebCryptoAlgorithm.h" 38 #include "public/platform/WebCryptoAlgorithm.h"
37 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
38 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
40 42
41 namespace WebCore { 43 namespace WebCore {
42 44
45 class ScriptPromiseResolver;
46
43 typedef int ExceptionCode; 47 typedef int ExceptionCode;
44 48
45 class CryptoOperation : public ScriptWrappable, public RefCounted<CryptoOperatio n> { 49 class CryptoOperation : public ScriptWrappable, public RefCounted<CryptoOperatio n> {
46 public: 50 public:
47 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm& algorithm) { return adoptRef(new CryptoOperation(algorithm)); } 51 ~CryptoOperation();
52 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperation*);
53
54 CryptoOperation* process(ArrayBuffer* data);
55 CryptoOperation* process(ArrayBufferView* data);
56
57 ScriptObject finish();
58 ScriptObject abort();
48 59
49 Algorithm* algorithm(); 60 Algorithm* algorithm();
50 61
51 private: 62 private:
52 explicit CryptoOperation(const WebKit::WebCryptoAlgorithm&); 63 class Result;
64 friend class Result;
65
66 enum State {
67 // Accepting calls to process().
68 Processing,
69
70 // finish() has been called, but the Promise has not been resolved yet.
71 Finishing,
72
73 // The operation either:
74 // - completed successfully
75 // - failed
76 // - was aborted
77 Done,
78 };
79
80 CryptoOperation(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperatio n*);
81
82 void process(const unsigned char*, size_t);
83
84 // Aborts and clears m_impl. If the operation has already comleted then
85 // returns false.
86 bool abortImpl();
87
88 ScriptPromiseResolver* promiseResolver();
53 89
54 WebKit::WebCryptoAlgorithm m_algorithm; 90 WebKit::WebCryptoAlgorithm m_algorithm;
91 WebKit::WebCryptoOperation* m_impl;
55 RefPtr<Algorithm> m_algorithmNode; 92 RefPtr<Algorithm> m_algorithmNode;
93 State m_state;
94
95 RefPtr<ScriptPromiseResolver> m_promiseResolver;
96
97 OwnPtr<Result> m_result;
56 }; 98 };
57 99
58 } // namespace WebCore 100 } // namespace WebCore
59 101
60 #endif 102 #endif
OLDNEW
« 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