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

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: reorder headers even though it violates style 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 CryptoOperation* finish();
58 CryptoOperation* abort();
48 59
49 Algorithm* algorithm(); 60 Algorithm* algorithm();
61 const ScriptValue& promise();
50 62
51 private: 63 private:
52 explicit CryptoOperation(const WebKit::WebCryptoAlgorithm&); 64 class Result;
65 friend class Result;
66
67 enum State {
68 // Accepting calls to process().
69 Processing,
70
71 // finish() has been called, but the Promise has not been resolved yet.
72 Finishing,
73
74 // The operation either:
75 // - completed successfully
76 // - failed
77 // - was aborted
78 Done,
79 };
80
81 CryptoOperation(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperatio n*);
82
83 void process(const unsigned char*, size_t);
53 84
54 WebKit::WebCryptoAlgorithm m_algorithm; 85 WebKit::WebCryptoAlgorithm m_algorithm;
86 WebKit::WebCryptoOperation* m_impl;
55 RefPtr<Algorithm> m_algorithmNode; 87 RefPtr<Algorithm> m_algorithmNode;
88 State m_state;
89
90 RefPtr<ScriptPromiseResolver> m_promiseResolver;
91 ScriptObject m_promise;
abarth-chromium 2013/07/12 03:53:24 This isn't good. You can't hold a ScriptObject as
eroman 2013/07/12 04:24:37 I have changed it so the accessor returns a copy o
92
93 OwnPtr<Result> m_result;
56 }; 94 };
57 95
58 } // namespace WebCore 96 } // namespace WebCore
59 97
60 #endif 98 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698