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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 284313011: Add IO service object handler, with initial implementation for HTTP server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/main.cc ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 70b81b1cb91e569d4dafe82d0b743354c84442f7..e9b610e00fedc9aa32c6c885e65b1935b9dc5e3f 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -2035,7 +2035,15 @@ class _HttpConnection extends LinkedListEntry<_HttpConnection> {
// HTTP server waiting for socket connections.
-class _HttpServer extends Stream<HttpRequest> implements HttpServer {
+class _HttpServer
+ extends Stream<HttpRequest> with _ServiceObject
+ implements HttpServer {
+ // Use default Map so we keep order.
+ static Map<int, _HttpServer> _servers = new Map<int, _HttpServer>();
+
+ final String _serviceTypePath = 'io/http/servers';
+ final String _serviceTypeName = 'HttpServer';
+
String serverHeader;
Duration _idleTimeout;
@@ -2067,12 +2075,14 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer {
_controller = new StreamController<HttpRequest>(sync: true,
onCancel: close);
idleTimeout = const Duration(seconds: 120);
+ _servers[_serviceId] = this;
}
_HttpServer.listenOn(this._serverSocket) : _closeServer = false {
_controller = new StreamController<HttpRequest>(sync: true,
onCancel: close);
idleTimeout = const Duration(seconds: 120);
+ _servers[_serviceId] = this;
}
Duration get idleTimeout => _idleTimeout;
@@ -2139,17 +2149,18 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer {
for (var c in _idleConnections.toList()) {
c.destroy();
}
- _maybeCloseSessionManager();
+ _maybePerformCleanup();
return result;
}
- void _maybeCloseSessionManager() {
+ void _maybePerformCleanup() {
if (closed &&
_idleConnections.isEmpty &&
_activeConnections.isEmpty &&
_sessionManagerInstance != null) {
_sessionManagerInstance.close();
_sessionManagerInstance = null;
+ _servers.remove(_serviceId);
}
}
@@ -2176,7 +2187,7 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer {
void _connectionClosed(_HttpConnection connection) {
// Remove itself from either idle or active connections.
connection.unlink();
- _maybeCloseSessionManager();
+ _maybePerformCleanup();
}
void _markIdle(_HttpConnection connection) {
@@ -2215,6 +2226,24 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer {
return result;
}
+ Map _toJSON(bool ref) {
+ var r = {
+ 'id': _servicePath,
+ 'type': _serviceType(ref),
+ 'name': '${address.host}:$port',
+ 'user_name': '${address.host}:$port',
+ };
+ if (ref) {
+ return r;
+ }
+ r['port'] = port;
+ r['address'] = address.host;
+ r['active'] = _activeConnections.length;
+ r['idle'] = _idleConnections.length;
+ r['closed'] = closed;
+ return r;
+ }
+
_HttpSessionManager _sessionManagerInstance;
// Indicated if the http server has been closed.
« no previous file with comments | « runtime/bin/main.cc ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698