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

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

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "modules/crypto/NormalizeAlgorithm.h" 46 #include "modules/crypto/NormalizeAlgorithm.h"
47 #include "public/platform/Platform.h" 47 #include "public/platform/Platform.h"
48 #include "public/platform/WebCryptoAlgorithm.h" 48 #include "public/platform/WebCryptoAlgorithm.h"
49 #include "wtf/Atomics.h" 49 #include "wtf/Atomics.h"
50 50
51 namespace blink { 51 namespace blink {
52 52
53 static void rejectWithTypeError(const String& errorDetails, ScriptPromiseResolve r* resolver) 53 static void rejectWithTypeError(const String& errorDetails, ScriptPromiseResolve r* resolver)
54 { 54 {
55 // Duplicate some of the checks done by ScriptPromiseResolver. 55 // Duplicate some of the checks done by ScriptPromiseResolver.
56 if (!resolver->executionContext() || resolver->executionContext()->activeDOM ObjectsAreStopped()) 56 if (!resolver->getExecutionContext() || resolver->getExecutionContext()->act iveDOMObjectsAreStopped())
57 return; 57 return;
58 58
59 ScriptState::Scope scope(resolver->scriptState()); 59 ScriptState::Scope scope(resolver->getScriptState());
60 v8::Isolate* isolate = resolver->scriptState()->isolate(); 60 v8::Isolate* isolate = resolver->getScriptState()->isolate();
61 resolver->reject(v8::Exception::TypeError(v8String(isolate, errorDetails))); 61 resolver->reject(v8::Exception::TypeError(v8String(isolate, errorDetails)));
62 } 62 }
63 63
64 class CryptoResultImpl::Resolver final : public ScriptPromiseResolver { 64 class CryptoResultImpl::Resolver final : public ScriptPromiseResolver {
65 public: 65 public:
66 static Resolver* create(ScriptState* scriptState, CryptoResultImpl* result) 66 static Resolver* create(ScriptState* scriptState, CryptoResultImpl* result)
67 { 67 {
68 ASSERT(scriptState->contextIsValid()); 68 ASSERT(scriptState->contextIsValid());
69 Resolver* resolver = new Resolver(scriptState, result); 69 Resolver* resolver = new Resolver(scriptState, result);
70 resolver->suspendIfNeeded(); 70 resolver->suspendIfNeeded();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 ASSERT_NOT_REACHED(); 128 ASSERT_NOT_REACHED();
129 return 0; 129 return 0;
130 } 130 }
131 131
132 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState) 132 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
133 : m_resolver(Resolver::create(scriptState, this)) 133 : m_resolver(Resolver::create(scriptState, this))
134 , m_cancel(ResultCancel::create()) 134 , m_cancel(ResultCancel::create())
135 { 135 {
136 // Sync cancellation state. 136 // Sync cancellation state.
137 if (scriptState->executionContext()->activeDOMObjectsAreStopped()) 137 if (scriptState->getExecutionContext()->activeDOMObjectsAreStopped())
138 m_cancel->cancel(); 138 m_cancel->cancel();
139 } 139 }
140 140
141 CryptoResultImpl::~CryptoResultImpl() 141 CryptoResultImpl::~CryptoResultImpl()
142 { 142 {
143 ASSERT(!m_resolver); 143 ASSERT(!m_resolver);
144 } 144 }
145 145
146 DEFINE_TRACE(CryptoResultImpl) 146 DEFINE_TRACE(CryptoResultImpl)
147 { 147 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 m_resolver->resolve(DOMArrayBuffer::create(bytes, bytesSize)); 183 m_resolver->resolve(DOMArrayBuffer::create(bytes, bytesSize));
184 clearResolver(); 184 clearResolver();
185 } 185 }
186 186
187 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length) 187 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length)
188 { 188 {
189 if (!m_resolver) 189 if (!m_resolver)
190 return; 190 return;
191 191
192 ScriptState* scriptState = m_resolver->scriptState(); 192 ScriptState* scriptState = m_resolver->getScriptState();
193 ScriptState::Scope scope(scriptState); 193 ScriptState::Scope scope(scriptState);
194 194
195 v8::Local<v8::String> jsonString = v8AtomicString(scriptState->isolate(), ut f8Data, length); 195 v8::Local<v8::String> jsonString = v8AtomicString(scriptState->isolate(), ut f8Data, length);
196 196
197 v8::TryCatch exceptionCatcher(scriptState->isolate()); 197 v8::TryCatch exceptionCatcher(scriptState->isolate());
198 v8::Local<v8::Value> jsonDictionary; 198 v8::Local<v8::Value> jsonDictionary;
199 if (v8Call(v8::JSON::Parse(scriptState->isolate(), jsonString), jsonDictiona ry, exceptionCatcher)) 199 if (v8Call(v8::JSON::Parse(scriptState->isolate(), jsonString), jsonDictiona ry, exceptionCatcher))
200 m_resolver->resolve(jsonDictionary); 200 m_resolver->resolve(jsonDictionary);
201 else 201 else
202 m_resolver->reject(exceptionCatcher.Exception()); 202 m_resolver->reject(exceptionCatcher.Exception());
(...skipping 16 matching lines...) Expand all
219 219
220 m_resolver->resolve(CryptoKey::create(key)); 220 m_resolver->resolve(CryptoKey::create(key));
221 clearResolver(); 221 clearResolver();
222 } 222 }
223 223
224 void CryptoResultImpl::completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey) 224 void CryptoResultImpl::completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey)
225 { 225 {
226 if (!m_resolver) 226 if (!m_resolver)
227 return; 227 return;
228 228
229 ScriptState* scriptState = m_resolver->scriptState(); 229 ScriptState* scriptState = m_resolver->getScriptState();
230 ScriptState::Scope scope(scriptState); 230 ScriptState::Scope scope(scriptState);
231 231
232 V8ObjectBuilder keyPair(scriptState); 232 V8ObjectBuilder keyPair(scriptState);
233 233
234 keyPair.add("publicKey", ScriptValue::from(scriptState, CryptoKey::create(pu blicKey))); 234 keyPair.add("publicKey", ScriptValue::from(scriptState, CryptoKey::create(pu blicKey)));
235 keyPair.add("privateKey", ScriptValue::from(scriptState, CryptoKey::create(p rivateKey))); 235 keyPair.add("privateKey", ScriptValue::from(scriptState, CryptoKey::create(p rivateKey)));
236 236
237 m_resolver->resolve(keyPair.v8Value()); 237 m_resolver->resolve(keyPair.v8Value());
238 clearResolver(); 238 clearResolver();
239 } 239 }
240 240
241 void CryptoResultImpl::cancel() 241 void CryptoResultImpl::cancel()
242 { 242 {
243 ASSERT(m_cancel); 243 ASSERT(m_cancel);
244 m_cancel->cancel(); 244 m_cancel->cancel();
245 m_cancel.clear(); 245 m_cancel.clear();
246 clearResolver(); 246 clearResolver();
247 } 247 }
248 248
249 ScriptPromise CryptoResultImpl::promise() 249 ScriptPromise CryptoResultImpl::promise()
250 { 250 {
251 return m_resolver ? m_resolver->promise() : ScriptPromise(); 251 return m_resolver ? m_resolver->promise() : ScriptPromise();
252 } 252 }
253 253
254 } // namespace blink 254 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/crypto/CryptoKey.cpp ('k') | third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698