OLD | NEW |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } else { | 193 } else { |
194 xmlHttpRequest->open(method, url, async, exceptionState); | 194 xmlHttpRequest->open(method, url, async, exceptionState); |
195 } | 195 } |
196 } else { | 196 } else { |
197 xmlHttpRequest->open(method, url, exceptionState); | 197 xmlHttpRequest->open(method, url, exceptionState); |
198 } | 198 } |
199 | 199 |
200 exceptionState.throwIfNeeded(); | 200 exceptionState.throwIfNeeded(); |
201 } | 201 } |
202 | 202 |
203 static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate) | |
204 { | |
205 // FIXME: add other document types. | |
206 return V8Document::hasInstance(value, isolate) || V8HTMLDocument::hasInstanc
e(value, isolate); | |
207 } | |
208 | |
209 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value
>& info) | |
210 { | |
211 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder()); | |
212 | |
213 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo
ntext(), xmlHttpRequest->url()); | |
214 | |
215 ExceptionState exceptionState(ExceptionState::ExecutionContext, "send", "XML
HttpRequest", info.Holder(), info.GetIsolate()); | |
216 if (info.Length() < 1) { | |
217 xmlHttpRequest->send(exceptionState); | |
218 } else { | |
219 v8::Handle<v8::Value> arg = info[0]; | |
220 if (isUndefinedOrNull(arg)) { | |
221 xmlHttpRequest->send(exceptionState); | |
222 } else if (isDocumentType(arg, info.GetIsolate())) { | |
223 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | |
224 Document* document = V8Document::toImpl(object); | |
225 ASSERT(document); | |
226 xmlHttpRequest->send(document, exceptionState); | |
227 } else if (V8Blob::hasInstance(arg, info.GetIsolate())) { | |
228 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | |
229 Blob* blob = V8Blob::toImpl(object); | |
230 ASSERT(blob); | |
231 xmlHttpRequest->send(blob, exceptionState); | |
232 } else if (V8FormData::hasInstance(arg, info.GetIsolate())) { | |
233 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | |
234 DOMFormData* domFormData = V8FormData::toImpl(object); | |
235 ASSERT(domFormData); | |
236 xmlHttpRequest->send(domFormData, exceptionState); | |
237 } else if (V8ArrayBuffer::hasInstance(arg, info.GetIsolate())) { | |
238 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | |
239 DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(object); | |
240 ASSERT(arrayBuffer); | |
241 xmlHttpRequest->send(arrayBuffer, exceptionState); | |
242 } else if (V8ArrayBufferView::hasInstance(arg, info.GetIsolate())) { | |
243 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | |
244 DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(obje
ct); | |
245 ASSERT(arrayBufferView); | |
246 xmlHttpRequest->send(arrayBufferView, exceptionState); | |
247 } else { | |
248 TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, argString, ar
g); | |
249 xmlHttpRequest->send(argString, exceptionState); | |
250 } | |
251 } | |
252 | |
253 exceptionState.throwIfNeeded(); | |
254 } | |
255 | |
256 } // namespace blink | 203 } // namespace blink |
OLD | NEW |