| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 Dart_ThrowException(exception); | 65 Dart_ThrowException(exception); |
| 66 ASSERT_NOT_REACHED(); | 66 ASSERT_NOT_REACHED(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void openCallback(Dart_NativeArguments args) | 69 void openCallback(Dart_NativeArguments args) |
| 70 { | 70 { |
| 71 DartApiScope dartApiScope; | 71 DartApiScope dartApiScope; |
| 72 Dart_Handle exception = 0; | 72 Dart_Handle exception = 0; |
| 73 { | 73 { |
| 74 XMLHttpRequest* receiver = DartDOMWrapper::receiver<XMLHttpRequest>(args
); | 74 XMLHttpRequest* receiver = DartDOMWrapper::receiver<XMLHttpRequest>(args
); |
| 75 const ParameterAdapter<String> method(Dart_GetNativeArgument(args, 1)); | 75 DartStringAdapter method = DartUtilities::dartToString(Dart_GetNativeArg
ument(args, 1), exception); |
| 76 if (!method.conversionSuccessful()) { | 76 if (exception) |
| 77 exception = method.exception(); | |
| 78 goto fail; | 77 goto fail; |
| 79 } | 78 DartStringAdapter url = DartUtilities::dartToString(Dart_GetNativeArgume
nt(args, 2), exception); |
| 80 const ParameterAdapter<String> url(Dart_GetNativeArgument(args, 2)); | 79 if (exception) |
| 81 if (!url.conversionSuccessful()) { | |
| 82 exception = url.exception(); | |
| 83 goto fail; | 80 goto fail; |
| 84 } | |
| 85 | 81 |
| 86 ScriptExecutionContext* context = DartUtilities::scriptExecutionContext(
); | 82 ScriptExecutionContext* context = DartUtilities::scriptExecutionContext(
); |
| 87 if (!context) | 83 if (!context) |
| 88 return; | 84 return; |
| 89 KURL fullURL = context->completeURL(url); | 85 KURL fullURL = context->completeURL(url); |
| 90 | 86 |
| 91 ExceptionCode ec = 0; | 87 ExceptionCode ec = 0; |
| 92 Dart_Handle arg3 = Dart_GetNativeArgument(args, 3); | 88 Dart_Handle arg3 = Dart_GetNativeArgument(args, 3); |
| 93 if (!Dart_IsNull(arg3)) { | 89 if (!Dart_IsNull(arg3)) { |
| 94 bool async = DartUtilities::dartToBool(arg3, exception); | 90 bool async = DartUtilities::dartToBool(arg3, exception); |
| 95 if (exception) | 91 if (exception) |
| 96 goto fail; | 92 goto fail; |
| 97 | 93 |
| 98 Dart_Handle arg4 = Dart_GetNativeArgument(args, 4); | 94 Dart_Handle arg4 = Dart_GetNativeArgument(args, 4); |
| 99 if (!Dart_IsNull(arg4)) { | 95 if (!Dart_IsNull(arg4)) { |
| 100 const ParameterAdapter<String> user(arg4); | 96 DartStringAdapter user = DartUtilities::dartToString(arg4, excep
tion); |
| 101 if (!user.conversionSuccessful()) { | 97 if (exception) |
| 102 exception = user.exception(); | |
| 103 goto fail; | 98 goto fail; |
| 104 } | |
| 105 | 99 |
| 106 Dart_Handle arg5 = Dart_GetNativeArgument(args, 5); | 100 Dart_Handle arg5 = Dart_GetNativeArgument(args, 5); |
| 107 if (!Dart_IsNull(arg5)) { | 101 if (!Dart_IsNull(arg5)) { |
| 108 const ParameterAdapter<String> passwd(arg5); | 102 DartStringAdapter passwd = DartUtilities::dartToString(arg5,
exception); |
| 109 if (!passwd.conversionSuccessful()) { | 103 if (exception) |
| 110 exception = passwd.exception(); | |
| 111 goto fail; | 104 goto fail; |
| 112 } | |
| 113 | 105 |
| 114 receiver->open(method, fullURL, async, user, passwd, ec); | 106 receiver->open(method, fullURL, async, user, passwd, ec); |
| 115 } else | 107 } else |
| 116 receiver->open(method, fullURL, async, user, ec); | 108 receiver->open(method, fullURL, async, user, ec); |
| 117 } else | 109 } else |
| 118 receiver->open(method, fullURL, async, ec); | 110 receiver->open(method, fullURL, async, ec); |
| 119 } else | 111 } else |
| 120 receiver->open(method, fullURL, ec); | 112 receiver->open(method, fullURL, ec); |
| 121 | 113 |
| 122 if (UNLIKELY(ec)) { | 114 if (UNLIKELY(ec)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 goto fail; | 150 goto fail; |
| 159 receiver->send(asDOMFormData, ec); | 151 receiver->send(asDOMFormData, ec); |
| 160 #if ENABLE(WEBGL) || ENABLE(BLOB) | 152 #if ENABLE(WEBGL) || ENABLE(BLOB) |
| 161 } else if (DartDOMWrapper::instanceOf<DartArrayBuffer>(arg1)) { | 153 } else if (DartDOMWrapper::instanceOf<DartArrayBuffer>(arg1)) { |
| 162 ArrayBuffer* asArrayBuffer = DartArrayBuffer::toNative(arg1, excepti
on); | 154 ArrayBuffer* asArrayBuffer = DartArrayBuffer::toNative(arg1, excepti
on); |
| 163 if (exception) | 155 if (exception) |
| 164 goto fail; | 156 goto fail; |
| 165 receiver->send(asArrayBuffer, ec); | 157 receiver->send(asArrayBuffer, ec); |
| 166 #endif | 158 #endif |
| 167 } else { | 159 } else { |
| 168 const ParameterAdapter<String> asString(arg1); | 160 DartStringAdapter asString = DartUtilities::dartToString(arg1, excep
tion); |
| 169 if (!asString.conversionSuccessful()) { | 161 if (exception) |
| 170 exception = asString.exception(); | |
| 171 goto fail; | 162 goto fail; |
| 172 } | |
| 173 receiver->send(asString, ec); | 163 receiver->send(asString, ec); |
| 174 } | 164 } |
| 175 | 165 |
| 176 if (UNLIKELY(ec)) { | 166 if (UNLIKELY(ec)) { |
| 177 exception = DartDOMWrapper::exceptionCodeToDartException(ec); | 167 exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| 178 goto fail; | 168 goto fail; |
| 179 } | 169 } |
| 180 return; | 170 return; |
| 181 } | 171 } |
| 182 | 172 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 261 } |
| 272 | 262 |
| 273 fail: | 263 fail: |
| 274 Dart_ThrowException(exception); | 264 Dart_ThrowException(exception); |
| 275 ASSERT_NOT_REACHED(); | 265 ASSERT_NOT_REACHED(); |
| 276 } | 266 } |
| 277 | 267 |
| 278 } // DartXMLHttpRequestInternal | 268 } // DartXMLHttpRequestInternal |
| 279 | 269 |
| 280 } // WebCore | 270 } // WebCore |
| OLD | NEW |