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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 namespace DartWebSocketInternal { | 40 namespace DartWebSocketInternal { |
41 | 41 |
42 void sendCallback(Dart_NativeArguments args) | 42 void sendCallback(Dart_NativeArguments args) |
43 { | 43 { |
44 Dart_Handle exception = 0; | 44 Dart_Handle exception = 0; |
45 { | 45 { |
46 WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); | 46 WebSocket* receiver = DartDOMWrapper::receiver<WebSocket>(args); |
47 | |
48 DartDOMData* domData = static_cast<DartDOMData*>(Dart_GetNativeIsolateDa
ta(args)); | |
49 Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); | 47 Dart_Handle dataHandle = Dart_GetNativeArgument(args, 1); |
50 | 48 |
51 DartExceptionState es; | 49 DartExceptionState es; |
52 if (DartUtilities::isTypedData(dataHandle)) { | 50 if (DartUtilities::isTypedData(dataHandle)) { |
53 RefPtr<ArrayBuffer> data = DartUtilities::dartToArrayBuffer(dataHand
le, exception); | 51 RefPtr<ArrayBuffer> data = DartUtilities::dartToArrayBuffer(dataHand
le, exception); |
54 if (exception) | 52 if (exception) |
55 goto fail; | 53 goto fail; |
56 receiver->send(data.get(), es); | 54 receiver->send(data.get(), es); |
57 } else if (DartDOMWrapper::instanceOf<DartBlob>(domData, dataHandle)) { | 55 } else if (DartDOMWrapper::subtypeOf(dataHandle, DartBlob::dartClassId))
{ |
58 Blob* data = DartBlob::toNative(dataHandle, exception); | 56 Blob* data = DartBlob::toNative(dataHandle, exception); |
59 if (exception) | 57 if (exception) |
60 goto fail; | 58 goto fail; |
61 receiver->send(data, es); | 59 receiver->send(data, es); |
62 } else if (Dart_IsString(dataHandle)) { | 60 } else if (Dart_IsString(dataHandle)) { |
63 DartStringAdapter data = DartUtilities::dartToString(dataHandle, exc
eption); | 61 DartStringAdapter data = DartUtilities::dartToString(dataHandle, exc
eption); |
64 if (exception) | 62 if (exception) |
65 goto fail; | 63 goto fail; |
66 receiver->send(data, es); | 64 receiver->send(data, es); |
67 } else { | 65 } else { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 179 } |
182 | 180 |
183 fail: | 181 fail: |
184 Dart_ThrowException(exception); | 182 Dart_ThrowException(exception); |
185 ASSERT_NOT_REACHED(); | 183 ASSERT_NOT_REACHED(); |
186 } | 184 } |
187 | 185 |
188 } | 186 } |
189 | 187 |
190 } | 188 } |
OLD | NEW |