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

Side by Side Diff: Source/modules/crypto/CryptoResult.cpp

Issue 23338006: Cleanup: remove WebCryptoResultPrivate from blink API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove extra newline Created 7 years, 3 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/modules/crypto/CryptoResult.h ('k') | Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 "modules/crypto/CryptoResult.h"
33
34 #include "V8Key.h" // Must precede ScriptPromiseResolver.h
35 #include "bindings/v8/custom/V8ArrayBufferCustom.h" // Must precede ScriptPromis eResolver.h
36 #include "bindings/v8/ScriptPromiseResolver.h"
37 #include "modules/crypto/Key.h"
38 #include "modules/crypto/NormalizeAlgorithm.h"
39 #include "public/platform/Platform.h"
32 #include "public/platform/WebArrayBuffer.h" 40 #include "public/platform/WebArrayBuffer.h"
33 #include "public/platform/WebCrypto.h" 41 #include "public/platform/WebCrypto.h"
34 #include <string.h> 42 #include "public/platform/WebCryptoAlgorithm.h"
43 #include "wtf/ArrayBufferView.h"
35 44
36 namespace WebKit { 45 namespace WebCore {
37 46
38 void WebCryptoResult::completeWithError() 47 CryptoResult::~CryptoResult()
39 { 48 {
40 m_impl->completeWithError(); 49 ASSERT(m_finished);
41 reset();
42 } 50 }
43 51
44 void WebCryptoResult::completeWithBuffer(const WebArrayBuffer& buffer) 52 PassRefPtr<CryptoResult> CryptoResult::create()
45 { 53 {
46 RELEASE_ASSERT(!buffer.isNull()); 54 return adoptRef(new CryptoResult);
47 m_impl->completeWithBuffer(buffer);
48 reset();
49 } 55 }
50 56
51 void WebCryptoResult::completeWithBuffer(const void* bytes, size_t bytesSize) 57 void CryptoResult::completeWithError()
52 { 58 {
53 WebArrayBuffer buffer = WebKit::WebArrayBuffer::create(bytesSize, 1); 59 m_promiseResolver->reject(ScriptValue::createNull());
54 RELEASE_ASSERT(!buffer.isNull()); 60 finish();
55 memcpy(buffer.data(), bytes, bytesSize);
56 completeWithBuffer(buffer);
57 } 61 }
58 62
59 void WebCryptoResult::completeWithBoolean(bool b) 63 void CryptoResult::completeWithBuffer(const WebKit::WebArrayBuffer& buffer)
60 { 64 {
61 m_impl->completeWithBoolean(b); 65 m_promiseResolver->fulfill(PassRefPtr<ArrayBuffer>(buffer));
62 reset(); 66 finish();
63 } 67 }
64 68
65 void WebCryptoResult::completeWithKey(const WebCryptoKey& key) 69 void CryptoResult::completeWithBoolean(bool b)
66 { 70 {
67 m_impl->completeWithKey(key); 71 m_promiseResolver->fulfill(ScriptValue::createBoolean(b));
68 reset(); 72 finish();
69 } 73 }
70 74
71 void WebCryptoResult::reset() 75 void CryptoResult::completeWithKey(const WebKit::WebCryptoKey& key)
72 { 76 {
73 m_impl.reset(); 77 m_promiseResolver->fulfill(Key::create(key));
78 finish();
74 } 79 }
75 80
76 void WebCryptoResult::assign(const WebCryptoResult& o) 81 ScriptObject CryptoResult::promise()
77 { 82 {
78 m_impl = o.m_impl; 83 return m_promiseResolver->promise();
79 } 84 }
80 85
81 void WebCryptoResult::assign(WebCryptoResultPrivate* impl) 86 CryptoResult::CryptoResult()
87 : m_promiseResolver(ScriptPromiseResolver::create())
88 , m_finished(false) { }
89
90 void CryptoResult::finish()
82 { 91 {
83 m_impl = impl; 92 ASSERT(!m_finished);
93 m_finished = true;
84 } 94 }
85 95
86 } // namespace WebKit 96 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/crypto/CryptoResult.h ('k') | Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698