Chromium Code Reviews| Index: Source/bindings/dart/custom/DartWebSocketCustom.cpp |
| diff --git a/Source/bindings/dart/custom/DartWebSocketCustom.cpp b/Source/bindings/dart/custom/DartWebSocketCustom.cpp |
| index 53ace5fd353ad4540267886761be226f71d54bd8..7921369bd015ba0fbf3563f4dec698f4a4912f1e 100644 |
| --- a/Source/bindings/dart/custom/DartWebSocketCustom.cpp |
| +++ b/Source/bindings/dart/custom/DartWebSocketCustom.cpp |
| @@ -81,6 +81,114 @@ fail: |
| ASSERT_NOT_REACHED(); |
| } |
| +void sendByteBufferCallback(Dart_NativeArguments args) |
| +{ |
| + DartApiScope dartApiScope; |
| + Dart_Handle exception = 0; |
| + { |
| + WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); |
| + Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); |
| + |
| + RefPtr<ArrayBufferView> data = DartUtilities::dartToArrayBufferView(dataHandle, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + ExceptionCode ec = 0; |
| + receiver->send(data.get(), ec); |
| + |
| + if (UNLIKELY(ec)) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| +} |
| + |
| +void sendTypeDataCallback(Dart_NativeArguments args) |
|
Anton Muhin
2013/07/09 10:00:09
TypeData or Type[d]Data?
and again, looks pretty
Emily Fortuna
2013/07/09 17:14:01
oops, yes I fixed this locally on my computer but
|
| +{ |
| + DartApiScope dartApiScope; |
| + Dart_Handle exception = 0; |
| + { |
| + WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); |
| + Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); |
| + |
| + RefPtr<ArrayBuffer> data = DartUtilities::dartToArrayBuffer(dataHandle, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + ExceptionCode ec = 0; |
| + receiver->send(data.get(), ec); |
| + |
| + if (UNLIKELY(ec)) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| +} |
| + |
| +void sendBlobCallback(Dart_NativeArguments args) |
| +{ |
| + DartApiScope dartApiScope; |
| + Dart_Handle exception = 0; |
| + { |
| + WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); |
| + Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); |
| + |
| + Blob* data = DartBlob::toNative(dataHandle, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + ExceptionCode ec = 0; |
| + receiver->send(data, ec); |
| + |
| + if (UNLIKELY(ec)) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| +} |
| + |
| +void sendStringCallback(Dart_NativeArguments args) |
| +{ |
| + DartApiScope dartApiScope; |
| + Dart_Handle exception = 0; |
| + { |
| + WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); |
| + Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); |
| + |
| + DartStringAdapter data = DartUtilities::dartToString(dataHandle, exception); |
| + if (exception) |
| + goto fail; |
| + |
| + ExceptionCode ec = 0; |
| + receiver->send(data, ec); |
| + |
| + if (UNLIKELY(ec)) { |
| + exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| + goto fail; |
| + } |
| + return; |
| + } |
| + |
| +fail: |
| + Dart_ThrowException(exception); |
| + ASSERT_NOT_REACHED(); |
| +} |
| + |
| } |
| } |