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

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

Issue 1027593003: bindings: Use Maybe version of v8::String::NewFromUtf8() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 clearResolver(); 143 clearResolver();
144 } 144 }
145 145
146 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length) 146 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length)
147 { 147 {
148 if (m_resolver) { 148 if (m_resolver) {
149 ScriptPromiseResolver* resolver = m_resolver; 149 ScriptPromiseResolver* resolver = m_resolver;
150 ScriptState* scriptState = resolver->scriptState(); 150 ScriptState* scriptState = resolver->scriptState();
151 ScriptState::Scope scope(scriptState); 151 ScriptState::Scope scope(scriptState);
152 152
153 v8::Handle<v8::String> jsonString = v8::String::NewFromUtf8(scriptState- >isolate(), utf8Data, v8::String::kInternalizedString, length); 153 v8::Handle<v8::String> jsonString = v8AtomicString(scriptState->isolate( ), utf8Data, length);
154 154
155 v8::TryCatch exceptionCatcher; 155 v8::TryCatch exceptionCatcher;
156 v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString); 156 v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString);
157 if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) { 157 if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) {
158 ASSERT_NOT_REACHED(); 158 ASSERT_NOT_REACHED();
159 resolver->reject(DOMException::create(OperationError, "Failed inflat ing JWK JSON to object")); 159 resolver->reject(DOMException::create(OperationError, "Failed inflat ing JWK JSON to object"));
160 } else { 160 } else {
161 resolver->resolve(jsonDictionary); 161 resolver->resolve(jsonDictionary);
162 } 162 }
163 } 163 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 m_resolver = Resolver::create(scriptState, this).get(); 219 m_resolver = Resolver::create(scriptState, this).get();
220 } 220 }
221 } 221 }
222 222
223 ScriptPromise CryptoResultImpl::promise() 223 ScriptPromise CryptoResultImpl::promise()
224 { 224 {
225 return m_resolver ? m_resolver->promise() : ScriptPromise(); 225 return m_resolver ? m_resolver->promise() : ScriptPromise();
226 } 226 }
227 227
228 } // namespace blink 228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698