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

Side by Side Diff: Source/modules/crypto/CryptoOperation.h

Issue 19885002: WebCrypto: Add interfaces for importKey(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add testing interface 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 16 matching lines...) Expand all
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/ScriptObject.h"
35 #include "bindings/v8/ScriptWrappable.h" 35 #include "bindings/v8/ScriptWrappable.h"
36 #include "modules/crypto/Algorithm.h" 36 #include "modules/crypto/Algorithm.h"
37 #include "public/platform/WebCryptoAlgorithm.h"
37 #include "public/platform/WebCrypto.h" 38 #include "public/platform/WebCrypto.h"
38 #include "public/platform/WebCryptoAlgorithm.h"
39 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
40 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
41 #include "wtf/RefCounted.h" 41 #include "wtf/ThreadSafeRefCounted.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class ScriptPromiseResolver; 45 class ScriptPromiseResolver;
46 class ExceptionState; 46 class ExceptionState;
47 47
48 class CryptoOperation : public ScriptWrappable, public WebKit::WebCryptoOperatio nResult, public RefCounted<CryptoOperation> { 48 typedef int ExceptionCode;
49
50 class CryptoOperation : public ScriptWrappable, public ThreadSafeRefCounted<Cryp toOperation> {
49 public: 51 public:
50 ~CryptoOperation(); 52 ~CryptoOperation();
51 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, ExceptionState*); 53 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&) ;
52 54
53 CryptoOperation* process(ArrayBuffer* data); 55 CryptoOperation* process(ArrayBuffer* data);
54 CryptoOperation* process(ArrayBufferView* data); 56 CryptoOperation* process(ArrayBufferView* data);
55 57
56 ScriptObject finish(); 58 ScriptObject finish();
57 ScriptObject abort(); 59 ScriptObject abort();
58 60
59 Algorithm* algorithm(); 61 Algorithm* algorithm();
60 62
61 // Implementation of WebKit::WebCryptoOperationResult. 63 void initializationFailed();
62 virtual void initializationFailed() OVERRIDE; 64 void initializationSucceeded(WebKit::WebCryptoOperation*);
63 virtual void initializationSucceded(WebKit::WebCryptoOperation*) OVERRIDE; 65 void completeWithError();
64 virtual void completeWithError() OVERRIDE; 66 void completeWithArrayBuffer(const WebKit::WebArrayBuffer&);
65 virtual void completeWithArrayBuffer(const WebKit::WebArrayBuffer&) OVERRIDE ; 67
68 CryptoOperation* returnValue(ExceptionState&);
66 69
67 private: 70 private:
68 enum State { 71 enum State {
69 // Constructing the WebCryptoOperation. 72 // Constructing the WebCryptoOperation.
70 Initializing, 73 Initializing,
71 74
72 // Accepting calls to process(). 75 // Accepting calls to process().
73 Processing, 76 Processing,
74 77
75 // finish() has been called, but the Promise has not been resolved yet. 78 // finish() has been called, but the Promise has not been resolved yet.
76 Finishing, 79 Finishing,
77 80
78 // The operation either: 81 // The operation either:
79 // - completed successfully 82 // - completed successfully
80 // - failed 83 // - failed
81 // - was aborted 84 // - was aborted
82 Done, 85 Done,
83 }; 86 };
84 87
85 CryptoOperation(const WebKit::WebCryptoAlgorithm&, ExceptionState*); 88 explicit CryptoOperation(const WebKit::WebCryptoAlgorithm&);
86 89
87 void process(const unsigned char*, size_t); 90 void process(const unsigned char*, size_t);
88 91
89 // Aborts and clears m_impl. If the operation has already comleted then 92 // Aborts and clears m_impl. If the operation has already comleted then
90 // returns false. 93 // returns false.
91 bool abortImpl(); 94 bool abortImpl();
92 95
93 ScriptPromiseResolver* promiseResolver(); 96 ScriptPromiseResolver* promiseResolver();
94 97
95 WebKit::WebCryptoAlgorithm m_algorithm; 98 WebKit::WebCryptoAlgorithm m_algorithm;
96 WebKit::WebCryptoOperation* m_impl; 99 WebKit::WebCryptoOperation* m_impl;
97 RefPtr<Algorithm> m_algorithmNode; 100 RefPtr<Algorithm> m_algorithmNode;
98 State m_state; 101 State m_state;
99 102
100 RefPtr<ScriptPromiseResolver> m_promiseResolver; 103 RefPtr<ScriptPromiseResolver> m_promiseResolver;
101 104
102 ExceptionState* m_exceptionState; 105 ExceptionCode m_exceptionCode;
103 }; 106 };
104 107
105 } // namespace WebCore 108 } // namespace WebCore
106 109
107 #endif 110 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698