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 13 matching lines...) Expand all Loading... |
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; |
42 | 46 |
43 // Wrapper around a Promise to notify completion of the crypto operation. | 47 // Wrapper around a Promise to notify completion of the crypto operation. |
44 // Platform cannot know about Promises which are declared in bindings. | 48 // Platform cannot know about Promises which are declared in bindings. |
45 class CryptoResultImpl FINAL : public CryptoResult { | 49 class CryptoResultImpl FINAL : public CryptoResult, public ContextLifecycleObser
ver { |
46 public: | 50 public: |
47 ~CryptoResultImpl(); | 51 ~CryptoResultImpl(); |
48 | 52 |
49 static PassRefPtr<CryptoResultImpl> create(ScriptPromise); | 53 static PassRefPtr<CryptoResultImpl> create(ScriptPromise); |
50 | 54 |
51 virtual void completeWithError() OVERRIDE; | 55 virtual void completeWithError() OVERRIDE; |
52 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE; | 56 virtual void completeWithBuffer(const blink::WebArrayBuffer&) OVERRIDE; |
53 virtual void completeWithBoolean(bool) OVERRIDE; | 57 virtual void completeWithBoolean(bool) OVERRIDE; |
54 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE; | 58 virtual void completeWithKey(const blink::WebCryptoKey&) OVERRIDE; |
55 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const
blink::WebCryptoKey& privateKey) OVERRIDE; | 59 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const
blink::WebCryptoKey& privateKey) OVERRIDE; |
56 | 60 |
57 private: | 61 private: |
58 explicit CryptoResultImpl(ScriptPromise); | 62 CryptoResultImpl(ExecutionContext*, ScriptPromise); |
59 void finish(); | 63 void finish(); |
| 64 void CheckValidThread() const; |
| 65 |
| 66 // Override from ContextLifecycleObserver |
| 67 virtual void contextDestroyed() OVERRIDE; |
| 68 |
| 69 // Returns true if the ExecutionContext is still alive and running. |
| 70 bool canCompletePromise() const; |
| 71 |
| 72 void clearPromiseResolver(); |
60 | 73 |
61 RefPtr<ScriptPromiseResolver> m_promiseResolver; | 74 RefPtr<ScriptPromiseResolver> m_promiseResolver; |
| 75 DOMRequestState m_requestState; |
| 76 |
| 77 #if !ASSERT_DISABLED |
| 78 ThreadIdentifier m_owningThread; |
62 bool m_finished; | 79 bool m_finished; |
| 80 #endif |
63 }; | 81 }; |
64 | 82 |
65 } // namespace WebCore | 83 } // namespace WebCore |
66 | 84 |
67 #endif | 85 #endif |
OLD | NEW |