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

Side by Side Diff: samples/chat/http_impl.dart

Issue 8726031: Change handling of accepting socket connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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/socket_impl.dart ('k') | tests/standalone/src/EchoServerStreamTest.dart » ('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 // Global constants. 5 // Global constants.
6 class Const { 6 class Const {
7 // Bytes for "HTTP/1.0". 7 // Bytes for "HTTP/1.0".
8 static final HTTP10 = const [72, 84, 84, 80, 47, 49, 46, 48]; 8 static final HTTP10 = const [72, 84, 84, 80, 47, 49, 46, 48];
9 // Bytes for "HTTP/1.1". 9 // Bytes for "HTTP/1.1".
10 static final HTTP11 = const [72, 84, 84, 80, 47, 49, 46, 49]; 10 static final HTTP11 = const [72, 84, 84, 80, 47, 49, 46, 49];
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 // HTTP server waiting for socket connections. The connections are 1104 // HTTP server waiting for socket connections. The connections are
1105 // managed by the server and as requests are received the request. 1105 // managed by the server and as requests are received the request.
1106 class HTTPServerImplementation implements HTTPServer { 1106 class HTTPServerImplementation implements HTTPServer {
1107 1107
1108 static final BUFFER_SIZE = 80; 1108 static final BUFFER_SIZE = 80;
1109 1109
1110 HTTPServerImplementation () : _debugTrace = false; 1110 HTTPServerImplementation () : _debugTrace = false;
1111 1111
1112 void listen(String host, int port, var callback) { 1112 void listen(String host, int port, var callback) {
1113 1113
1114 void connectionHandler() { 1114 void connectionHandler(Socket socket) {
1115 // Accept the client connection. 1115 // Accept the client connection.
1116 Socket socket = _server.accept();
1117 HTTPConnection connection = new HTTPConnection(socket); 1116 HTTPConnection connection = new HTTPConnection(socket);
1118 connection.requestReceived = callback; 1117 connection.requestReceived = callback;
1119 _connections.addLast(connection); 1118 _connections.addLast(connection);
1120 _connectionsCount++; 1119 _connectionsCount++;
1121 if (_debugTrace) { 1120 if (_debugTrace) {
1122 print("New connection (total $_connectionsCount connections)"); 1121 print("New connection (total $_connectionsCount connections)");
1123 } 1122 }
1124 } 1123 }
1125 1124
1126 _connections = new Queue<HTTPConnection>(); 1125 _connections = new Queue<HTTPConnection>();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 1479
1481 // Return connection. 1480 // Return connection.
1482 sockets.addFirst(socketConn); 1481 sockets.addFirst(socketConn);
1483 socketConn._markReturned(); 1482 socketConn._markReturned();
1484 } 1483 }
1485 1484
1486 Map<String, Queue<SocketConnection>> _openSockets; 1485 Map<String, Queue<SocketConnection>> _openSockets;
1487 Timer _evictionTimer; 1486 Timer _evictionTimer;
1488 bool _shutdown; // Has this HTTP client been shutdown? 1487 bool _shutdown; // Has this HTTP client been shutdown?
1489 } 1488 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_impl.dart ('k') | tests/standalone/src/EchoServerStreamTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698