| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED) | 5 #if !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED) |
| 6 | 6 |
| 7 #include "bin/io_service_no_ssl.h" | 7 #include "bin/io_service_no_ssl.h" |
| 8 | 8 |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/directory.h" | 10 #include "bin/directory.h" |
| 11 #include "bin/file.h" | 11 #include "bin/file.h" |
| 12 #include "bin/io_buffer.h" | 12 #include "bin/io_buffer.h" |
| 13 #include "bin/socket.h" | 13 #include "bin/socket.h" |
| 14 #include "bin/utils.h" | 14 #include "bin/utils.h" |
| 15 | 15 |
| 16 #include "include/dart_api.h" | 16 #include "include/dart_api.h" |
| 17 | 17 |
| 18 #include "platform/globals.h" | 18 #include "platform/globals.h" |
| 19 #include "platform/utils.h" | 19 #include "platform/utils.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 namespace bin { | 22 namespace bin { |
| 23 | 23 |
| 24 #define CASE_REQUEST(type, method, id) \ | 24 #define CASE_REQUEST(type, method, id) \ |
| 25 case IOService::k##type##method##Request: \ | 25 case IOService::k##type##method##Request: \ |
| 26 response = type::method##Request(data); \ | 26 response = type::method##Request(data); \ |
| 27 break; | 27 break; |
| 28 | 28 |
| 29 void IOServiceCallback(Dart_Port dest_port_id, | 29 void IOServiceCallback(Dart_Port dest_port_id, Dart_CObject* message) { |
| 30 Dart_CObject* message) { | |
| 31 Dart_Port reply_port_id = ILLEGAL_PORT; | 30 Dart_Port reply_port_id = ILLEGAL_PORT; |
| 32 CObject* response = CObject::IllegalArgumentError(); | 31 CObject* response = CObject::IllegalArgumentError(); |
| 33 CObjectArray request(message); | 32 CObjectArray request(message); |
| 34 if ((message->type == Dart_CObject_kArray) && | 33 if ((message->type == Dart_CObject_kArray) && (request.Length() == 4) && |
| 35 (request.Length() == 4) && | 34 request[0]->IsInt32() && request[1]->IsSendPort() && |
| 36 request[0]->IsInt32() && | 35 request[2]->IsInt32() && request[3]->IsArray()) { |
| 37 request[1]->IsSendPort() && | |
| 38 request[2]->IsInt32() && | |
| 39 request[3]->IsArray()) { | |
| 40 CObjectInt32 message_id(request[0]); | 36 CObjectInt32 message_id(request[0]); |
| 41 CObjectSendPort reply_port(request[1]); | 37 CObjectSendPort reply_port(request[1]); |
| 42 CObjectInt32 request_id(request[2]); | 38 CObjectInt32 request_id(request[2]); |
| 43 CObjectArray data(request[3]); | 39 CObjectArray data(request[3]); |
| 44 reply_port_id = reply_port.Value(); | 40 reply_port_id = reply_port.Value(); |
| 45 switch (request_id.Value()) { | 41 switch (request_id.Value()) { |
| 46 IO_SERVICE_REQUEST_LIST(CASE_REQUEST); | 42 IO_SERVICE_REQUEST_LIST(CASE_REQUEST); |
| 47 default: | 43 default: |
| 48 UNREACHABLE(); | 44 UNREACHABLE(); |
| 49 } | 45 } |
| 50 } | 46 } |
| 51 | 47 |
| 52 CObjectArray result(CObject::NewArray(2)); | 48 CObjectArray result(CObject::NewArray(2)); |
| 53 result.SetAt(0, request[0]); | 49 result.SetAt(0, request[0]); |
| 54 result.SetAt(1, response); | 50 result.SetAt(1, response); |
| 55 ASSERT(reply_port_id != ILLEGAL_PORT); | 51 ASSERT(reply_port_id != ILLEGAL_PORT); |
| 56 Dart_PostCObject(reply_port_id, result.AsApiCObject()); | 52 Dart_PostCObject(reply_port_id, result.AsApiCObject()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 // Return a send port for the service port. | 65 // Return a send port for the service port. |
| 70 Dart_Handle send_port = Dart_NewSendPort(service_port); | 66 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 71 Dart_SetReturnValue(args, send_port); | 67 Dart_SetReturnValue(args, send_port); |
| 72 } | 68 } |
| 73 } | 69 } |
| 74 | 70 |
| 75 } // namespace bin | 71 } // namespace bin |
| 76 } // namespace dart | 72 } // namespace dart |
| 77 | 73 |
| 78 #endif // !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED) | 74 #endif // !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED) |
| OLD | NEW |