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

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: Use a wrapper for the result rather than raw pointer 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 28 matching lines...) Expand all
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/RefCounted.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class ScriptPromiseResolver; 45 class ScriptPromiseResolver;
46 46
47 typedef int ExceptionCode; 47 typedef int ExceptionCode;
48 48
49 class CryptoOperation : public ScriptWrappable, public WebKit::WebCryptoOperatio nResult, public RefCounted<CryptoOperation> { 49 class CryptoOperation : public ScriptWrappable, public RefCounted<CryptoOperatio n> {
50 public: 50 public:
51 ~CryptoOperation(); 51 ~CryptoOperation();
52 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, ExceptionCode*); 52 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&) ;
53 53
54 CryptoOperation* process(ArrayBuffer* data); 54 CryptoOperation* process(ArrayBuffer* data);
55 CryptoOperation* process(ArrayBufferView* data); 55 CryptoOperation* process(ArrayBufferView* data);
56 56
57 ScriptObject finish(); 57 ScriptObject finish();
58 ScriptObject abort(); 58 ScriptObject abort();
59 59
60 Algorithm* algorithm(); 60 Algorithm* algorithm();
61 61
62 // Implementation of WebKit::WebCryptoOperationResult. 62 void initializationFailed();
63 virtual void initializationFailed() OVERRIDE; 63 void initializationSucceeded(WebKit::WebCryptoOperation*);
64 virtual void initializationSucceded(WebKit::WebCryptoOperation*) OVERRIDE; 64 void completeWithError();
65 virtual void completeWithError() OVERRIDE; 65 void completeWithArrayBuffer(const WebKit::WebArrayBuffer&);
66 virtual void completeWithArrayBuffer(const WebKit::WebArrayBuffer&) OVERRIDE ; 66
67 CryptoOperation* returnValue(ExceptionCode&);
67 68
68 private: 69 private:
69 enum State { 70 enum State {
70 // Constructing the WebCryptoOperation. 71 // Constructing the WebCryptoOperation.
71 Initializing, 72 Initializing,
72 73
73 // Accepting calls to process(). 74 // Accepting calls to process().
74 Processing, 75 Processing,
75 76
76 // finish() has been called, but the Promise has not been resolved yet. 77 // finish() has been called, but the Promise has not been resolved yet.
77 Finishing, 78 Finishing,
78 79
79 // The operation either: 80 // The operation either:
80 // - completed successfully 81 // - completed successfully
81 // - failed 82 // - failed
82 // - was aborted 83 // - was aborted
83 Done, 84 Done,
84 }; 85 };
85 86
86 CryptoOperation(const WebKit::WebCryptoAlgorithm&, ExceptionCode*); 87 CryptoOperation(const WebKit::WebCryptoAlgorithm&);
abarth-chromium 2013/07/23 21:45:49 Please mark one-argument constructors "explicit"
eroman 2013/07/23 23:29:02 Done.
87 88
88 void process(const unsigned char*, size_t); 89 void process(const unsigned char*, size_t);
89 90
90 // Aborts and clears m_impl. If the operation has already comleted then 91 // Aborts and clears m_impl. If the operation has already comleted then
91 // returns false. 92 // returns false.
92 bool abortImpl(); 93 bool abortImpl();
93 94
94 ScriptPromiseResolver* promiseResolver(); 95 ScriptPromiseResolver* promiseResolver();
95 96
96 WebKit::WebCryptoAlgorithm m_algorithm; 97 WebKit::WebCryptoAlgorithm m_algorithm;
97 WebKit::WebCryptoOperation* m_impl; 98 WebKit::WebCryptoOperation* m_impl;
98 RefPtr<Algorithm> m_algorithmNode; 99 RefPtr<Algorithm> m_algorithmNode;
99 State m_state; 100 State m_state;
100 101
101 RefPtr<ScriptPromiseResolver> m_promiseResolver; 102 RefPtr<ScriptPromiseResolver> m_promiseResolver;
102 103
103 ExceptionCode* m_exceptionCode; 104 ExceptionCode m_exceptionCode;
104 }; 105 };
105 106
106 } // namespace WebCore 107 } // namespace WebCore
107 108
108 #endif 109 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698