Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: runtime/bin/eventhandler_win.h

Issue 8437090: Change the handling of closing sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by ager@ Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | runtime/bin/eventhandler_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_WIN_H_ 5 #ifndef BIN_EVENTHANDLER_WIN_H_
6 #define BIN_EVENTHANDLER_WIN_H_ 6 #define BIN_EVENTHANDLER_WIN_H_
7 7
8 #include <winsock2.h> 8 #include <winsock2.h>
9 #include <mswsock.h> 9 #include <mswsock.h>
10 10
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 ClientSocket* accepted_head_; 268 ClientSocket* accepted_head_;
269 ClientSocket* accepted_tail_; 269 ClientSocket* accepted_tail_;
270 }; 270 };
271 271
272 272
273 // Information on connected sockets. 273 // Information on connected sockets.
274 class ClientSocket : public SocketHandle { 274 class ClientSocket : public SocketHandle {
275 public: 275 public:
276 explicit ClientSocket(SOCKET s) 276 explicit ClientSocket(SOCKET s)
277 : SocketHandle(s), 277 : SocketHandle(s),
278 next_(NULL) { type_ = kClientSocket; } 278 next_(NULL),
279 flags_(0) { type_ = kClientSocket; }
279 280
280 ClientSocket(SOCKET s, Dart_Port port) 281 ClientSocket(SOCKET s, Dart_Port port)
281 : SocketHandle(s, port), 282 : SocketHandle(s, port),
282 next_(NULL) { type_ = kClientSocket; } 283 next_(NULL),
284 flags_(0) { type_ = kClientSocket; }
283 285
284 virtual ~ClientSocket() { 286 virtual ~ClientSocket() {
285 // Don't delete this object until all pending requests have been handled. 287 // Don't delete this object until all pending requests have been handled.
286 ASSERT(!HasPendingRead()); 288 ASSERT(!HasPendingRead());
287 ASSERT(!HasPendingWrite()); 289 ASSERT(!HasPendingWrite());
288 ASSERT(next_ == NULL); 290 ASSERT(next_ == NULL);
289 }; 291 };
290 292
293 void Shutdown(int how);
294 bool IsClosedRead() { return (flags_ & (1 << kCloseRead)) != 0; }
295 bool IsClosedWrite() { return (flags_ & (1 << kCloseWrite)) != 0; }
296
297 void MarkClosedRead() { flags_ |= (1 << kCloseRead); }
298 void MarkClosedWrite() { flags_ |= (1 << kCloseWrite); }
299
291 // Internal interface used by the event handler. 300 // Internal interface used by the event handler.
292 virtual bool IssueRead(); 301 virtual bool IssueRead();
293 virtual bool IssueWrite(); 302 virtual bool IssueWrite();
294 303
295 virtual void EnsureInitialized( 304 virtual void EnsureInitialized(
296 EventHandlerImplementation* event_handler); 305 EventHandlerImplementation* event_handler);
297 virtual bool IsClosed(); 306 virtual bool IsClosed();
298 307
299 ClientSocket* next() { return next_; } 308 ClientSocket* next() { return next_; }
300 void set_next(ClientSocket* next) { next_ = next; } 309 void set_next(ClientSocket* next) { next_ = next; }
301 310
302 private: 311 private:
312 enum Flags {
313 kCloseRead = 0,
314 kCloseWrite = 1
315 };
316
303 virtual void AfterClose(); 317 virtual void AfterClose();
304 318
305 ClientSocket* next_; 319 ClientSocket* next_;
320 int flags_;
306 }; 321 };
307 322
308 323
309 // Event handler. 324 // Event handler.
310 class EventHandlerImplementation { 325 class EventHandlerImplementation {
311 public: 326 public:
312 EventHandlerImplementation(); 327 EventHandlerImplementation();
313 virtual ~EventHandlerImplementation() {} 328 virtual ~EventHandlerImplementation() {}
314 329
315 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); 330 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
(...skipping 14 matching lines...) Expand all
330 private: 345 private:
331 ClientSocket* client_sockets_head_; 346 ClientSocket* client_sockets_head_;
332 347
333 int64_t timeout_; // Time for next timeout. 348 int64_t timeout_; // Time for next timeout.
334 Dart_Port timeout_port_; 349 Dart_Port timeout_port_;
335 HANDLE completion_port_; 350 HANDLE completion_port_;
336 }; 351 };
337 352
338 353
339 #endif // BIN_EVENTHANDLER_WIN_H_ 354 #endif // BIN_EVENTHANDLER_WIN_H_
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | runtime/bin/eventhandler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698