| 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 RUNTIME_BIN_EVENTHANDLER_WIN_H_ | 5 #ifndef RUNTIME_BIN_EVENTHANDLER_WIN_H_ |
| 6 #define RUNTIME_BIN_EVENTHANDLER_WIN_H_ | 6 #define RUNTIME_BIN_EVENTHANDLER_WIN_H_ |
| 7 | 7 |
| 8 #if !defined(RUNTIME_BIN_EVENTHANDLER_H_) | 8 #if !defined(RUNTIME_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 15 matching lines...) Expand all Loading... |
| 26 class SocketHandle; | 26 class SocketHandle; |
| 27 class ClientSocket; | 27 class ClientSocket; |
| 28 class ListenSocket; | 28 class ListenSocket; |
| 29 | 29 |
| 30 // An OverlappedBuffer encapsulates the OVERLAPPED structure and the | 30 // An OverlappedBuffer encapsulates the OVERLAPPED structure and the |
| 31 // associated data buffer. For accept it also contains the pre-created | 31 // associated data buffer. For accept it also contains the pre-created |
| 32 // socket for the client. | 32 // socket for the client. |
| 33 class OverlappedBuffer { | 33 class OverlappedBuffer { |
| 34 public: | 34 public: |
| 35 enum Operation { | 35 enum Operation { |
| 36 kAccept, kRead, kRecvFrom, kWrite, kSendTo, kDisconnect, kConnect | 36 kAccept, |
| 37 kRead, |
| 38 kRecvFrom, |
| 39 kWrite, |
| 40 kSendTo, |
| 41 kDisconnect, |
| 42 kConnect |
| 37 }; | 43 }; |
| 38 | 44 |
| 39 static OverlappedBuffer* AllocateAcceptBuffer(int buffer_size); | 45 static OverlappedBuffer* AllocateAcceptBuffer(int buffer_size); |
| 40 static OverlappedBuffer* AllocateReadBuffer(int buffer_size); | 46 static OverlappedBuffer* AllocateReadBuffer(int buffer_size); |
| 41 static OverlappedBuffer* AllocateRecvFromBuffer(int buffer_size); | 47 static OverlappedBuffer* AllocateRecvFromBuffer(int buffer_size); |
| 42 static OverlappedBuffer* AllocateWriteBuffer(int buffer_size); | 48 static OverlappedBuffer* AllocateWriteBuffer(int buffer_size); |
| 43 static OverlappedBuffer* AllocateSendToBuffer(int buffer_size); | 49 static OverlappedBuffer* AllocateSendToBuffer(int buffer_size); |
| 44 static OverlappedBuffer* AllocateDisconnectBuffer(); | 50 static OverlappedBuffer* AllocateDisconnectBuffer(); |
| 45 static OverlappedBuffer* AllocateConnectBuffer(); | 51 static OverlappedBuffer* AllocateConnectBuffer(); |
| 46 static void DisposeBuffer(OverlappedBuffer* buffer); | 52 static void DisposeBuffer(OverlappedBuffer* buffer); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 int Write(const void* buffer, int num_bytes); | 67 int Write(const void* buffer, int num_bytes); |
| 62 | 68 |
| 63 // Check the amount of data in a read buffer which has not been read yet. | 69 // Check the amount of data in a read buffer which has not been read yet. |
| 64 int GetRemainingLength(); | 70 int GetRemainingLength(); |
| 65 bool IsEmpty() { return GetRemainingLength() == 0; } | 71 bool IsEmpty() { return GetRemainingLength() == 0; } |
| 66 | 72 |
| 67 Operation operation() { return operation_; } | 73 Operation operation() { return operation_; } |
| 68 SOCKET client() { return client_; } | 74 SOCKET client() { return client_; } |
| 69 char* GetBufferStart() { return reinterpret_cast<char*>(&buffer_data_); } | 75 char* GetBufferStart() { return reinterpret_cast<char*>(&buffer_data_); } |
| 70 int GetBufferSize() { return buflen_; } | 76 int GetBufferSize() { return buflen_; } |
| 71 struct sockaddr* from() { return from_; } | 77 struct sockaddr* from() { |
| 78 return from_; |
| 79 } |
| 72 socklen_t* from_len_addr() { return from_len_addr_; } | 80 socklen_t* from_len_addr() { return from_len_addr_; } |
| 73 socklen_t from_len() { return from_ == NULL ? 0 : *from_len_addr_; } | 81 socklen_t from_len() { return from_ == NULL ? 0 : *from_len_addr_; } |
| 74 | 82 |
| 75 // Returns the address of the OVERLAPPED structure with all fields | 83 // Returns the address of the OVERLAPPED structure with all fields |
| 76 // initialized to zero. | 84 // initialized to zero. |
| 77 OVERLAPPED* GetCleanOverlapped() { | 85 OVERLAPPED* GetCleanOverlapped() { |
| 78 memset(&overlapped_, 0, sizeof(overlapped_)); | 86 memset(&overlapped_, 0, sizeof(overlapped_)); |
| 79 return &overlapped_; | 87 return &overlapped_; |
| 80 } | 88 } |
| 81 | 89 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 OverlappedBuffer(int buffer_size, Operation operation) | 100 OverlappedBuffer(int buffer_size, Operation operation) |
| 93 : operation_(operation), buflen_(buffer_size) { | 101 : operation_(operation), buflen_(buffer_size) { |
| 94 memset(GetBufferStart(), 0, GetBufferSize()); | 102 memset(GetBufferStart(), 0, GetBufferSize()); |
| 95 if (operation == kRecvFrom) { | 103 if (operation == kRecvFrom) { |
| 96 // Reserve part of the buffer for the length of source sockaddr | 104 // Reserve part of the buffer for the length of source sockaddr |
| 97 // and source sockaddr. | 105 // and source sockaddr. |
| 98 const int kAdditionalSize = | 106 const int kAdditionalSize = |
| 99 sizeof(struct sockaddr_storage) + sizeof(socklen_t); | 107 sizeof(struct sockaddr_storage) + sizeof(socklen_t); |
| 100 ASSERT(buflen_ > kAdditionalSize); | 108 ASSERT(buflen_ > kAdditionalSize); |
| 101 buflen_ -= kAdditionalSize; | 109 buflen_ -= kAdditionalSize; |
| 102 from_len_addr_ = reinterpret_cast<socklen_t*>( | 110 from_len_addr_ = |
| 103 GetBufferStart() + GetBufferSize()); | 111 reinterpret_cast<socklen_t*>(GetBufferStart() + GetBufferSize()); |
| 104 *from_len_addr_ = sizeof(struct sockaddr_storage); | 112 *from_len_addr_ = sizeof(struct sockaddr_storage); |
| 105 from_ = reinterpret_cast<struct sockaddr*>(from_len_addr_ + 1); | 113 from_ = reinterpret_cast<struct sockaddr*>(from_len_addr_ + 1); |
| 106 } else { | 114 } else { |
| 107 from_len_addr_ = NULL; | 115 from_len_addr_ = NULL; |
| 108 from_ = NULL; | 116 from_ = NULL; |
| 109 } | 117 } |
| 110 index_ = 0; | 118 index_ = 0; |
| 111 data_length_ = 0; | 119 data_length_ = 0; |
| 112 if (operation_ == kAccept) { | 120 if (operation_ == kAccept) { |
| 113 client_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | 121 client_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
| 114 } | 122 } |
| 115 } | 123 } |
| 116 | 124 |
| 117 void* operator new(size_t size, int buffer_size) { | 125 void* operator new(size_t size, int buffer_size) { |
| 118 return malloc(size + buffer_size); | 126 return malloc(size + buffer_size); |
| 119 } | 127 } |
| 120 | 128 |
| 121 void operator delete(void* buffer) { | 129 void operator delete(void* buffer) { free(buffer); } |
| 122 free(buffer); | |
| 123 } | |
| 124 | 130 |
| 125 // Allocate an overlapped buffer for thse specified amount of data and | 131 // Allocate an overlapped buffer for thse specified amount of data and |
| 126 // operation. Some operations need additional buffer space, which is | 132 // operation. Some operations need additional buffer space, which is |
| 127 // handled by this method. | 133 // handled by this method. |
| 128 static OverlappedBuffer* AllocateBuffer(int buffer_size, | 134 static OverlappedBuffer* AllocateBuffer(int buffer_size, Operation operation); |
| 129 Operation operation); | |
| 130 | 135 |
| 131 OVERLAPPED overlapped_; // OVERLAPPED structure for overlapped IO. | 136 OVERLAPPED overlapped_; // OVERLAPPED structure for overlapped IO. |
| 132 SOCKET client_; // Used for AcceptEx client socket. | 137 SOCKET client_; // Used for AcceptEx client socket. |
| 133 int buflen_; // Length of the buffer. | 138 int buflen_; // Length of the buffer. |
| 134 Operation operation_; // Type of operation issued. | 139 Operation operation_; // Type of operation issued. |
| 135 | 140 |
| 136 int index_; // Index for next read from read buffer. | 141 int index_; // Index for next read from read buffer. |
| 137 int data_length_; // Length of the actual data in the buffer. | 142 int data_length_; // Length of the actual data in the buffer. |
| 138 | 143 |
| 139 WSABUF wbuf_; // Structure for passing buffer to WSA functions. | 144 WSABUF wbuf_; // Structure for passing buffer to WSA functions. |
| 140 | 145 |
| 141 // For the recvfrom operation additional storace is allocated for the | 146 // For the recvfrom operation additional storace is allocated for the |
| 142 // source sockaddr. | 147 // source sockaddr. |
| 143 socklen_t* from_len_addr_; // Pointer to source sockaddr size storage. | 148 socklen_t* from_len_addr_; // Pointer to source sockaddr size storage. |
| 144 struct sockaddr* from_; // Pointer to source sockaddr storage. | 149 struct sockaddr* from_; // Pointer to source sockaddr storage. |
| 145 | 150 |
| 146 // Buffer for recv/send/AcceptEx. This must be at the end of the | 151 // Buffer for recv/send/AcceptEx. This must be at the end of the |
| 147 // object as the object is allocated larger than it's definition | 152 // object as the object is allocated larger than it's definition |
| 148 // indicate to extend this array. | 153 // indicate to extend this array. |
| 149 uint8_t buffer_data_[1]; | 154 uint8_t buffer_data_[1]; |
| 150 | 155 |
| 151 DISALLOW_COPY_AND_ASSIGN(OverlappedBuffer); | 156 DISALLOW_COPY_AND_ASSIGN(OverlappedBuffer); |
| 152 }; | 157 }; |
| 153 | 158 |
| 154 | 159 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 198 |
| 194 bool IsClosing() { return (flags_ & (1 << kClosing)) != 0; } | 199 bool IsClosing() { return (flags_ & (1 << kClosing)) != 0; } |
| 195 bool IsClosedRead() { return (flags_ & (1 << kCloseRead)) != 0; } | 200 bool IsClosedRead() { return (flags_ & (1 << kCloseRead)) != 0; } |
| 196 bool IsClosedWrite() { return (flags_ & (1 << kCloseWrite)) != 0; } | 201 bool IsClosedWrite() { return (flags_ & (1 << kCloseWrite)) != 0; } |
| 197 bool IsError() { return (flags_ & (1 << kError)) != 0; } | 202 bool IsError() { return (flags_ & (1 << kError)) != 0; } |
| 198 void MarkClosing() { flags_ |= (1 << kClosing); } | 203 void MarkClosing() { flags_ |= (1 << kClosing); } |
| 199 void MarkClosedRead() { flags_ |= (1 << kCloseRead); } | 204 void MarkClosedRead() { flags_ |= (1 << kCloseRead); } |
| 200 void MarkClosedWrite() { flags_ |= (1 << kCloseWrite); } | 205 void MarkClosedWrite() { flags_ |= (1 << kCloseWrite); } |
| 201 void MarkError() { flags_ |= (1 << kError); } | 206 void MarkError() { flags_ |= (1 << kError); } |
| 202 | 207 |
| 203 virtual void EnsureInitialized( | 208 virtual void EnsureInitialized(EventHandlerImplementation* event_handler) = 0; |
| 204 EventHandlerImplementation* event_handler) = 0; | |
| 205 | 209 |
| 206 HANDLE handle() { return handle_; } | 210 HANDLE handle() { return handle_; } |
| 207 | 211 |
| 208 bool CreateCompletionPort(HANDLE completion_port); | 212 bool CreateCompletionPort(HANDLE completion_port); |
| 209 | 213 |
| 210 void Close(); | 214 void Close(); |
| 211 virtual void DoClose(); | 215 virtual void DoClose(); |
| 212 virtual bool IsClosed() = 0; | 216 virtual bool IsClosed() = 0; |
| 213 | 217 |
| 214 bool IsHandleClosed() const { return handle_ == INVALID_HANDLE_VALUE; } | 218 bool IsHandleClosed() const { return handle_ == INVALID_HANDLE_VALUE; } |
| 215 | 219 |
| 216 Type type() { return type_; } | 220 Type type() { return type_; } |
| 217 bool is_file() { return type_ == kFile; } | 221 bool is_file() { return type_ == kFile; } |
| 218 bool is_socket() { return type_ == kListenSocket || | 222 bool is_socket() { |
| 219 type_ == kClientSocket || | 223 return type_ == kListenSocket || type_ == kClientSocket || |
| 220 type_ == kDatagramSocket; } | 224 type_ == kDatagramSocket; |
| 225 } |
| 221 bool is_listen_socket() { return type_ == kListenSocket; } | 226 bool is_listen_socket() { return type_ == kListenSocket; } |
| 222 bool is_client_socket() { return type_ == kClientSocket; } | 227 bool is_client_socket() { return type_ == kClientSocket; } |
| 223 bool is_datagram_socket() { return type_ == kDatagramSocket; } | 228 bool is_datagram_socket() { return type_ == kDatagramSocket; } |
| 224 | 229 |
| 225 void MarkDoesNotSupportOverlappedIO() { | 230 void MarkDoesNotSupportOverlappedIO() { |
| 226 flags_ |= (1 << kDoesNotSupportOverlappedIO); | 231 flags_ |= (1 << kDoesNotSupportOverlappedIO); |
| 227 } | 232 } |
| 228 bool SupportsOverlappedIO() { | 233 bool SupportsOverlappedIO() { |
| 229 return (flags_ & (1 << kDoesNotSupportOverlappedIO)) == 0; | 234 return (flags_ & (1 << kDoesNotSupportOverlappedIO)) == 0; |
| 230 } | 235 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 249 explicit Handle(intptr_t handle); | 254 explicit Handle(intptr_t handle); |
| 250 | 255 |
| 251 virtual void HandleIssueError(); | 256 virtual void HandleIssueError(); |
| 252 | 257 |
| 253 Monitor* monitor_; | 258 Monitor* monitor_; |
| 254 Type type_; | 259 Type type_; |
| 255 HANDLE handle_; | 260 HANDLE handle_; |
| 256 HANDLE completion_port_; | 261 HANDLE completion_port_; |
| 257 EventHandlerImplementation* event_handler_; | 262 EventHandlerImplementation* event_handler_; |
| 258 | 263 |
| 259 OverlappedBuffer* data_ready_; // Buffer for data ready to be read. | 264 OverlappedBuffer* data_ready_; // Buffer for data ready to be read. |
| 260 OverlappedBuffer* pending_read_; // Buffer for pending read. | 265 OverlappedBuffer* pending_read_; // Buffer for pending read. |
| 261 OverlappedBuffer* pending_write_; // Buffer for pending write | 266 OverlappedBuffer* pending_write_; // Buffer for pending write |
| 262 | 267 |
| 263 DWORD last_error_; | 268 DWORD last_error_; |
| 264 | 269 |
| 265 ThreadId read_thread_id_; | 270 ThreadId read_thread_id_; |
| 266 HANDLE read_thread_handle_; | 271 HANDLE read_thread_handle_; |
| 267 bool read_thread_starting_; | 272 bool read_thread_starting_; |
| 268 bool read_thread_finished_; | 273 bool read_thread_finished_; |
| 269 | 274 |
| 270 private: | 275 private: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 350 |
| 346 DISALLOW_COPY_AND_ASSIGN(DirectoryWatchHandle); | 351 DISALLOW_COPY_AND_ASSIGN(DirectoryWatchHandle); |
| 347 }; | 352 }; |
| 348 | 353 |
| 349 | 354 |
| 350 class SocketHandle : public Handle { | 355 class SocketHandle : public Handle { |
| 351 public: | 356 public: |
| 352 SOCKET socket() const { return socket_; } | 357 SOCKET socket() const { return socket_; } |
| 353 | 358 |
| 354 protected: | 359 protected: |
| 355 explicit SocketHandle(intptr_t s) | 360 explicit SocketHandle(intptr_t s) : Handle(s), socket_(s) {} |
| 356 : Handle(s), | |
| 357 socket_(s) {} | |
| 358 | 361 |
| 359 virtual void HandleIssueError(); | 362 virtual void HandleIssueError(); |
| 360 | 363 |
| 361 private: | 364 private: |
| 362 const SOCKET socket_; | 365 const SOCKET socket_; |
| 363 | 366 |
| 364 DISALLOW_COPY_AND_ASSIGN(SocketHandle); | 367 DISALLOW_COPY_AND_ASSIGN(SocketHandle); |
| 365 }; | 368 }; |
| 366 | 369 |
| 367 | 370 |
| 368 // Information on listen sockets. | 371 // Information on listen sockets. |
| 369 class ListenSocket : public DescriptorInfoMultipleMixin<SocketHandle> { | 372 class ListenSocket : public DescriptorInfoMultipleMixin<SocketHandle> { |
| 370 public: | 373 public: |
| 371 explicit ListenSocket(intptr_t s) : DescriptorInfoMultipleMixin(s, true), | 374 explicit ListenSocket(intptr_t s) |
| 372 AcceptEx_(NULL), | 375 : DescriptorInfoMultipleMixin(s, true), |
| 373 pending_accept_count_(0), | 376 AcceptEx_(NULL), |
| 374 accepted_head_(NULL), | 377 pending_accept_count_(0), |
| 375 accepted_tail_(NULL), | 378 accepted_head_(NULL), |
| 376 accepted_count_(0) { | 379 accepted_tail_(NULL), |
| 380 accepted_count_(0) { |
| 377 type_ = kListenSocket; | 381 type_ = kListenSocket; |
| 378 } | 382 } |
| 379 virtual ~ListenSocket() { | 383 virtual ~ListenSocket() { |
| 380 ASSERT(!HasPendingAccept()); | 384 ASSERT(!HasPendingAccept()); |
| 381 ASSERT(accepted_head_ == NULL); | 385 ASSERT(accepted_head_ == NULL); |
| 382 ASSERT(accepted_tail_ == NULL); | 386 ASSERT(accepted_tail_ == NULL); |
| 383 } | 387 } |
| 384 | 388 |
| 385 // Socket interface exposing normal socket operations. | 389 // Socket interface exposing normal socket operations. |
| 386 ClientSocket* Accept(); | 390 ClientSocket* Accept(); |
| 387 bool CanAccept(); | 391 bool CanAccept(); |
| 388 | 392 |
| 389 // Internal interface used by the event handler. | 393 // Internal interface used by the event handler. |
| 390 bool HasPendingAccept() { return pending_accept_count_ > 0; } | 394 bool HasPendingAccept() { return pending_accept_count_ > 0; } |
| 391 bool IssueAccept(); | 395 bool IssueAccept(); |
| 392 void AcceptComplete(OverlappedBuffer* buffer, HANDLE completion_port); | 396 void AcceptComplete(OverlappedBuffer* buffer, HANDLE completion_port); |
| 393 | 397 |
| 394 virtual void EnsureInitialized( | 398 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); |
| 395 EventHandlerImplementation* event_handler); | |
| 396 virtual void DoClose(); | 399 virtual void DoClose(); |
| 397 virtual bool IsClosed(); | 400 virtual bool IsClosed(); |
| 398 | 401 |
| 399 int pending_accept_count() { return pending_accept_count_; } | 402 int pending_accept_count() { return pending_accept_count_; } |
| 400 | 403 |
| 401 int accepted_count() { return accepted_count_; } | 404 int accepted_count() { return accepted_count_; } |
| 402 | 405 |
| 403 private: | 406 private: |
| 404 bool LoadAcceptEx(); | 407 bool LoadAcceptEx(); |
| 405 | 408 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 418 // this queue and processed by dart isolates. | 421 // this queue and processed by dart isolates. |
| 419 int accepted_count_; | 422 int accepted_count_; |
| 420 | 423 |
| 421 DISALLOW_COPY_AND_ASSIGN(ListenSocket); | 424 DISALLOW_COPY_AND_ASSIGN(ListenSocket); |
| 422 }; | 425 }; |
| 423 | 426 |
| 424 | 427 |
| 425 // Information on connected sockets. | 428 // Information on connected sockets. |
| 426 class ClientSocket : public DescriptorInfoSingleMixin<SocketHandle> { | 429 class ClientSocket : public DescriptorInfoSingleMixin<SocketHandle> { |
| 427 public: | 430 public: |
| 428 explicit ClientSocket(intptr_t s) : DescriptorInfoSingleMixin(s, true), | 431 explicit ClientSocket(intptr_t s) |
| 429 DisconnectEx_(NULL), | 432 : DescriptorInfoSingleMixin(s, true), |
| 430 next_(NULL), | 433 DisconnectEx_(NULL), |
| 431 connected_(false), | 434 next_(NULL), |
| 432 closed_(false) { | 435 connected_(false), |
| 436 closed_(false) { |
| 433 LoadDisconnectEx(); | 437 LoadDisconnectEx(); |
| 434 type_ = kClientSocket; | 438 type_ = kClientSocket; |
| 435 } | 439 } |
| 436 | 440 |
| 437 virtual ~ClientSocket() { | 441 virtual ~ClientSocket() { |
| 438 // Don't delete this object until all pending requests have been handled. | 442 // Don't delete this object until all pending requests have been handled. |
| 439 ASSERT(!HasPendingRead()); | 443 ASSERT(!HasPendingRead()); |
| 440 ASSERT(!HasPendingWrite()); | 444 ASSERT(!HasPendingWrite()); |
| 441 ASSERT(next_ == NULL); | 445 ASSERT(next_ == NULL); |
| 442 ASSERT(closed_ == true); | 446 ASSERT(closed_ == true); |
| 443 } | 447 } |
| 444 | 448 |
| 445 void Shutdown(int how); | 449 void Shutdown(int how); |
| 446 | 450 |
| 447 // Internal interface used by the event handler. | 451 // Internal interface used by the event handler. |
| 448 virtual bool IssueRead(); | 452 virtual bool IssueRead(); |
| 449 virtual bool IssueWrite(); | 453 virtual bool IssueWrite(); |
| 450 void IssueDisconnect(); | 454 void IssueDisconnect(); |
| 451 void DisconnectComplete(OverlappedBuffer* buffer); | 455 void DisconnectComplete(OverlappedBuffer* buffer); |
| 452 | 456 |
| 453 void ConnectComplete(OverlappedBuffer* buffer); | 457 void ConnectComplete(OverlappedBuffer* buffer); |
| 454 | 458 |
| 455 virtual void EnsureInitialized( | 459 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); |
| 456 EventHandlerImplementation* event_handler); | |
| 457 virtual void DoClose(); | 460 virtual void DoClose(); |
| 458 virtual bool IsClosed(); | 461 virtual bool IsClosed(); |
| 459 | 462 |
| 460 ClientSocket* next() { return next_; } | 463 ClientSocket* next() { return next_; } |
| 461 void set_next(ClientSocket* next) { next_ = next; } | 464 void set_next(ClientSocket* next) { next_ = next; } |
| 462 | 465 |
| 463 void mark_connected() { | 466 void mark_connected() { connected_ = true; } |
| 464 connected_ = true; | |
| 465 } | |
| 466 bool is_connected() const { return connected_; } | 467 bool is_connected() const { return connected_; } |
| 467 | 468 |
| 468 void mark_closed() { | 469 void mark_closed() { closed_ = true; } |
| 469 closed_ = true; | |
| 470 } | |
| 471 | 470 |
| 472 private: | 471 private: |
| 473 bool LoadDisconnectEx(); | 472 bool LoadDisconnectEx(); |
| 474 | 473 |
| 475 LPFN_DISCONNECTEX DisconnectEx_; | 474 LPFN_DISCONNECTEX DisconnectEx_; |
| 476 ClientSocket* next_; | 475 ClientSocket* next_; |
| 477 bool connected_; | 476 bool connected_; |
| 478 bool closed_; | 477 bool closed_; |
| 479 | 478 |
| 480 DISALLOW_COPY_AND_ASSIGN(ClientSocket); | 479 DISALLOW_COPY_AND_ASSIGN(ClientSocket); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 void SendData(intptr_t id, Dart_Port dart_port, int64_t data); | 514 void SendData(intptr_t id, Dart_Port dart_port, int64_t data); |
| 516 void Start(EventHandler* handler); | 515 void Start(EventHandler* handler); |
| 517 void Shutdown(); | 516 void Shutdown(); |
| 518 | 517 |
| 519 static void EventHandlerEntry(uword args); | 518 static void EventHandlerEntry(uword args); |
| 520 | 519 |
| 521 int64_t GetTimeout(); | 520 int64_t GetTimeout(); |
| 522 void HandleInterrupt(InterruptMessage* msg); | 521 void HandleInterrupt(InterruptMessage* msg); |
| 523 void HandleTimeout(); | 522 void HandleTimeout(); |
| 524 void HandleAccept(ListenSocket* listen_socket, OverlappedBuffer* buffer); | 523 void HandleAccept(ListenSocket* listen_socket, OverlappedBuffer* buffer); |
| 525 void TryDispatchingPendingAccepts(ListenSocket *listen_socket); | 524 void TryDispatchingPendingAccepts(ListenSocket* listen_socket); |
| 526 void HandleRead(Handle* handle, int bytes, OverlappedBuffer* buffer); | 525 void HandleRead(Handle* handle, int bytes, OverlappedBuffer* buffer); |
| 527 void HandleRecvFrom(Handle* handle, int bytes, OverlappedBuffer* buffer); | 526 void HandleRecvFrom(Handle* handle, int bytes, OverlappedBuffer* buffer); |
| 528 void HandleWrite(Handle* handle, int bytes, OverlappedBuffer* buffer); | 527 void HandleWrite(Handle* handle, int bytes, OverlappedBuffer* buffer); |
| 529 void HandleDisconnect(ClientSocket* client_socket, | 528 void HandleDisconnect(ClientSocket* client_socket, |
| 530 int bytes, | 529 int bytes, |
| 531 OverlappedBuffer* buffer); | 530 OverlappedBuffer* buffer); |
| 532 void HandleConnect(ClientSocket* client_socket, | 531 void HandleConnect(ClientSocket* client_socket, |
| 533 int bytes, | 532 int bytes, |
| 534 OverlappedBuffer* buffer); | 533 OverlappedBuffer* buffer); |
| 535 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); | 534 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 547 bool shutdown_; | 546 bool shutdown_; |
| 548 HANDLE completion_port_; | 547 HANDLE completion_port_; |
| 549 | 548 |
| 550 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); | 549 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); |
| 551 }; | 550 }; |
| 552 | 551 |
| 553 } // namespace bin | 552 } // namespace bin |
| 554 } // namespace dart | 553 } // namespace dart |
| 555 | 554 |
| 556 #endif // RUNTIME_BIN_EVENTHANDLER_WIN_H_ | 555 #endif // RUNTIME_BIN_EVENTHANDLER_WIN_H_ |
| OLD | NEW |