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

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

Issue 2472753003: Move fromJSONString to V8Binding (Closed)
Patch Set: V2 Created 4 years, 1 month 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) 2008, 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 v8::Isolate* isolate = info.GetIsolate(); 77 v8::Isolate* isolate = info.GetIsolate();
78 78
79 ScriptString jsonSource = xmlHttpRequest->responseJSONSource(); 79 ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
80 if (jsonSource.isEmpty()) { 80 if (jsonSource.isEmpty()) {
81 v8SetReturnValue(info, v8::Null(isolate)); 81 v8SetReturnValue(info, v8::Null(isolate));
82 return; 82 return;
83 } 83 }
84 84
85 // Catch syntax error. Swallows an exception (when thrown) as the 85 // Catch syntax error. Swallows an exception (when thrown) as the
86 // spec says. https://xhr.spec.whatwg.org/#response-body 86 // spec says. https://xhr.spec.whatwg.org/#response-body
87 v8::TryCatch exceptionCatcher(isolate); 87 TrackExceptionState exceptionState;
haraken 2016/11/03 14:01:35 Use a normal ExceptionState instead of TrackExcept
rwlbuis 2016/11/03 14:12:59 Acknowledged.
88 v8::Local<v8::Value> json; 88 v8::Local<v8::Value> json = fromJSONString(
89 if (v8Call(v8::JSON::Parse(isolate, jsonSource.v8Value()), json, 89 isolate, toCoreString(jsonSource.v8Value()), exceptionState);
90 exceptionCatcher)) 90 if (exceptionState.hadException())
91 v8SetReturnValue(info, v8::Null(isolate));
92 else
91 v8SetReturnValue(info, json); 93 v8SetReturnValue(info, json);
92 else
93 v8SetReturnValue(info, v8::Null(isolate));
94 return; 94 return;
95 } 95 }
96 96
97 case XMLHttpRequest::ResponseTypeDocument: { 97 case XMLHttpRequest::ResponseTypeDocument: {
98 ExceptionState exceptionState(ExceptionState::GetterContext, "response", 98 ExceptionState exceptionState(ExceptionState::GetterContext, "response",
99 "XMLHttpRequest", info.Holder(), 99 "XMLHttpRequest", info.Holder(),
100 info.GetIsolate()); 100 info.GetIsolate());
101 Document* document = xmlHttpRequest->responseXML(exceptionState); 101 Document* document = xmlHttpRequest->responseXML(exceptionState);
102 v8SetReturnValueFast(info, document, xmlHttpRequest); 102 v8SetReturnValueFast(info, document, xmlHttpRequest);
103 return; 103 return;
(...skipping 13 matching lines...) Expand all
117 117
118 case XMLHttpRequest::ResponseTypeArrayBuffer: { 118 case XMLHttpRequest::ResponseTypeArrayBuffer: {
119 DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(); 119 DOMArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
120 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest); 120 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
121 return; 121 return;
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 } // namespace blink 126 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp ('k') | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698