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

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

Issue 185543004: Merge all http-outgoing transfomers into _HttpOutgoing, including simpler(better) buffering. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | sdk/lib/io/http_impl.dart » ('j') | sdk/lib/io/http_impl.dart » ('J')
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 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 Future<Socket> addStream(Stream<List<int>> stream) { 1174 Future<Socket> addStream(Stream<List<int>> stream) {
1175 socket._ensureRawSocketSubscription(); 1175 socket._ensureRawSocketSubscription();
1176 streamCompleter = new Completer<Socket>(); 1176 streamCompleter = new Completer<Socket>();
1177 if (socket._raw != null) { 1177 if (socket._raw != null) {
1178 subscription = stream.listen( 1178 subscription = stream.listen(
1179 (data) { 1179 (data) {
1180 assert(!paused); 1180 assert(!paused);
1181 assert(buffer == null); 1181 assert(buffer == null);
1182 buffer = data; 1182 buffer = data;
1183 offset = 0; 1183 offset = 0;
1184 write(); 1184 try {
1185 write();
1186 } catch (e) {
1187 stop();
1188 socket._consumerDone();
1189 done(e);
1190 }
1185 }, 1191 },
1186 onError: (error, [stackTrace]) { 1192 onError: (error, [stackTrace]) {
1187 socket._consumerDone(); 1193 socket._consumerDone();
1188 done(error, stackTrace); 1194 done(error, stackTrace);
1189 }, 1195 },
1190 onDone: () { 1196 onDone: () {
1191 done(); 1197 done();
1192 }, 1198 },
1193 cancelOnError: true); 1199 cancelOnError: true);
1194 } 1200 }
1195 return streamCompleter.future; 1201 return streamCompleter.future;
1196 } 1202 }
1197 1203
1198 Future<Socket> close() { 1204 Future<Socket> close() {
1199 socket._consumerDone(); 1205 socket._consumerDone();
1200 return new Future.value(socket); 1206 return new Future.value(socket);
1201 } 1207 }
1202 1208
1203 void write() { 1209 void write() {
1204 try { 1210 if (subscription == null) return;
1205 if (subscription == null) return; 1211 assert(buffer != null);
1206 assert(buffer != null); 1212 // Write as much as possible.
1207 // Write as much as possible. 1213 offset += socket._write(buffer, offset, buffer.length - offset);
1208 offset += socket._write(buffer, offset, buffer.length - offset); 1214 if (offset < buffer.length) {
1209 if (offset < buffer.length) { 1215 if (!paused) {
1210 if (!paused) { 1216 paused = true;
1211 paused = true; 1217 subscription.pause();
1212 subscription.pause();
1213 }
1214 socket._enableWriteEvent();
1215 } else {
1216 buffer = null;
1217 if (paused) {
1218 paused = false;
1219 subscription.resume();
1220 }
1221 } 1218 }
1222 } catch (e) { 1219 socket._enableWriteEvent();
1223 stop(); 1220 } else {
1224 socket._consumerDone(); 1221 buffer = null;
1225 done(e); 1222 if (paused) {
1223 paused = false;
1224 subscription.resume();
1225 }
1226 } 1226 }
1227 } 1227 }
1228 1228
1229 void done([error, stackTrace]) { 1229 void done([error, stackTrace]) {
1230 if (streamCompleter != null) { 1230 if (streamCompleter != null) {
1231 if (error != null) { 1231 if (error != null) {
1232 streamCompleter.completeError(error, stackTrace); 1232 streamCompleter.completeError(error, stackTrace);
1233 } else { 1233 } else {
1234 streamCompleter.complete(socket); 1234 streamCompleter.complete(socket);
1235 } 1235 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1591
1592 Datagram _makeDatagram(List<int> data, 1592 Datagram _makeDatagram(List<int> data,
1593 String address, 1593 String address,
1594 List<int> in_addr, 1594 List<int> in_addr,
1595 int port) { 1595 int port) {
1596 return new Datagram( 1596 return new Datagram(
1597 data, 1597 data,
1598 new _InternetAddress(address, null, in_addr), 1598 new _InternetAddress(address, null, in_addr),
1599 port); 1599 port);
1600 } 1600 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | sdk/lib/io/http_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698