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

Side by Side Diff: sdk/lib/io/http_parser.dart

Issue 16952005: dart:io | Rename optional carryOverData argument to SecureSocket.secureServer to bufferedData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/secure_socket.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) 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 part of dart.io; 5 part of dart.io;
6 6
7 // Global constants. 7 // Global constants.
8 class _Const { 8 class _Const {
9 // Bytes for "HTTP". 9 // Bytes for "HTTP".
10 static const HTTP = const [72, 84, 84, 80]; 10 static const HTTP = const [72, 84, 84, 80];
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 class _MessageType { 92 class _MessageType {
93 static const int UNDETERMINED = 0; 93 static const int UNDETERMINED = 0;
94 static const int REQUEST = 1; 94 static const int REQUEST = 1;
95 static const int RESPONSE = 0; 95 static const int RESPONSE = 0;
96 } 96 }
97 97
98 class _HttpDetachedIncoming extends Stream<List<int>> { 98 class _HttpDetachedIncoming extends Stream<List<int>> {
99 StreamController<List<int>> controller; 99 StreamController<List<int>> controller;
100 final StreamSubscription subscription; 100 final StreamSubscription subscription;
101 101
102 List<int> carryOverData; 102 List<int> bufferedData;
103 bool paused; 103 bool paused;
104 104
105 Completer resumeCompleter; 105 Completer resumeCompleter;
106 106
107 _HttpDetachedIncoming(StreamSubscription this.subscription, 107 _HttpDetachedIncoming(StreamSubscription this.subscription,
108 List<int> this.carryOverData) { 108 List<int> this.bufferedData) {
109 controller = new StreamController<List<int>>( 109 controller = new StreamController<List<int>>(
110 sync: true, 110 sync: true,
111 onListen: resume, 111 onListen: resume,
112 onPause: pause, 112 onPause: pause,
113 onResume: resume, 113 onResume: resume,
114 onCancel: () => subscription.cancel()); 114 onCancel: () => subscription.cancel());
115 if (subscription == null) { 115 if (subscription == null) {
116 // Socket was already closed. 116 // Socket was already closed.
117 if (carryOverData != null) controller.add(carryOverData); 117 if (bufferedData != null) controller.add(bufferedData);
118 controller.close(); 118 controller.close();
119 } else { 119 } else {
120 pause(); 120 pause();
121 subscription.resume(); 121 subscription.resume();
122 subscription.onData(controller.add); 122 subscription.onData(controller.add);
123 subscription.onDone(controller.close); 123 subscription.onDone(controller.close);
124 subscription.onError(controller.addError); 124 subscription.onError(controller.addError);
125 } 125 }
126 } 126 }
127 127
128 StreamSubscription<List<int>> listen(void onData(List<int> event), 128 StreamSubscription<List<int>> listen(void onData(List<int> event),
129 {void onError(error), 129 {void onError(error),
130 void onDone(), 130 void onDone(),
131 bool cancelOnError}) { 131 bool cancelOnError}) {
132 return controller.stream.listen( 132 return controller.stream.listen(
133 onData, 133 onData,
134 onError: onError, 134 onError: onError,
135 onDone: onDone, 135 onDone: onDone,
136 cancelOnError: cancelOnError); 136 cancelOnError: cancelOnError);
137 } 137 }
138 138
139 void resume() { 139 void resume() {
140 paused = false; 140 paused = false;
141 if (carryOverData != null) { 141 if (bufferedData != null) {
142 var data = carryOverData; 142 var data = bufferedData;
143 carryOverData = null; 143 bufferedData = null;
144 controller.add(data); 144 controller.add(data);
145 // If the consumer pauses again after the carry-over data, we'll not 145 // If the consumer pauses again after the carry-over data, we'll not
146 // continue our subscriber until the next resume. 146 // continue our subscriber until the next resume.
147 if (paused) return; 147 if (paused) return;
148 } 148 }
149 if (resumeCompleter != null) { 149 if (resumeCompleter != null) {
150 resumeCompleter.complete(); 150 resumeCompleter.complete();
151 resumeCompleter = null; 151 resumeCompleter = null;
152 } 152 }
153 } 153 }
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 _HttpHeaders _headers; 980 _HttpHeaders _headers;
981 981
982 // The current incoming connection. 982 // The current incoming connection.
983 _HttpIncoming _incoming; 983 _HttpIncoming _incoming;
984 StreamSubscription _socketSubscription; 984 StreamSubscription _socketSubscription;
985 bool _paused = true; 985 bool _paused = true;
986 bool _bodyPaused = false; 986 bool _bodyPaused = false;
987 StreamController<_HttpIncoming> _controller; 987 StreamController<_HttpIncoming> _controller;
988 StreamController<List<int>> _bodyController; 988 StreamController<List<int>> _bodyController;
989 } 989 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698