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

Side by Side Diff: dart/runtime/bin/socket_patch.dart

Issue 900363004: Introduce a kSetEventMaskCommand, some cleanups in windows eventhandler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 5 years, 10 months 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 | « dart/runtime/bin/eventhandler_win.cc ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 static const int FIRST_EVENT = READ_EVENT; 231 static const int FIRST_EVENT = READ_EVENT;
232 static const int LAST_EVENT = DESTROYED_EVENT; 232 static const int LAST_EVENT = DESTROYED_EVENT;
233 static const int EVENT_COUNT = LAST_EVENT - FIRST_EVENT + 1; 233 static const int EVENT_COUNT = LAST_EVENT - FIRST_EVENT + 1;
234 234
235 static const int CLOSE_COMMAND = 8; 235 static const int CLOSE_COMMAND = 8;
236 static const int SHUTDOWN_READ_COMMAND = 9; 236 static const int SHUTDOWN_READ_COMMAND = 9;
237 static const int SHUTDOWN_WRITE_COMMAND = 10; 237 static const int SHUTDOWN_WRITE_COMMAND = 10;
238 // The lower bits of RETURN_TOKEN_COMMAND messages contains the number 238 // The lower bits of RETURN_TOKEN_COMMAND messages contains the number
239 // of tokens returned. 239 // of tokens returned.
240 static const int RETURN_TOKEN_COMMAND = 11; 240 static const int RETURN_TOKEN_COMMAND = 11;
241 static const int SET_EVENT_MASK_COMMAND = 12;
241 static const int FIRST_COMMAND = CLOSE_COMMAND; 242 static const int FIRST_COMMAND = CLOSE_COMMAND;
242 static const int LAST_COMMAND = RETURN_TOKEN_COMMAND; 243 static const int LAST_COMMAND = SET_EVENT_MASK_COMMAND;
243 244
244 // Type flag send to the eventhandler providing additional 245 // Type flag send to the eventhandler providing additional
245 // information on the type of the file descriptor. 246 // information on the type of the file descriptor.
246 static const int LISTENING_SOCKET = 16; 247 static const int LISTENING_SOCKET = 16;
247 static const int PIPE_SOCKET = 17; 248 static const int PIPE_SOCKET = 17;
248 static const int TYPE_NORMAL_SOCKET = 0; 249 static const int TYPE_NORMAL_SOCKET = 0;
249 static const int TYPE_LISTENING_SOCKET = 1 << LISTENING_SOCKET; 250 static const int TYPE_LISTENING_SOCKET = 1 << LISTENING_SOCKET;
250 static const int TYPE_PIPE = 1 << PIPE_SOCKET; 251 static const int TYPE_PIPE = 1 << PIPE_SOCKET;
251 static const int TYPE_TYPE_MASK = TYPE_LISTENING_SOCKET | PIPE_SOCKET; 252 static const int TYPE_TYPE_MASK = TYPE_LISTENING_SOCKET | PIPE_SOCKET;
252 253
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 if (port != 0) socket.localPort = port; 517 if (port != 0) socket.localPort = port;
517 return socket; 518 return socket;
518 }); 519 });
519 } 520 }
520 521
521 _NativeSocket.datagram(this.address) 522 _NativeSocket.datagram(this.address)
522 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_UDP_SOCKET; 523 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_UDP_SOCKET;
523 524
524 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET | TYPE_TCP_SOCKET; 525 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET | TYPE_TCP_SOCKET;
525 526
526 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP_SOCKET; 527 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP_SOCKET {
528 isClosedWrite = true;
529 }
527 530
528 _NativeSocket.pipe() : typeFlags = TYPE_PIPE; 531 _NativeSocket.pipe() : typeFlags = TYPE_PIPE;
529 532
530 _NativeSocket.watch(int id) 533 _NativeSocket.watch(int id)
531 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_INTERNAL_SOCKET { 534 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_INTERNAL_SOCKET {
532 isClosedWrite = true; 535 isClosedWrite = true;
533 nativeSetSocketId(id); 536 nativeSetSocketId(id);
534 } 537 }
535 538
536 bool get isListening => (typeFlags & TYPE_LISTENING_SOCKET) != 0; 539 bool get isListening => (typeFlags & TYPE_LISTENING_SOCKET) != 0;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 eventHandlers[DESTROYED_EVENT] = destroyed; 801 eventHandlers[DESTROYED_EVENT] = destroyed;
799 } 802 }
800 803
801 void setListening({read: true, write: true}) { 804 void setListening({read: true, write: true}) {
802 sendReadEvents = read; 805 sendReadEvents = read;
803 sendWriteEvents = write; 806 sendWriteEvents = write;
804 if (read) issueReadEvent(); 807 if (read) issueReadEvent();
805 if (write) issueWriteEvent(); 808 if (write) issueWriteEvent();
806 if (!flagsSent && !isClosing) { 809 if (!flagsSent && !isClosing) {
807 flagsSent = true; 810 flagsSent = true;
808 int flags = 0; 811 int flags = 1 << SET_EVENT_MASK_COMMAND;
809 if (!isClosedRead) flags |= 1 << READ_EVENT; 812 if (!isClosedRead) flags |= 1 << READ_EVENT;
810 if (!isClosedWrite) flags |= 1 << WRITE_EVENT; 813 if (!isClosedWrite) flags |= 1 << WRITE_EVENT;
811 sendToEventHandler(flags); 814 sendToEventHandler(flags);
812 } 815 }
813 } 816 }
814 817
815 Future close() { 818 Future close() {
816 if (!isClosing && !isClosed) { 819 if (!isClosing && !isClosed) {
817 sendToEventHandler(1 << CLOSE_COMMAND); 820 sendToEventHandler(1 << CLOSE_COMMAND);
818 isClosing = true; 821 isClosing = true;
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 String address, 1933 String address,
1931 List<int> in_addr, 1934 List<int> in_addr,
1932 int port) { 1935 int port) {
1933 return new Datagram( 1936 return new Datagram(
1934 data, 1937 data,
1935 new _InternetAddress(address, null, in_addr), 1938 new _InternetAddress(address, null, in_addr),
1936 port); 1939 port);
1937 } 1940 }
1938 1941
1939 String _socketsStats() => _SocketsObservatory.toJSON(); 1942 String _socketsStats() => _SocketsObservatory.toJSON();
OLDNEW
« no previous file with comments | « dart/runtime/bin/eventhandler_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698