Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_LINUX_H_ | 5 #ifndef BIN_EVENTHANDLER_LINUX_H_ |
| 6 #define BIN_EVENTHANDLER_LINUX_H_ | 6 #define BIN_EVENTHANDLER_LINUX_H_ |
| 7 | 7 |
| 8 | 8 |
| 9 typedef struct { | 9 class InterruptMessage { |
| 10 public: | |
| 10 intptr_t id; | 11 intptr_t id; |
| 11 Dart_Port dart_port; | 12 Dart_Port dart_port; |
| 12 int64_t data; | 13 int64_t data; |
| 13 } InterruptMessage; | 14 }; |
| 14 | 15 |
| 15 | 16 |
| 16 typedef struct { | 17 class SocketData { |
| 17 Dart_Port dart_port; | 18 public: |
| 18 intptr_t mask; | 19 void FillPollEvents(struct pollfd* pollfds); |
| 19 } PortData; | 20 bool IsListeningSocket() { return (_mask & (1 << kListeningSocket)) != 0; } |
| 21 | |
| 22 Dart_Port port() { return _port; } | |
| 23 void set_port(Dart_Port port) { _port = port; } | |
| 24 intptr_t mask() { return _mask; } | |
| 25 void set_mask(intptr_t mask) { _mask = mask; } | |
| 26 | |
|
Mads Ager (google)
2011/11/01 09:10:23
Remove one newline?
Søren Gjesse
2011/11/01 11:34:21
Done.
| |
| 27 | |
| 28 private: | |
| 29 Dart_Port _port; | |
| 30 intptr_t _mask; | |
| 31 }; | |
| 20 | 32 |
| 21 | 33 |
| 22 class EventHandlerImplementation { | 34 class EventHandlerImplementation { |
| 23 public: | 35 public: |
| 24 EventHandlerImplementation(); | 36 EventHandlerImplementation(); |
| 25 ~EventHandlerImplementation(); | 37 ~EventHandlerImplementation(); |
| 26 | 38 |
| 39 SocketData* GetSocketData(intptr_t fd); | |
| 27 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); | 40 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); |
| 28 void StartEventHandler(); | 41 void StartEventHandler(); |
| 29 | 42 |
| 30 private: | 43 private: |
| 31 intptr_t GetTimeout(); | 44 intptr_t GetTimeout(); |
| 32 bool GetInterruptMessage(InterruptMessage* msg); | 45 bool GetInterruptMessage(InterruptMessage* msg); |
| 33 struct pollfd* GetPollFds(intptr_t* size); | 46 struct pollfd* GetPollFds(intptr_t* size); |
| 34 void RegisterFdWakeup(intptr_t id, Dart_Port dart_port, intptr_t data); | 47 void RegisterFdWakeup(intptr_t id, Dart_Port dart_port, intptr_t data); |
| 35 void UnregisterFdWakeup(intptr_t id); | 48 void UnregisterFdWakeup(intptr_t id); |
| 36 void CloseFd(intptr_t id); | 49 void CloseFd(intptr_t id); |
| 37 void UnregisterFd(intptr_t id); | 50 void UnregisterFd(intptr_t id); |
| 38 void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size); | 51 void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size); |
| 39 void HandleTimeout(); | 52 void HandleTimeout(); |
| 40 static void* Poll(void* args); | 53 static void* Poll(void* args); |
| 41 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data); | 54 void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data); |
| 42 void HandleInterruptFd(); | 55 void HandleInterruptFd(); |
| 43 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); | 56 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); |
| 44 Dart_Port PortFor(intptr_t fd); | |
| 45 bool IsListeningSocket(intptr_t fd); | |
| 46 intptr_t GetPollEvents(struct pollfd* pollfd); | 57 intptr_t GetPollEvents(struct pollfd* pollfd); |
| 47 void SetPollEvents(struct pollfd* pollfds, intptr_t mask); | |
| 48 | 58 |
| 49 PortData* port_map_; | 59 SocketData* port_map_; |
|
Mads Ager (google)
2011/11/01 09:10:23
Should this be socket_map_ instead of port_map_?
Søren Gjesse
2011/11/01 11:34:21
Done.
| |
| 50 intptr_t port_map_entries_; | 60 intptr_t port_map_entries_; |
| 51 intptr_t port_map_size_; | 61 intptr_t port_map_size_; |
| 52 int64_t timeout_; // Time for next timeout. | 62 int64_t timeout_; // Time for next timeout. |
| 53 Dart_Port timeout_port_; | 63 Dart_Port timeout_port_; |
| 54 int interrupt_fds_[2]; | 64 int interrupt_fds_[2]; |
| 55 }; | 65 }; |
| 56 | 66 |
| 57 | 67 |
| 58 #endif // BIN_EVENTHANDLER_LINUX_H_ | 68 #endif // BIN_EVENTHANDLER_LINUX_H_ |
| OLD | NEW |