| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 #include "bin/eventhandler.h" | 6 #include "bin/eventhandler.h" |
| 7 #include "bin/socket.h" | 7 #include "bin/socket.h" |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 void EventHandler::Stop() { | 70 void EventHandler::Stop() { |
| 71 if (event_handler == NULL) return; | 71 if (event_handler == NULL) return; |
| 72 event_handler->delegate_.Shutdown(); | 72 event_handler->delegate_.Shutdown(); |
| 73 event_handler = NULL; | 73 event_handler = NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 EventHandlerImplementation* EventHandler::delegate() { |
| 78 if (event_handler == NULL) return NULL; |
| 79 return &event_handler->delegate_; |
| 80 } |
| 81 |
| 82 |
| 77 /* | 83 /* |
| 78 * Send data to the EventHandler thread to register for a given instance | 84 * Send data to the EventHandler thread to register for a given instance |
| 79 * args[0] a ReceivePort args[1] with a notification event args[2]. | 85 * args[0] a ReceivePort args[1] with a notification event args[2]. |
| 80 */ | 86 */ |
| 81 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) { | 87 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) { |
| 82 Dart_Handle sender = Dart_GetNativeArgument(args, 0); | 88 Dart_Handle sender = Dart_GetNativeArgument(args, 0); |
| 83 intptr_t id = kInvalidId; | 89 intptr_t id = kInvalidId; |
| 84 if (Dart_IsNull(sender)) { | 90 if (Dart_IsNull(sender)) { |
| 85 id = kTimerId; | 91 id = kTimerId; |
| 86 } else { | 92 } else { |
| 87 Socket::GetSocketIdNativeField(sender, &id); | 93 Socket::GetSocketIdNativeField(sender, &id); |
| 88 } | 94 } |
| 89 Dart_Handle handle = Dart_GetNativeArgument(args, 1); | 95 Dart_Handle handle = Dart_GetNativeArgument(args, 1); |
| 90 Dart_Port dart_port = | 96 Dart_Port dart_port = |
| 91 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName); | 97 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName); |
| 92 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); | 98 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); |
| 93 event_handler->SendData(id, dart_port, data); | 99 event_handler->SendData(id, dart_port, data); |
| 94 } | 100 } |
| 95 | 101 |
| 96 } // namespace bin | 102 } // namespace bin |
| 97 } // namespace dart | 103 } // namespace dart |
| OLD | NEW |