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

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

Issue 537403002: bindings: Renames from/toInternalPointer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 3 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 | 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(c ontext, securityOrigin); 67 RefPtrWillBeRawPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(c ontext, securityOrigin);
68 68
69 v8::Handle<v8::Object> wrapper = info.Holder(); 69 v8::Handle<v8::Object> wrapper = info.Holder();
70 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re lease(), &wrapperTypeInfo, wrapper, info.GetIsolate()); 70 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re lease(), &wrapperTypeInfo, wrapper, info.GetIsolate());
71 info.GetReturnValue().Set(wrapper); 71 info.GetReturnValue().Set(wrapper);
72 } 72 }
73 73
74 void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallb ackInfo<v8::Value>& info) 74 void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallb ackInfo<v8::Value>& info)
75 { 75 {
76 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); 76 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
77 ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate()); 77 ExceptionState exceptionState(ExceptionState::GetterContext, "responseText", "XMLHttpRequest", info.Holder(), info.GetIsolate());
78 ScriptString text = xmlHttpRequest->responseText(exceptionState); 78 ScriptString text = xmlHttpRequest->responseText(exceptionState);
79 if (exceptionState.throwIfNeeded()) 79 if (exceptionState.throwIfNeeded())
80 return; 80 return;
81 if (text.isEmpty()) { 81 if (text.isEmpty()) {
82 v8SetReturnValueString(info, emptyString(), info.GetIsolate()); 82 v8SetReturnValueString(info, emptyString(), info.GetIsolate());
83 return; 83 return;
84 } 84 }
85 v8SetReturnValue(info, text.v8Value()); 85 v8SetReturnValue(info, text.v8Value());
86 } 86 }
87 87
88 void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI nfo<v8::Value>& info) 88 void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI nfo<v8::Value>& info)
89 { 89 {
90 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); 90 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
91 91
92 switch (xmlHttpRequest->responseTypeCode()) { 92 switch (xmlHttpRequest->responseTypeCode()) {
93 case XMLHttpRequest::ResponseTypeDefault: 93 case XMLHttpRequest::ResponseTypeDefault:
94 case XMLHttpRequest::ResponseTypeText: 94 case XMLHttpRequest::ResponseTypeText:
95 responseTextAttributeGetterCustom(info); 95 responseTextAttributeGetterCustom(info);
96 return; 96 return;
97 97
98 case XMLHttpRequest::ResponseTypeJSON: 98 case XMLHttpRequest::ResponseTypeJSON:
99 { 99 {
100 v8::Isolate* isolate = info.GetIsolate(); 100 v8::Isolate* isolate = info.GetIsolate();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // open(method, url, async, user, passwd) 167 // open(method, url, async, user, passwd)
168 168
169 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "XML HttpRequest", info.Holder(), info.GetIsolate()); 169 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "XML HttpRequest", info.Holder(), info.GetIsolate());
170 170
171 if (info.Length() < 2) { 171 if (info.Length() < 2) {
172 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 172 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
173 exceptionState.throwIfNeeded(); 173 exceptionState.throwIfNeeded();
174 return; 174 return;
175 } 175 }
176 176
177 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); 177 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
178 178
179 TOSTRING_VOID(V8StringResource<>, method, info[0]); 179 TOSTRING_VOID(V8StringResource<>, method, info[0]);
180 TOSTRING_VOID(V8StringResource<>, urlstring, info[1]); 180 TOSTRING_VOID(V8StringResource<>, urlstring, info[1]);
181 181
182 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); 182 ExecutionContext* context = currentExecutionContext(info.GetIsolate());
183 KURL url = context->completeURL(urlstring); 183 KURL url = context->completeURL(urlstring);
184 184
185 if (info.Length() >= 3) { 185 if (info.Length() >= 3) {
186 bool async = info[2]->BooleanValue(); 186 bool async = info[2]->BooleanValue();
187 187
(...skipping 17 matching lines...) Expand all
205 } 205 }
206 206
207 static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate) 207 static bool isDocumentType(v8::Handle<v8::Value> value, v8::Isolate* isolate)
208 { 208 {
209 // FIXME: add other document types. 209 // FIXME: add other document types.
210 return V8Document::hasInstance(value, isolate) || V8HTMLDocument::hasInstanc e(value, isolate); 210 return V8Document::hasInstance(value, isolate) || V8HTMLDocument::hasInstanc e(value, isolate);
211 } 211 }
212 212
213 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& info) 213 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value >& info)
214 { 214 {
215 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); 215 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toImpl(info.Holder());
216 216
217 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo ntext(), xmlHttpRequest->url()); 217 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo ntext(), xmlHttpRequest->url());
218 218
219 ExceptionState exceptionState(ExceptionState::ExecutionContext, "send", "XML HttpRequest", info.Holder(), info.GetIsolate()); 219 ExceptionState exceptionState(ExceptionState::ExecutionContext, "send", "XML HttpRequest", info.Holder(), info.GetIsolate());
220 if (info.Length() < 1) { 220 if (info.Length() < 1) {
221 xmlHttpRequest->send(exceptionState); 221 xmlHttpRequest->send(exceptionState);
222 } else { 222 } else {
223 v8::Handle<v8::Value> arg = info[0]; 223 v8::Handle<v8::Value> arg = info[0];
224 if (isUndefinedOrNull(arg)) { 224 if (isUndefinedOrNull(arg)) {
225 xmlHttpRequest->send(exceptionState); 225 xmlHttpRequest->send(exceptionState);
226 } else if (isDocumentType(arg, info.GetIsolate())) { 226 } else if (isDocumentType(arg, info.GetIsolate())) {
227 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 227 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
228 Document* document = V8Document::toNative(object); 228 Document* document = V8Document::toImpl(object);
229 ASSERT(document); 229 ASSERT(document);
230 xmlHttpRequest->send(document, exceptionState); 230 xmlHttpRequest->send(document, exceptionState);
231 } else if (V8Blob::hasInstance(arg, info.GetIsolate())) { 231 } else if (V8Blob::hasInstance(arg, info.GetIsolate())) {
232 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 232 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
233 Blob* blob = V8Blob::toNative(object); 233 Blob* blob = V8Blob::toImpl(object);
234 ASSERT(blob); 234 ASSERT(blob);
235 xmlHttpRequest->send(blob, exceptionState); 235 xmlHttpRequest->send(blob, exceptionState);
236 } else if (V8FormData::hasInstance(arg, info.GetIsolate())) { 236 } else if (V8FormData::hasInstance(arg, info.GetIsolate())) {
237 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 237 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
238 DOMFormData* domFormData = V8FormData::toNative(object); 238 DOMFormData* domFormData = V8FormData::toImpl(object);
239 ASSERT(domFormData); 239 ASSERT(domFormData);
240 xmlHttpRequest->send(domFormData, exceptionState); 240 xmlHttpRequest->send(domFormData, exceptionState);
241 } else if (V8ArrayBuffer::hasInstance(arg, info.GetIsolate())) { 241 } else if (V8ArrayBuffer::hasInstance(arg, info.GetIsolate())) {
242 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 242 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
243 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object); 243 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(object);
244 ASSERT(arrayBuffer); 244 ASSERT(arrayBuffer);
245 xmlHttpRequest->send(arrayBuffer, exceptionState); 245 xmlHttpRequest->send(arrayBuffer, exceptionState);
246 } else if (V8ArrayBufferView::hasInstance(arg, info.GetIsolate())) { 246 } else if (V8ArrayBufferView::hasInstance(arg, info.GetIsolate())) {
247 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); 247 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
248 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(objec t); 248 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object) ;
249 ASSERT(arrayBufferView); 249 ASSERT(arrayBufferView);
250 xmlHttpRequest->send(arrayBufferView, exceptionState); 250 xmlHttpRequest->send(arrayBufferView, exceptionState);
251 } else { 251 } else {
252 TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, argString, ar g); 252 TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, argString, ar g);
253 xmlHttpRequest->send(argString, exceptionState); 253 xmlHttpRequest->send(argString, exceptionState);
254 } 254 }
255 } 255 }
256 256
257 exceptionState.throwIfNeeded(); 257 exceptionState.throwIfNeeded();
258 } 258 }
259 259
260 } // namespace blink 260 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8WorkerGlobalScopeCustom.cpp ('k') | Source/bindings/core/v8/custom/V8XSLTProcessorCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698