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

Unified Diff: Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp

Issue 96793002: Switch custom XMLHttpRequest bindings over to new-style ExceptionState. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Inline local binding in throwTypeError() Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ExceptionState.cpp ('k') | Source/core/xml/XMLHttpRequest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
diff --git a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index d9d56000f2313830b35291a1830152920a56ca52..02cd3a1ab0c8027135a904bf17ce6caa56cb73b8 100644
--- a/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -72,7 +72,7 @@ void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Valu
void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
- ExceptionState exceptionState(info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate());
ScriptValue text = xmlHttpRequest->responseText(exceptionState);
if (exceptionState.throwIfNeeded())
return;
@@ -97,11 +97,7 @@ void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI
{
v8::Isolate* isolate = info.GetIsolate();
- ExceptionState exceptionState(info.Holder(), isolate);
ScriptString jsonSource = xmlHttpRequest->responseJSONSource();
- if (exceptionState.throwIfNeeded())
- return;
-
if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) {
v8SetReturnValue(info, v8NullWithCheck(isolate));
return;
@@ -164,38 +160,37 @@ void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value
// open(method, url, async, user)
// open(method, url, async, user, passwd)
- if (info.Length() < 2) {
- throwTypeError(ExceptionMessages::failedToExecute("open", "XMLHttpRequest", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIsolate());
- return;
- }
-
- XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "XMLHttpRequest", info.Holder(), info.GetIsolate());
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]);
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1]);
+ if (info.Length() < 2) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
+ } else {
+ XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
- ExecutionContext* context = getExecutionContext();
- KURL url = context->completeURL(urlstring);
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]);
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1]);
- ExceptionState exceptionState(info.Holder(), info.GetIsolate());
+ ExecutionContext* context = getExecutionContext();
+ KURL url = context->completeURL(urlstring);
- if (info.Length() >= 3) {
- bool async = info[2]->BooleanValue();
+ if (info.Length() >= 3) {
+ bool async = info[2]->BooleanValue();
- if (info.Length() >= 4 && !info[3]->IsUndefined()) {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, user, info[3]);
+ if (info.Length() >= 4 && !info[3]->IsUndefined()) {
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, user, info[3]);
- if (info.Length() >= 5 && !info[4]->IsUndefined()) {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, password, info[4]);
- xmlHttpRequest->open(method, url, async, user, password, exceptionState);
+ if (info.Length() >= 5 && !info[4]->IsUndefined()) {
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, password, info[4]);
+ xmlHttpRequest->open(method, url, async, user, password, exceptionState);
+ } else {
+ xmlHttpRequest->open(method, url, async, user, exceptionState);
+ }
} else {
- xmlHttpRequest->open(method, url, async, user, exceptionState);
+ xmlHttpRequest->open(method, url, async, exceptionState);
}
} else {
- xmlHttpRequest->open(method, url, async, exceptionState);
+ xmlHttpRequest->open(method, url, exceptionState);
}
- } else {
- xmlHttpRequest->open(method, url, exceptionState);
}
exceptionState.throwIfNeeded();
@@ -213,7 +208,7 @@ void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value
InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionContext(), xmlHttpRequest->url());
- ExceptionState exceptionState(info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "send", "XMLHttpRequest", info.Holder(), info.GetIsolate());
if (info.Length() < 1)
xmlHttpRequest->send(exceptionState);
else {
« no previous file with comments | « Source/bindings/v8/ExceptionState.cpp ('k') | Source/core/xml/XMLHttpRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698