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

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: Use DOMRequestState for handle/context scope 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 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 CryptoResultImpl_h 31 #ifndef CryptoResultImpl_h
32 #define CryptoResultImpl_h 32 #define CryptoResultImpl_h
33 33
34 #include "bindings/v8/DOMRequestState.h"
34 #include "bindings/v8/ScriptPromise.h" 35 #include "bindings/v8/ScriptPromise.h"
36 #include "core/dom/ContextLifecycleObserver.h"
35 #include "core/platform/CryptoResult.h" 37 #include "core/platform/CryptoResult.h"
36 #include "public/platform/WebCrypto.h" 38 #include "public/platform/WebCrypto.h"
39 #include "wtf/Assertions.h"
37 #include "wtf/Forward.h" 40 #include "wtf/Forward.h"
41 #include "wtf/Threading.h"
38 42
39 namespace WebCore { 43 namespace WebCore {
40 44
41 class ScriptPromiseResolver; 45 class ScriptPromiseResolver;
46 class ScriptState;
abarth-chromium 2014/01/18 09:03:48 This looks unused now.
42 47
43 // Wrapper around a Promise to notify completion of the crypto operation. 48 // Wrapper around a Promise to notify completion of the crypto operation.
44 // Platform cannot know about Promises which are declared in bindings. 49 // Platform cannot know about Promises which are declared in bindings.
45 class CryptoResultImpl FINAL : public CryptoResult { 50 class CryptoResultImpl FINAL : public CryptoResult, public ContextLifecycleObser ver {
46 public: 51 public:
47 ~CryptoResultImpl(); 52 ~CryptoResultImpl();
48 53
49 static PassRefPtr<CryptoResultImpl> create(ScriptPromise); 54 static PassRefPtr<CryptoResultImpl> create(ScriptPromise);
50 55
51 virtual void completeWithError() OVERRIDE; 56 virtual void completeWithError() OVERRIDE;
52 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE; 57 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE;
53 virtual void completeWithBoolean(bool) OVERRIDE; 58 virtual void completeWithBoolean(bool) OVERRIDE;
54 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE; 59 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE;
55 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) OVERRIDE; 60 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) OVERRIDE;
56 61
57 private: 62 private:
58 explicit CryptoResultImpl(ScriptPromise); 63 CryptoResultImpl(ExecutionContext*, ScriptPromise);
59 void finish(); 64 void finish();
65 void CheckValidThread() const;
66
67 // Override from ContextLifecycleObserver
68 virtual void contextDestroyed() OVERRIDE;
69
70 // Returns true if the ExecutionContext is still alive and running.
71 bool canCompletePromise() const;
72
73 void clearPromiseResolver();
60 74
61 RefPtr<ScriptPromiseResolver> m_promiseResolver; 75 RefPtr<ScriptPromiseResolver> m_promiseResolver;
76 DOMRequestState m_requestState;
77
78 #if !ASSERT_DISABLED
79 ThreadIdentifier m_owningThread;
62 bool m_finished; 80 bool m_finished;
81 #endif
63 }; 82 };
64 83
65 } // namespace WebCore 84 } // namespace WebCore
66 85
67 #endif 86 #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