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 10 matching lines...) Expand all Loading... | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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 WorkerClients_h | 31 #ifndef CryptoResult_h |
32 #define WorkerClients_h | 32 #define CryptoResult_h |
33 | 33 |
34 #include "core/platform/Supplementable.h" | 34 #include "bindings/v8/ScriptObject.h" |
35 #include "public/platform/WebCrypto.h" | |
35 #include "wtf/Forward.h" | 36 #include "wtf/Forward.h" |
37 #include "wtf/ThreadSafeRefCounted.h" | |
36 | 38 |
37 namespace WebCore { | 39 namespace WebCore { |
38 | 40 |
39 // This is created on the main thread, passed to the worker thread and | 41 class ScriptPromiseResolver; |
40 // attached to WorkerGlobalScope when it is created. | 42 |
41 // This class can be used to provide "client" implementations to Workers. | 43 // Wrapper around a Promise to notify completion of the crypto operation. |
42 class WorkerClients : public Supplementable<WorkerClients> { | 44 class CryptoResult : public ThreadSafeRefCounted<CryptoResult> { |
eroman
2013/08/23 23:51:26
This class is unchanged except for adding a destru
| |
43 WTF_MAKE_NONCOPYABLE(WorkerClients); | |
44 public: | 45 public: |
45 static PassOwnPtr<WorkerClients> create() | 46 ~CryptoResult(); |
47 | |
48 static PassRefPtr<CryptoResult> create(); | |
49 | |
50 void completeWithError(); | |
51 void completeWithBuffer(const WebKit::WebArrayBuffer&); | |
52 void completeWithBoolean(bool); | |
53 void completeWithKey(const WebKit::WebCryptoKey&); | |
54 | |
55 WebKit::WebCryptoResult result() | |
46 { | 56 { |
47 return adoptPtr(new WorkerClients()); | 57 return WebKit::WebCryptoResult(this); |
48 } | 58 } |
49 | 59 |
50 virtual ~WorkerClients() { } | 60 ScriptObject promise(); |
51 | 61 |
52 private: | 62 private: |
53 WorkerClients() { } | 63 CryptoResult(); |
64 void finish(); | |
65 | |
66 RefPtr<ScriptPromiseResolver> m_promiseResolver; | |
67 bool m_finished; | |
54 }; | 68 }; |
55 | 69 |
56 } // namespace WebCore | 70 } // namespace WebCore |
57 | 71 |
58 #endif // WorkerClients_h | 72 #endif |
OLD | NEW |