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_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 | 9 |
| 10 // The event handler delegation class is OS specific. | 10 // The event handler delegation class is OS specific. |
| 11 #if defined(TARGET_OS_LINUX) | 11 #if defined(TARGET_OS_LINUX) |
| 12 #include "bin/eventhandler_linux.h" | 12 #include "bin/eventhandler_linux.h" |
| 13 #elif defined(TARGET_OS_MACOS) | 13 #elif defined(TARGET_OS_MACOS) |
| 14 #include "bin/eventhandler_macos.h" | 14 #include "bin/eventhandler_macos.h" |
| 15 #elif defined(TARGET_OS_WINDOWS) | 15 #elif defined(TARGET_OS_WINDOWS) |
| 16 #include "bin/eventhandler_win.h" | 16 #include "bin/eventhandler_win.h" |
| 17 #else | 17 #else |
| 18 #error Unknown target os. | 18 #error Unknown target os. |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 /* | 21 /* |
| 22 * Keep these constant in sync with the dart poll event identifiers. | 22 * Keep these constant in sync with the dart poll event identifiers. |
| 23 */ | 23 */ |
| 24 enum Message { | 24 enum Message { |
| 25 kInEvent = 0, | 25 kInEvent = 0, |
| 26 kOutEvent, | 26 kOutEvent = 1, |
| 27 kErrorEvent, | 27 kErrorEvent = 2, |
| 28 kCloseEvent, | 28 kCloseEvent = 3, |
| 29 kCloseCommand, | 29 kCloseCommand = 8, |
| 30 kListenSocket = 16, | |
|
Mads Ager (google)
2011/10/28 08:33:23
The naming here confuses me. 4 Events, 1 Command a
Søren Gjesse
2011/10/28 09:24:19
So this is the bits that we send to the event loop
| |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 | 33 |
| 33 class EventHandler { | 34 class EventHandler { |
| 34 public: | 35 public: |
| 35 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { | 36 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { |
| 36 delegate_.SendData(id, dart_port, data); | 37 delegate_.SendData(id, dart_port, data); |
| 37 } | 38 } |
| 38 | 39 |
| 39 static EventHandler* StartEventHandler() { | 40 static EventHandler* StartEventHandler() { |
| 40 EventHandler* handler = new EventHandler(); | 41 EventHandler* handler = new EventHandler(); |
| 41 handler->delegate_.StartEventHandler(); | 42 handler->delegate_.StartEventHandler(); |
| 42 return handler; | 43 return handler; |
| 43 } | 44 } |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 EventHandlerImplementation delegate_; | 47 EventHandlerImplementation delegate_; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 | 50 |
| 50 #endif // BIN_EVENTHANDLER_H_ | 51 #endif // BIN_EVENTHANDLER_H_ |
| OLD | NEW |