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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.cpp

Issue 1702223002: PaymentRequest API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/JSONValuesForV8.h" 5 #include "bindings/core/v8/JSONValuesForV8.h"
6
7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/V8Binding.h"
6 9
7 namespace blink { 10 namespace blink {
8 11
9 static String coreString(v8::Local<v8::String> v8String) 12 static String coreString(v8::Local<v8::String> v8String)
10 { 13 {
11 int length = v8String->Length(); 14 int length = v8String->Length();
12 UChar* buffer; 15 UChar* buffer;
13 String result = String::createUninitialized(length, buffer); 16 String result = String::createUninitialized(length, buffer);
14 v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length); 17 v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
15 return result; 18 return result;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (!propertyValue) 79 if (!propertyValue)
77 return nullptr; 80 return nullptr;
78 jsonObject->setValue(coreString(propertyName), propertyValue); 81 jsonObject->setValue(coreString(propertyName), propertyValue);
79 } 82 }
80 return jsonObject; 83 return jsonObject;
81 } 84 }
82 ASSERT_NOT_REACHED(); 85 ASSERT_NOT_REACHED();
83 return nullptr; 86 return nullptr;
84 } 87 }
85 88
89 v8::Local<v8::Value> fromJSONString(v8::Local<v8::Context> context, const String & stringifiedJSON, ExceptionState& exceptionState)
haraken 2016/03/02 00:46:16 Nit: You can pass in ScriptState rather than v8::C
please use gerrit instead 2016/03/02 01:24:34 Done.
90 {
91 v8::Isolate* isolate = context->GetIsolate();
92 v8::Local<v8::Value> parsed;
93 v8::TryCatch tryCatch(isolate);
haraken 2016/03/02 00:46:16 Use scriptState->isolate().
please use gerrit instead 2016/03/02 01:24:34 Done.
94 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), pa rsed, tryCatch)) {
95 if (tryCatch.HasCaught())
96 exceptionState.rethrowV8Exception(tryCatch.Exception());
haraken 2016/03/02 00:46:16 Have you confirmed that this throws an exception a
please use gerrit instead 2016/03/02 01:24:34 For PaymentResponse, the stringified JSON comes fr
97 }
98
99 return parsed;
100 }
101
86 } // namespace blink 102 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/JSONValuesForV8.h ('k') | third_party/WebKit/Source/bindings/core/v8/v8.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698