OLD | NEW |
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return; | 212 return; |
213 } | 213 } |
214 | 214 |
215 fail: | 215 fail: |
216 Dart_ThrowException(exception); | 216 Dart_ThrowException(exception); |
217 ASSERT_NOT_REACHED(); | 217 ASSERT_NOT_REACHED(); |
218 } | 218 } |
219 | 219 |
220 void responseGetter(Dart_NativeArguments args) | 220 void responseGetter(Dart_NativeArguments args) |
221 { | 221 { |
222 // FIXME: implement. | 222 DartApiScope dartApiScope; |
223 DART_UNIMPLEMENTED(); | 223 Dart_Handle exception; |
| 224 { |
| 225 XMLHttpRequest* receiver = DartDOMWrapper::receiver<XMLHttpRequest>(args
); |
| 226 |
| 227 switch (receiver->responseTypeCode()) { |
| 228 case XMLHttpRequest::ResponseTypeDefault: |
| 229 case XMLHttpRequest::ResponseTypeText: |
| 230 { |
| 231 ExceptionCode ec = 0; |
| 232 String result = receiver->responseText(ec); |
| 233 if (UNLIKELY(ec)) { |
| 234 exception = DartDOMWrapper::exceptionCodeToDartException(ec)
; |
| 235 goto fail; |
| 236 } |
| 237 Dart_SetReturnValue(args, DartUtilities::stringToDart(result)); |
| 238 return; |
| 239 } |
| 240 |
| 241 case XMLHttpRequest::ResponseTypeDocument: |
| 242 { |
| 243 ExceptionCode ec = 0; |
| 244 Document* document = receiver->responseXML(ec); |
| 245 if (UNLIKELY(ec)) { |
| 246 exception = DartDOMWrapper::exceptionCodeToDartException(ec)
; |
| 247 goto fail; |
| 248 } |
| 249 DartDOMWrapper::returnValue<DartDocument>(args, document); |
| 250 return; |
| 251 } |
| 252 |
| 253 case XMLHttpRequest::ResponseTypeBlob: |
| 254 #if ENABLE(XHR_RESPONSE_BLOB) |
| 255 { |
| 256 ExceptionCode ec = 0; |
| 257 Blob* blob = receiver->responseBlob(ec); |
| 258 if (UNLIKELY(ec)) { |
| 259 exception = DartDOMWrapper::exceptionCodeToDartException(ec)
; |
| 260 goto fail; |
| 261 } |
| 262 DartDOMWrapper::returnValue<DartBlob>(args, blob); |
| 263 } |
| 264 #endif |
| 265 return; |
| 266 |
| 267 case XMLHttpRequest::ResponseTypeArrayBuffer: |
| 268 { |
| 269 ExceptionCode ec = 0; |
| 270 ArrayBuffer* arrayBuffer = receiver->responseArrayBuffer(ec); |
| 271 if (UNLIKELY(ec)) { |
| 272 exception = DartDOMWrapper::exceptionCodeToDartException(ec)
; |
| 273 goto fail; |
| 274 } |
| 275 DartDOMWrapper::returnValue<DartArrayBuffer>(args, arrayBuffer); |
| 276 return; |
| 277 } |
| 278 } |
| 279 |
| 280 return; |
| 281 } |
| 282 |
| 283 fail: |
| 284 Dart_ThrowException(exception); |
| 285 ASSERT_NOT_REACHED(); |
224 } | 286 } |
225 | 287 |
226 } // DartXMLHttpRequestInternal | 288 } // DartXMLHttpRequestInternal |
227 | 289 |
228 } // WebCore | 290 } // WebCore |
OLD | NEW |