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

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

Issue 133253002: [webcrypto] Fix TODO regarding asynchronous completion of crypto operations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/platform/CryptoResult.h ('k') | Source/modules/crypto/CryptoResultImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CryptoResultImpl_h 31 #ifndef CryptoResultImpl_h
32 #define CryptoResultImpl_h 32 #define CryptoResultImpl_h
33 33
34 #include "bindings/v8/ScriptPromise.h" 34 #include "bindings/v8/ScriptPromise.h"
35 #include "core/platform/CryptoResult.h" 35 #include "core/platform/CryptoResult.h"
36 #include "public/platform/WebCrypto.h" 36 #include "public/platform/WebCrypto.h"
37 #include "wtf/Assertions.h"
37 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
39 #include "wtf/Threading.h"
38 40
39 namespace WebCore { 41 namespace WebCore {
40 42
41 class ScriptPromiseResolver; 43 class ScriptPromiseResolver;
44 class ScriptState;
42 45
43 // Wrapper around a Promise to notify completion of the crypto operation. 46 // Wrapper around a Promise to notify completion of the crypto operation.
44 // Platform cannot know about Promises which are declared in bindings. 47 // Platform cannot know about Promises which are declared in bindings.
45 class CryptoResultImpl : public CryptoResult { 48 class CryptoResultImpl : public CryptoResult {
46 public: 49 public:
47 ~CryptoResultImpl(); 50 ~CryptoResultImpl();
48 51
49 static PassRefPtr<CryptoResultImpl> create(ScriptPromise); 52 static PassRefPtr<CryptoResultImpl> create(ScriptPromise);
50 53
51 virtual void completeWithError() OVERRIDE; 54 virtual void completeWithError() OVERRIDE;
52 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE; 55 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE;
53 virtual void completeWithBoolean(bool) OVERRIDE; 56 virtual void completeWithBoolean(bool) OVERRIDE;
54 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE; 57 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE;
55 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) OVERRIDE; 58 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) OVERRIDE;
56 59
57 private: 60 private:
58 explicit CryptoResultImpl(ScriptPromise); 61 explicit CryptoResultImpl(ScriptPromise);
59 void finish(); 62 void finish();
63 void CheckValidThread() const;
60 64
61 RefPtr<ScriptPromiseResolver> m_promiseResolver; 65 RefPtr<ScriptPromiseResolver> m_promiseResolver;
66
67 // This ScriptState should outlive m_promiseResolver, as it is kept alive by
eroman 2014/01/10 05:21:13 Please confirm whether this interpretation is corr
abarth-chromium 2014/01/10 15:25:03 This looks wrong. Why should ScriptValue keep the
eroman 2014/01/10 19:10:26 Thanks abarth! I modeled this after FontFaceSet.c
abarth-chromium 2014/01/14 04:01:06 You shouldn't need to keep a ScriptState. Take a
eroman 2014/01/14 20:40:09 Would it be appropriate to make CryptoResultImpl i
68 // a ScriptValue held by the resolver.
69 ScriptState* m_scriptState;
70
71 #if !ASSERT_DISABLED
72 ThreadIdentifier m_owningThread;
62 bool m_finished; 73 bool m_finished;
74 #endif
63 }; 75 };
64 76
65 } // namespace WebCore 77 } // namespace WebCore
66 78
67 #endif 79 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/CryptoResult.h ('k') | Source/modules/crypto/CryptoResultImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698