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 11 matching lines...) Expand all Loading... |
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 #include "config.h" | 31 #include "config.h" |
| 32 #include "public/platform/WebArrayBuffer.h" |
32 #include "public/platform/WebCrypto.h" | 33 #include "public/platform/WebCrypto.h" |
| 34 #include <string.h> |
33 | 35 |
34 namespace WebKit { | 36 namespace WebKit { |
35 | 37 |
36 // FIXME: Assert that these methods are called from the right thread. | 38 void WebCryptoResult::completeWithError() |
37 | |
38 void WebCryptoOperationResult::initializationFailed() | |
39 { | |
40 m_impl->initializationFailed(); | |
41 reset(); | |
42 } | |
43 | |
44 void WebCryptoOperationResult::initializationSucceeded(WebCryptoOperation* op) | |
45 { | |
46 m_impl->initializationSucceeded(op); | |
47 reset(); | |
48 } | |
49 | |
50 void WebCryptoOperationResult::completeWithError() | |
51 { | 39 { |
52 m_impl->completeWithError(); | 40 m_impl->completeWithError(); |
53 reset(); | 41 reset(); |
54 } | 42 } |
55 | 43 |
56 void WebCryptoOperationResult::completeWithArrayBuffer(const WebArrayBuffer& buf
fer) | 44 void WebCryptoResult::completeWithBuffer(const WebArrayBuffer& buffer) |
57 { | 45 { |
58 m_impl->completeWithArrayBuffer(buffer); | 46 m_impl->completeWithBuffer(buffer); |
59 reset(); | 47 reset(); |
60 } | 48 } |
61 | 49 |
62 void WebCryptoOperationResult::completeWithBoolean(bool b) | 50 void WebCryptoResult::completeWithBuffer(const void* bytes, size_t bytesSize) |
| 51 { |
| 52 WebArrayBuffer buffer = WebKit::WebArrayBuffer::create(bytesSize, 1); |
| 53 memcpy(buffer.data(), bytes, bytesSize); |
| 54 completeWithBuffer(buffer); |
| 55 } |
| 56 |
| 57 void WebCryptoResult::completeWithBoolean(bool b) |
63 { | 58 { |
64 m_impl->completeWithBoolean(b); | 59 m_impl->completeWithBoolean(b); |
65 reset(); | 60 reset(); |
66 } | 61 } |
67 | 62 |
68 void WebCryptoOperationResult::reset() | 63 void WebCryptoResult::completeWithKey(const WebCryptoKey& key) |
69 { | |
70 m_impl.reset(); | |
71 } | |
72 | |
73 void WebCryptoOperationResult::assign(const WebCryptoOperationResult& o) | |
74 { | |
75 m_impl = o.m_impl; | |
76 } | |
77 | |
78 void WebCryptoOperationResult::assign(WebCryptoOperationResultPrivate* impl) | |
79 { | |
80 m_impl = impl; | |
81 } | |
82 | |
83 void WebCryptoKeyOperationResult::initializationFailed() | |
84 { | |
85 m_impl->initializationFailed(); | |
86 reset(); | |
87 } | |
88 | |
89 void WebCryptoKeyOperationResult::initializationSucceeded(WebCryptoKeyOperation*
op) | |
90 { | |
91 m_impl->initializationSucceeded(op); | |
92 reset(); | |
93 } | |
94 | |
95 void WebCryptoKeyOperationResult::completeWithError() | |
96 { | |
97 m_impl->completeWithError(); | |
98 reset(); | |
99 } | |
100 | |
101 void WebCryptoKeyOperationResult::completeWithKey(const WebCryptoKey& key) | |
102 { | 64 { |
103 m_impl->completeWithKey(key); | 65 m_impl->completeWithKey(key); |
104 reset(); | 66 reset(); |
105 } | 67 } |
106 | 68 |
107 void WebCryptoKeyOperationResult::reset() | 69 void WebCryptoResult::reset() |
108 { | 70 { |
109 m_impl.reset(); | 71 m_impl.reset(); |
110 } | 72 } |
111 | 73 |
112 void WebCryptoKeyOperationResult::assign(const WebCryptoKeyOperationResult& o) | 74 void WebCryptoResult::assign(const WebCryptoResult& o) |
113 { | 75 { |
114 m_impl = o.m_impl; | 76 m_impl = o.m_impl; |
115 } | 77 } |
116 | 78 |
117 void WebCryptoKeyOperationResult::assign(WebCryptoKeyOperationResultPrivate* imp
l) | 79 void WebCryptoResult::assign(WebCryptoResultPrivate* impl) |
118 { | 80 { |
119 m_impl = impl; | 81 m_impl = impl; |
120 } | 82 } |
121 | 83 |
122 } // namespace WebKit | 84 } // namespace WebKit |
OLD | NEW |