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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 void MarkDoesNotSupportOverlappedIO() { | 192 void MarkDoesNotSupportOverlappedIO() { |
193 flags_ |= (1 << kDoesNotSupportOverlappedIO); | 193 flags_ |= (1 << kDoesNotSupportOverlappedIO); |
194 } | 194 } |
195 bool SupportsOverlappedIO() { | 195 bool SupportsOverlappedIO() { |
196 return (flags_ & (1 << kDoesNotSupportOverlappedIO)) == 0; | 196 return (flags_ & (1 << kDoesNotSupportOverlappedIO)) == 0; |
197 } | 197 } |
198 | 198 |
199 void ReadSyncCompleteAsync(); | 199 void ReadSyncCompleteAsync(); |
200 | 200 |
| 201 DWORD last_error() { return last_error_; } |
| 202 void set_last_error(DWORD last_error) { last_error_ = last_error; } |
| 203 |
201 protected: | 204 protected: |
202 enum Flags { | 205 enum Flags { |
203 kClosing = 0, | 206 kClosing = 0, |
204 kCloseRead = 1, | 207 kCloseRead = 1, |
205 kCloseWrite = 2, | 208 kCloseWrite = 2, |
206 kDoesNotSupportOverlappedIO = 3 | 209 kDoesNotSupportOverlappedIO = 3 |
207 }; | 210 }; |
208 | 211 |
209 explicit Handle(HANDLE handle); | 212 explicit Handle(HANDLE handle); |
210 Handle(HANDLE handle, Dart_Port port); | 213 Handle(HANDLE handle, Dart_Port port); |
211 | 214 |
212 virtual void AfterClose() = 0; | 215 virtual void AfterClose() = 0; |
213 | 216 |
214 Type type_; | 217 Type type_; |
215 HANDLE handle_; | 218 HANDLE handle_; |
216 Dart_Port port_; // Dart port to communicate events for this socket. | 219 Dart_Port port_; // Dart port to communicate events for this socket. |
217 intptr_t mask_; // Mask of events to report through the port. | 220 intptr_t mask_; // Mask of events to report through the port. |
218 HANDLE completion_port_; | 221 HANDLE completion_port_; |
219 EventHandlerImplementation* event_handler_; | 222 EventHandlerImplementation* event_handler_; |
220 | 223 |
221 IOBuffer* data_ready_; // IO buffer for data ready to be read. | 224 IOBuffer* data_ready_; // IO buffer for data ready to be read. |
222 IOBuffer* pending_read_; // IO buffer for pending read. | 225 IOBuffer* pending_read_; // IO buffer for pending read. |
223 IOBuffer* pending_write_; // IO buffer for pending write | 226 IOBuffer* pending_write_; // IO buffer for pending write |
224 | 227 |
| 228 DWORD last_error_; |
| 229 |
225 private: | 230 private: |
226 int flags_; | 231 int flags_; |
227 CRITICAL_SECTION cs_; // Critical section protecting this object. | 232 CRITICAL_SECTION cs_; // Critical section protecting this object. |
228 }; | 233 }; |
229 | 234 |
230 | 235 |
231 class FileHandle : public Handle { | 236 class FileHandle : public Handle { |
232 public: | 237 public: |
233 explicit FileHandle(HANDLE handle) | 238 explicit FileHandle(HANDLE handle) |
234 : Handle(reinterpret_cast<HANDLE>(handle)) { type_ = kFile; } | 239 : Handle(reinterpret_cast<HANDLE>(handle)) { type_ = kFile; } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 virtual ~EventHandlerImplementation() {} | 347 virtual ~EventHandlerImplementation() {} |
343 | 348 |
344 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); | 349 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); |
345 void StartEventHandler(); | 350 void StartEventHandler(); |
346 | 351 |
347 DWORD GetTimeout(); | 352 DWORD GetTimeout(); |
348 void HandleInterrupt(InterruptMessage* msg); | 353 void HandleInterrupt(InterruptMessage* msg); |
349 void HandleTimeout(); | 354 void HandleTimeout(); |
350 void HandleAccept(ListenSocket* listen_socket, IOBuffer* buffer); | 355 void HandleAccept(ListenSocket* listen_socket, IOBuffer* buffer); |
351 void HandleClosed(Handle* handle); | 356 void HandleClosed(Handle* handle); |
| 357 void HandleError(Handle* handle); |
352 void HandleRead(Handle* handle, int bytes, IOBuffer* buffer); | 358 void HandleRead(Handle* handle, int bytes, IOBuffer* buffer); |
353 void HandleWrite(Handle* handle, int bytes, IOBuffer* buffer); | 359 void HandleWrite(Handle* handle, int bytes, IOBuffer* buffer); |
354 void HandleClose(ClientSocket* client_socket); | 360 void HandleClose(ClientSocket* client_socket); |
355 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); | 361 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); |
356 | 362 |
357 HANDLE completion_port() { return completion_port_; } | 363 HANDLE completion_port() { return completion_port_; } |
358 | 364 |
359 private: | 365 private: |
360 ClientSocket* client_sockets_head_; | 366 ClientSocket* client_sockets_head_; |
361 | 367 |
362 int64_t timeout_; // Time for next timeout. | 368 int64_t timeout_; // Time for next timeout. |
363 Dart_Port timeout_port_; | 369 Dart_Port timeout_port_; |
364 HANDLE completion_port_; | 370 HANDLE completion_port_; |
365 }; | 371 }; |
366 | 372 |
367 | 373 |
368 #endif // BIN_EVENTHANDLER_WIN_H_ | 374 #endif // BIN_EVENTHANDLER_WIN_H_ |
OLD | NEW |