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

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

Issue 1031783003: Add V8ObjectBuilder helper and use in modules/crypto/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use "const String&" Created 5 years, 9 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
« no previous file with comments | « Source/modules/crypto/CryptoKey.cpp ('k') | no next file » | 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/crypto/CryptoResultImpl.h" 32 #include "modules/crypto/CryptoResultImpl.h"
33 33
34 #include "bindings/core/v8/Dictionary.h" 34 #include "bindings/core/v8/Dictionary.h"
35 #include "bindings/core/v8/ScriptPromiseResolver.h" 35 #include "bindings/core/v8/ScriptPromiseResolver.h"
36 #include "bindings/core/v8/ScriptState.h" 36 #include "bindings/core/v8/ScriptState.h"
37 #include "bindings/core/v8/V8ArrayBuffer.h" 37 #include "bindings/core/v8/V8ArrayBuffer.h"
38 #include "bindings/core/v8/V8Binding.h" 38 #include "bindings/core/v8/V8Binding.h"
39 #include "bindings/core/v8/V8ObjectBuilder.h"
39 #include "bindings/modules/v8/V8CryptoKey.h" 40 #include "bindings/modules/v8/V8CryptoKey.h"
40 #include "core/dom/ContextLifecycleObserver.h" 41 #include "core/dom/ContextLifecycleObserver.h"
41 #include "core/dom/DOMArrayBuffer.h" 42 #include "core/dom/DOMArrayBuffer.h"
42 #include "core/dom/DOMError.h" 43 #include "core/dom/DOMError.h"
43 #include "core/dom/DOMException.h" 44 #include "core/dom/DOMException.h"
44 #include "core/dom/ExecutionContext.h" 45 #include "core/dom/ExecutionContext.h"
45 #include "modules/crypto/CryptoKey.h" 46 #include "modules/crypto/CryptoKey.h"
46 #include "modules/crypto/NormalizeAlgorithm.h" 47 #include "modules/crypto/NormalizeAlgorithm.h"
47 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
48 #include "public/platform/WebCryptoAlgorithm.h" 49 #include "public/platform/WebCryptoAlgorithm.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 m_resolver->resolve(CryptoKey::create(key)); 176 m_resolver->resolve(CryptoKey::create(key));
176 clearResolver(); 177 clearResolver();
177 } 178 }
178 179
179 void CryptoResultImpl::completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey) 180 void CryptoResultImpl::completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey)
180 { 181 {
181 if (m_resolver) { 182 if (m_resolver) {
182 ScriptState* scriptState = m_resolver->scriptState(); 183 ScriptState* scriptState = m_resolver->scriptState();
183 ScriptState::Scope scope(scriptState); 184 ScriptState::Scope scope(scriptState);
184 185
185 Dictionary keyPair = Dictionary::createEmpty(scriptState->isolate()); 186 V8ObjectBuilder keyPair(scriptState);
186 187
187 v8::Handle<v8::Value> publicKeyValue = toV8(CryptoKey::create(publicKey) , scriptState->context()->Global(), scriptState->isolate()); 188 keyPair.add("publicKey", ScriptValue::from(scriptState, CryptoKey::creat e(publicKey)));
188 v8::Handle<v8::Value> privateKeyValue = toV8(CryptoKey::create(privateKe y), scriptState->context()->Global(), scriptState->isolate()); 189 keyPair.add("privateKey", ScriptValue::from(scriptState, CryptoKey::crea te(privateKey)));
189
190 keyPair.set("publicKey", publicKeyValue);
191 keyPair.set("privateKey", privateKeyValue);
192 190
193 m_resolver->resolve(keyPair.v8Value()); 191 m_resolver->resolve(keyPair.v8Value());
194 } 192 }
195 clearResolver(); 193 clearResolver();
196 } 194 }
197 195
198 bool CryptoResultImpl::cancelled() const 196 bool CryptoResultImpl::cancelled() const
199 { 197 {
200 return acquireLoad(&m_cancelled); 198 return acquireLoad(&m_cancelled);
201 } 199 }
(...skipping 15 matching lines...) Expand all
217 m_resolver = Resolver::create(scriptState, this).get(); 215 m_resolver = Resolver::create(scriptState, this).get();
218 } 216 }
219 } 217 }
220 218
221 ScriptPromise CryptoResultImpl::promise() 219 ScriptPromise CryptoResultImpl::promise()
222 { 220 {
223 return m_resolver ? m_resolver->promise() : ScriptPromise(); 221 return m_resolver ? m_resolver->promise() : ScriptPromise();
224 } 222 }
225 223
226 } // namespace blink 224 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/crypto/CryptoKey.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698