OLD | NEW |
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 14 matching lines...) Expand all Loading... |
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/ScriptPromise.h" | 34 #include "bindings/v8/ScriptPromise.h" |
| 35 #include "core/dom/ContextLifecycleObserver.h" |
35 #include "core/platform/CryptoResult.h" | 36 #include "core/platform/CryptoResult.h" |
36 #include "public/platform/WebCrypto.h" | 37 #include "public/platform/WebCrypto.h" |
| 38 #include "wtf/Assertions.h" |
37 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 40 #include "wtf/Threading.h" |
38 | 41 |
39 namespace WebCore { | 42 namespace WebCore { |
40 | 43 |
| 44 class DOMWrapperWorld; |
41 class ScriptPromiseResolver; | 45 class ScriptPromiseResolver; |
| 46 class ScriptState; |
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*, DOMWrapperWorld*, 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; |
60 | 72 |
61 RefPtr<ScriptPromiseResolver> m_promiseResolver; | 73 RefPtr<ScriptPromiseResolver> m_promiseResolver; |
| 74 RefPtr<DOMWrapperWorld> m_world; |
| 75 |
| 76 #if !ASSERT_DISABLED |
| 77 ThreadIdentifier m_owningThread; |
62 bool m_finished; | 78 bool m_finished; |
| 79 #endif |
63 }; | 80 }; |
64 | 81 |
65 } // namespace WebCore | 82 } // namespace WebCore |
66 | 83 |
67 #endif | 84 #endif |
OLD | NEW |