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

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

Issue 54283002: Rename |args| to |info| in V8 bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/dom/Document.h" 45 #include "core/dom/Document.h"
46 #include "core/fileapi/Stream.h" 46 #include "core/fileapi/Stream.h"
47 #include "core/inspector/InspectorInstrumentation.h" 47 #include "core/inspector/InspectorInstrumentation.h"
48 #include "core/workers/WorkerGlobalScope.h" 48 #include "core/workers/WorkerGlobalScope.h"
49 #include "core/xml/XMLHttpRequest.h" 49 #include "core/xml/XMLHttpRequest.h"
50 #include "wtf/ArrayBuffer.h" 50 #include "wtf/ArrayBuffer.h"
51 #include <v8.h> 51 #include <v8.h>
52 52
53 namespace WebCore { 53 namespace WebCore {
54 54
55 void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Valu e>& args) 55 void V8XMLHttpRequest::constructorCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info)
56 { 56 {
57 ExecutionContext* context = getExecutionContext(); 57 ExecutionContext* context = getExecutionContext();
58 58
59 RefPtr<SecurityOrigin> securityOrigin; 59 RefPtr<SecurityOrigin> securityOrigin;
60 if (context->isDocument()) { 60 if (context->isDocument()) {
61 if (DOMWrapperWorld* world = isolatedWorldForEnteredContext()) 61 if (DOMWrapperWorld* world = isolatedWorldForEnteredContext())
62 securityOrigin = world->isolatedWorldSecurityOrigin(); 62 securityOrigin = world->isolatedWorldSecurityOrigin();
63 } 63 }
64 64
65 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, secu rityOrigin); 65 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, secu rityOrigin);
66 66
67 v8::Handle<v8::Object> wrapper = args.Holder(); 67 v8::Handle<v8::Object> wrapper = info.Holder();
68 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re lease(), &wrapperTypeInfo, wrapper, args.GetIsolate(), WrapperConfiguration::Dep endent); 68 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re lease(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent);
69 args.GetReturnValue().Set(wrapper); 69 info.GetReturnValue().Set(wrapper);
70 } 70 }
71 71
72 void V8XMLHttpRequest::responseTextAttributeGetterCustom(v8::Local<v8::String> n ame, const v8::PropertyCallbackInfo<v8::Value>& info) 72 void V8XMLHttpRequest::responseTextAttributeGetterCustom(v8::Local<v8::String> n ame, const v8::PropertyCallbackInfo<v8::Value>& info)
73 { 73 {
74 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); 74 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
75 ExceptionState es(info.GetIsolate()); 75 ExceptionState es(info.GetIsolate());
76 ScriptValue text = xmlHttpRequest->responseText(es); 76 ScriptValue text = xmlHttpRequest->responseText(es);
77 if (es.throwIfNeeded()) 77 if (es.throwIfNeeded())
78 return; 78 return;
79 if (text.hasNoValue()) { 79 if (text.hasNoValue()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(); 149 ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer();
150 if (arrayBuffer) { 150 if (arrayBuffer) {
151 arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationOb server::instance()); 151 arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationOb server::instance());
152 } 152 }
153 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest); 153 v8SetReturnValueFast(info, arrayBuffer, xmlHttpRequest);
154 return; 154 return;
155 } 155 }
156 } 156 }
157 } 157 }
158 158
159 void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& args) 159 void V8XMLHttpRequest::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& info)
160 { 160 {
161 // Four cases: 161 // Four cases:
162 // open(method, url) 162 // open(method, url)
163 // open(method, url, async) 163 // open(method, url, async)
164 // open(method, url, async, user) 164 // open(method, url, async, user)
165 // open(method, url, async, user, passwd) 165 // open(method, url, async, user, passwd)
166 166
167 if (args.Length() < 2) { 167 if (info.Length() < 2) {
168 throwTypeError(ExceptionMessages::failedToExecute("open", "XMLHttpReques t", ExceptionMessages::notEnoughArguments(2, args.Length())), args.GetIsolate()) ; 168 throwTypeError(ExceptionMessages::failedToExecute("open", "XMLHttpReques t", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIsolate()) ;
169 return; 169 return;
170 } 170 }
171 171
172 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); 172 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
173 173
174 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, args[0]); 174 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]);
175 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, args[1]) ; 175 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1]) ;
176 176
177 ExecutionContext* context = getExecutionContext(); 177 ExecutionContext* context = getExecutionContext();
178 KURL url = context->completeURL(urlstring); 178 KURL url = context->completeURL(urlstring);
179 179
180 ExceptionState es(args.GetIsolate()); 180 ExceptionState es(info.GetIsolate());
181 181
182 if (args.Length() >= 3) { 182 if (info.Length() >= 3) {
183 bool async = args[2]->BooleanValue(); 183 bool async = info[2]->BooleanValue();
184 184
185 if (args.Length() >= 4 && !args[3]->IsUndefined()) { 185 if (info.Length() >= 4 && !info[3]->IsUndefined()) {
186 String user = toWebCoreStringWithNullCheck(args[3]); 186 String user = toWebCoreStringWithNullCheck(info[3]);
187 187
188 if (args.Length() >= 5 && !args[4]->IsUndefined()) { 188 if (info.Length() >= 5 && !info[4]->IsUndefined()) {
189 String passwd = toWebCoreStringWithNullCheck(args[4]); 189 String passwd = toWebCoreStringWithNullCheck(info[4]);
190 xmlHttpRequest->open(method, url, async, user, passwd, es); 190 xmlHttpRequest->open(method, url, async, user, passwd, es);
191 } else { 191 } else {
192 xmlHttpRequest->open(method, url, async, user, es); 192 xmlHttpRequest->open(method, url, async, user, es);
193 } 193 }
194 } else { 194 } else {
195 xmlHttpRequest->open(method, url, async, es); 195 xmlHttpRequest->open(method, url, async, es);
196 } 196 }
197 } else { 197 } else {
198 xmlHttpRequest->open(method, url, es); 198 xmlHttpRequest->open(method, url, es);
199 } 199 }
200 200
201 es.throwIfNeeded(); 201 es.throwIfNeeded();
202 } 202 }
203 203
204 static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate, Wr apperWorldType currentWorldType) 204 static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate, Wr apperWorldType currentWorldType)
205 { 205 {
206 // FIXME: add other document types. 206 // FIXME: add other document types.
207 return V8Document::HasInstance(value, isolate, currentWorldType) || V8HTMLDo cument::HasInstance(value, isolate, currentWorldType); 207 return V8Document::HasInstance(value, isolate, currentWorldType) || V8HTMLDo cument::HasInstance(value, isolate, currentWorldType);
208 } 208 }
209 209
210 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& args) 210 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& info)
211 { 211 {
212 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); 212 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
213 213
214 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo ntext(), xmlHttpRequest->url()); 214 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo ntext(), xmlHttpRequest->url());
215 215
216 ExceptionState es(args.GetIsolate()); 216 ExceptionState es(info.GetIsolate());
217 if (args.Length() < 1) 217 if (info.Length() < 1)
218 xmlHttpRequest->send(es); 218 xmlHttpRequest->send(es);
219 else { 219 else {
220 v8::Handle<v8::Value> arg = args[0]; 220 v8::Handle<v8::Value> arg = info[0];
221 WrapperWorldType currentWorldType = worldType(args.GetIsolate()); 221 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
222 if (isUndefinedOrNull(arg)) 222 if (isUndefinedOrNull(arg)) {
223 xmlHttpRequest->send(es); 223 xmlHttpRequest->send(es);
224 else if (isDocumentType(arg, args.GetIsolate(), currentWorldType)) { 224 } else if (isDocumentType(arg, info.GetIsolate(), currentWorldType)) {
225 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 225 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
226 Document* document = V8Document::toNative(object); 226 Document* document = V8Document::toNative(object);
227 ASSERT(document); 227 ASSERT(document);
228 xmlHttpRequest->send(document, es); 228 xmlHttpRequest->send(document, es);
229 } else if (V8Blob::HasInstance(arg, args.GetIsolate(), currentWorldType) ) { 229 } else if (V8Blob::HasInstance(arg, info.GetIsolate(), currentWorldType) ) {
230 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 230 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
231 Blob* blob = V8Blob::toNative(object); 231 Blob* blob = V8Blob::toNative(object);
232 ASSERT(blob); 232 ASSERT(blob);
233 xmlHttpRequest->send(blob, es); 233 xmlHttpRequest->send(blob, es);
234 } else if (V8FormData::HasInstance(arg, args.GetIsolate(), currentWorldT ype)) { 234 } else if (V8FormData::HasInstance(arg, info.GetIsolate(), currentWorldT ype)) {
235 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 235 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
236 DOMFormData* domFormData = V8FormData::toNative(object); 236 DOMFormData* domFormData = V8FormData::toNative(object);
237 ASSERT(domFormData); 237 ASSERT(domFormData);
238 xmlHttpRequest->send(domFormData, es); 238 xmlHttpRequest->send(domFormData, es);
239 } else if (V8ArrayBuffer::HasInstance(arg, args.GetIsolate(), currentWor ldType)) { 239 } else if (V8ArrayBuffer::HasInstance(arg, info.GetIsolate(), currentWor ldType)) {
240 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 240 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
241 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object); 241 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object);
242 ASSERT(arrayBuffer); 242 ASSERT(arrayBuffer);
243 xmlHttpRequest->send(arrayBuffer, es); 243 xmlHttpRequest->send(arrayBuffer, es);
244 } else if (V8ArrayBufferView::HasInstance(arg, args.GetIsolate(), curren tWorldType)) { 244 } else if (V8ArrayBufferView::HasInstance(arg, info.GetIsolate(), curren tWorldType)) {
245 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 245 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
246 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(objec t); 246 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(objec t);
247 ASSERT(arrayBufferView); 247 ASSERT(arrayBufferView);
248 xmlHttpRequest->send(arrayBufferView, es); 248 xmlHttpRequest->send(arrayBufferView, es);
249 } else 249 } else {
250 xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), es); 250 xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), es);
251 }
251 } 252 }
252 253
253 es.throwIfNeeded(); 254 es.throwIfNeeded();
254 } 255 }
255 256
256 } // namespace WebCore 257 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8WorkerGlobalScopeCustom.cpp ('k') | Source/bindings/v8/custom/V8XSLTProcessorCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698