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 #ifndef BIN_EVENTHANDLER_H_ | 5 #ifndef BIN_EVENTHANDLER_H_ |
6 #define BIN_EVENTHANDLER_H_ | 6 #define BIN_EVENTHANDLER_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/isolate_data.h" |
9 | 10 |
10 // Flags used to provide information and actions to the eventhandler | 11 // Flags used to provide information and actions to the eventhandler |
11 // when sending a message about a file descriptor. These flags should | 12 // when sending a message about a file descriptor. These flags should |
12 // be kept in sync with the constants in socket_impl.dart. For more | 13 // be kept in sync with the constants in socket_impl.dart. For more |
13 // information see the comments in socket_impl.dart | 14 // information see the comments in socket_impl.dart |
14 enum MessageFlags { | 15 enum MessageFlags { |
15 kInEvent = 0, | 16 kInEvent = 0, |
16 kOutEvent = 1, | 17 kOutEvent = 1, |
17 kErrorEvent = 2, | 18 kErrorEvent = 2, |
18 kCloseEvent = 3, | 19 kCloseEvent = 3, |
(...skipping 15 matching lines...) Expand all Loading... |
34 #else | 35 #else |
35 #error Unknown target os. | 36 #error Unknown target os. |
36 #endif | 37 #endif |
37 | 38 |
38 class EventHandler { | 39 class EventHandler { |
39 public: | 40 public: |
40 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { | 41 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { |
41 delegate_.SendData(id, dart_port, data); | 42 delegate_.SendData(id, dart_port, data); |
42 } | 43 } |
43 | 44 |
44 static EventHandler* StartEventHandler() { | 45 void Shutdown() { |
| 46 delegate_.Shutdown(); |
| 47 } |
| 48 |
| 49 static EventHandler* Start() { |
45 EventHandler* handler = new EventHandler(); | 50 EventHandler* handler = new EventHandler(); |
46 handler->delegate_.StartEventHandler(); | 51 handler->delegate_.Start(); |
| 52 IsolateData* isolate_data = |
| 53 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); |
| 54 isolate_data->event_handler = handler; |
47 return handler; | 55 return handler; |
48 } | 56 } |
49 | 57 |
50 private: | 58 private: |
51 EventHandlerImplementation delegate_; | 59 EventHandlerImplementation delegate_; |
52 }; | 60 }; |
53 | 61 |
54 | 62 |
55 #endif // BIN_EVENTHANDLER_H_ | 63 #endif // BIN_EVENTHANDLER_H_ |
OLD | NEW |