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

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: Fix Windows linking. 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/ScriptState.h"
9 #include "bindings/core/v8/V8Binding.h"
6 10
7 namespace blink { 11 namespace blink {
8 12
9 static String coreString(v8::Local<v8::String> v8String) 13 static String coreString(v8::Local<v8::String> v8String)
10 { 14 {
11 int length = v8String->Length(); 15 int length = v8String->Length();
12 UChar* buffer; 16 UChar* buffer;
13 String result = String::createUninitialized(length, buffer); 17 String result = String::createUninitialized(length, buffer);
14 v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length); 18 v8String->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
15 return result; 19 return result;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (!propertyValue) 80 if (!propertyValue)
77 return nullptr; 81 return nullptr;
78 jsonObject->setValue(coreString(propertyName), propertyValue); 82 jsonObject->setValue(coreString(propertyName), propertyValue);
79 } 83 }
80 return jsonObject; 84 return jsonObject;
81 } 85 }
82 ASSERT_NOT_REACHED(); 86 ASSERT_NOT_REACHED();
83 return nullptr; 87 return nullptr;
84 } 88 }
85 89
90 v8::Local<v8::Value> fromJSONString(ScriptState* scriptState, const String& stri ngifiedJSON, ExceptionState& exceptionState)
91 {
92 v8::Isolate* isolate = scriptState->isolate();
93 v8::Local<v8::Value> parsed;
94 v8::TryCatch tryCatch(isolate);
95 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), pa rsed, tryCatch)) {
96 if (tryCatch.HasCaught())
97 exceptionState.rethrowV8Exception(tryCatch.Exception());
98 }
99
100 return parsed;
101 }
102
86 } // namespace blink 103 } // 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