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_WIN_H_ | 5 #ifndef BIN_EVENTHANDLER_WIN_H_ |
6 #define BIN_EVENTHANDLER_WIN_H_ | 6 #define BIN_EVENTHANDLER_WIN_H_ |
7 | 7 |
8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(BIN_EVENTHANDLER_H_) |
9 #error Do not include eventhandler_win.h directly; use eventhandler.h instead. | 9 #error Do not include eventhandler_win.h directly; use eventhandler.h instead. |
10 #endif | 10 #endif |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // object as the object is allocated larger than it's definition | 123 // object as the object is allocated larger than it's definition |
124 // indicate to extend this array. | 124 // indicate to extend this array. |
125 uint8_t buffer_data_[1]; | 125 uint8_t buffer_data_[1]; |
126 }; | 126 }; |
127 | 127 |
128 | 128 |
129 // Abstract super class for holding information on listen and connected | 129 // Abstract super class for holding information on listen and connected |
130 // sockets. | 130 // sockets. |
131 class Handle { | 131 class Handle { |
132 public: | 132 public: |
133 enum Type { kFile, kClientSocket, kListenSocket }; | 133 enum Type { |
| 134 kFile, |
| 135 kDirectoryWatch, |
| 136 kClientSocket, |
| 137 kListenSocket |
| 138 }; |
134 | 139 |
135 class ScopedLock { | 140 class ScopedLock { |
136 public: | 141 public: |
137 explicit ScopedLock(Handle* handle) | 142 explicit ScopedLock(Handle* handle) |
138 : handle_(handle) { | 143 : handle_(handle) { |
139 handle_->Lock(); | 144 handle_->Lock(); |
140 } | 145 } |
141 ~ScopedLock() { | 146 ~ScopedLock() { |
142 handle_->Unlock(); | 147 handle_->Unlock(); |
143 } | 148 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 244 |
240 private: | 245 private: |
241 int flags_; | 246 int flags_; |
242 CRITICAL_SECTION cs_; // Critical section protecting this object. | 247 CRITICAL_SECTION cs_; // Critical section protecting this object. |
243 }; | 248 }; |
244 | 249 |
245 | 250 |
246 class FileHandle : public Handle { | 251 class FileHandle : public Handle { |
247 public: | 252 public: |
248 explicit FileHandle(HANDLE handle) | 253 explicit FileHandle(HANDLE handle) |
249 : Handle(reinterpret_cast<HANDLE>(handle)) { type_ = kFile; } | 254 : Handle(handle) { type_ = kFile; } |
250 FileHandle(HANDLE handle, Dart_Port port) | 255 FileHandle(HANDLE handle, Dart_Port port) |
251 : Handle(reinterpret_cast<HANDLE>(handle), port) { type_ = kFile; } | 256 : Handle(handle, port) { type_ = kFile; } |
252 | 257 |
253 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); | 258 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); |
254 virtual bool IsClosed(); | 259 virtual bool IsClosed(); |
255 virtual void DoClose(); | 260 virtual void DoClose(); |
256 }; | 261 }; |
257 | 262 |
258 | 263 |
| 264 class DirectoryWatchHandle : public Handle { |
| 265 public: |
| 266 DirectoryWatchHandle(HANDLE handle, int events, bool recursive) |
| 267 : Handle(handle), |
| 268 events_(events), |
| 269 recursive_(recursive) { |
| 270 type_ = kDirectoryWatch; |
| 271 } |
| 272 |
| 273 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); |
| 274 virtual bool IsClosed(); |
| 275 virtual void DoClose(); |
| 276 |
| 277 virtual bool IssueRead(); |
| 278 |
| 279 private: |
| 280 int events_; |
| 281 bool recursive_; |
| 282 }; |
| 283 |
| 284 |
259 class SocketHandle : public Handle { | 285 class SocketHandle : public Handle { |
260 public: | 286 public: |
261 SOCKET socket() { return reinterpret_cast<SOCKET>(handle_); } | 287 SOCKET socket() { return reinterpret_cast<SOCKET>(handle_); } |
262 | 288 |
263 protected: | 289 protected: |
264 explicit SocketHandle(SOCKET s) : Handle(reinterpret_cast<HANDLE>(s)) {} | 290 explicit SocketHandle(SOCKET s) : Handle(reinterpret_cast<HANDLE>(s)) {} |
265 SocketHandle(SOCKET s, Dart_Port port) | 291 SocketHandle(SOCKET s, Dart_Port port) |
266 : Handle(reinterpret_cast<HANDLE>(s), port) {} | 292 : Handle(reinterpret_cast<HANDLE>(s), port) {} |
267 | 293 |
268 virtual void HandleIssueError(); | 294 virtual void HandleIssueError(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 419 |
394 TimeoutQueue timeout_queue_; // Time for next timeout. | 420 TimeoutQueue timeout_queue_; // Time for next timeout. |
395 bool shutdown_; | 421 bool shutdown_; |
396 HANDLE completion_port_; | 422 HANDLE completion_port_; |
397 }; | 423 }; |
398 | 424 |
399 } // namespace bin | 425 } // namespace bin |
400 } // namespace dart | 426 } // namespace dart |
401 | 427 |
402 #endif // BIN_EVENTHANDLER_WIN_H_ | 428 #endif // BIN_EVENTHANDLER_WIN_H_ |
OLD | NEW |