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

Side by Side Diff: Source/core/platform/chromium/support/WebCrypto.cpp

Issue 19885002: WebCrypto: Add interfaces for importKey(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add testing interface Created 7 years, 5 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/core.gypi ('k') | Source/modules/crypto/CryptoOperation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "config.h"
32 #include "public/platform/WebCrypto.h"
33
34 #include "modules/crypto/CryptoOperation.h"
35 #include "modules/crypto/KeyOperation.h"
36
37 namespace WebKit {
38
39 // FIXME: Assert that these methods are called from the right thread.
40
41 WebCryptoOperationResult::WebCryptoOperationResult(WebCore::CryptoOperation* imp l)
42 : m_impl(impl)
43 , m_testInterface(0)
44 {
45 ASSERT(impl);
46 }
47
48 void WebCryptoOperationResult::initializationFailed()
49 {
50 if (m_testInterface) {
51 m_testInterface->initializationFailed();
52 m_testInterface = 0;
53 } else {
54 m_impl->initializationFailed();
55 m_impl.reset();
56 }
57 }
58
59 void WebCryptoOperationResult::initializationSucceeded(WebCryptoOperation* op)
60 {
61 if (m_testInterface) {
62 m_testInterface->initializationSucceeded(op);
63 m_testInterface = 0;
64 } else {
65 m_impl->initializationSucceeded(op);
66 m_impl.reset();
67 }
68 }
69
70 void WebCryptoOperationResult::completeWithError()
71 {
72 if (m_testInterface) {
73 m_testInterface->completeWithError();
74 m_testInterface = 0;
75 } else {
76 m_impl->completeWithError();
77 m_impl.reset();
78 }
79 }
80
81 void WebCryptoOperationResult::completeWithArrayBuffer(const WebArrayBuffer& buf fer)
82 {
83 if (m_testInterface) {
84 m_testInterface->completeWithArrayBuffer(buffer);
85 m_testInterface = 0;
86 } else {
87 m_impl->completeWithArrayBuffer(buffer);
88 m_impl.reset();
89 }
90 }
91
92 void WebCryptoOperationResult::reset()
93 {
94 m_impl.reset();
95 m_testInterface = 0;
96 }
97
98 void WebCryptoOperationResult::assign(const WebCryptoOperationResult& o)
99 {
100 m_impl = o.m_impl;
101 m_testInterface = o.m_testInterface;
102 }
103
104 WebCryptoKeyOperationResult::WebCryptoKeyOperationResult(WebCore::KeyOperation* impl)
105 : m_impl(impl)
106 , m_testInterface(0)
107 {
108 ASSERT(impl);
109 }
110
111 void WebCryptoKeyOperationResult::initializationFailed()
112 {
113 if (m_testInterface) {
114 m_testInterface->initializationFailed();
115 m_testInterface = 0;
abarth-chromium 2013/07/24 01:19:10 So much test-specific code...
116 } else {
117 m_impl->initializationFailed();
118 m_impl.reset();
119 }
120 }
121
122 void WebCryptoKeyOperationResult::initializationSucceeded(WebCryptoKeyOperation* op)
123 {
124 if (m_testInterface) {
125 m_testInterface->initializationSucceeded(op);
126 m_testInterface = 0;
127 } else {
128 m_impl->initializationSucceeded(op);
129 m_impl.reset();
130 }
131 }
132
133 void WebCryptoKeyOperationResult::completeWithError()
134 {
135 if (m_testInterface) {
136 m_testInterface->completeWithError();
137 m_testInterface = 0;
138 } else {
139 m_impl->completeWithError();
140 m_impl.reset();
141 }
142 }
143
144 void WebCryptoKeyOperationResult::completeWithKey(const WebCryptoKey& key)
145 {
146 if (m_testInterface) {
147 m_testInterface->completeWithKey(key);
148 m_testInterface = 0;
149 } else {
150 m_impl->completeWithKey(key);
151 m_impl.reset();
152 }
153 }
154
155 void WebCryptoKeyOperationResult::reset()
156 {
157 m_impl.reset();
158 m_testInterface = 0;
159 }
160
161 void WebCryptoKeyOperationResult::assign(const WebCryptoKeyOperationResult& o)
162 {
163 m_impl = o.m_impl;
164 m_testInterface = o.m_testInterface;
165 }
166
167 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/modules/crypto/CryptoOperation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698