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

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

Issue 14057010: Re-write _BufferList to keep an internal Uint8List buffer, that will grow on demand. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment Created 7 years, 8 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 | « sdk/lib/io/file_impl.dart ('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 part of dart.io; 5 part of dart.io;
6 6
7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
8 8
9 class _WebSocketMessageType { 9 class _WebSocketMessageType {
10 static const int NONE = 0; 10 static const int NONE = 0;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 } 271 }
272 272
273 void _messageFrameEnd(EventSink sink) { 273 void _messageFrameEnd(EventSink sink) {
274 if (_fin) { 274 if (_fin) {
275 switch (_currentMessageType) { 275 switch (_currentMessageType) {
276 case _WebSocketMessageType.TEXT: 276 case _WebSocketMessageType.TEXT:
277 sink.add(_buffer.toString()); 277 sink.add(_buffer.toString());
278 break; 278 break;
279 case _WebSocketMessageType.BINARY: 279 case _WebSocketMessageType.BINARY:
280 if (_buffer.length == 0) { 280 sink.add(_buffer.readBytes());
281 sink.add(const []);
282 } else {
283 sink.add(_buffer.readBytes(_buffer.length));
284 }
285 break; 281 break;
286 } 282 }
287 _buffer = null; 283 _buffer = null;
288 _currentMessageType = _WebSocketMessageType.NONE; 284 _currentMessageType = _WebSocketMessageType.NONE;
289 } 285 }
290 _prepareForNextFrame(); 286 _prepareForNextFrame();
291 } 287 }
292 288
293 void _controlFrameEnd(EventSink sink) { 289 void _controlFrameEnd(EventSink sink) {
294 switch (_opcode) { 290 switch (_opcode) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 code == WebSocketStatus.RESERVED_1015) { 740 code == WebSocketStatus.RESERVED_1015) {
745 throw new WebSocketException("Reserved status code $code"); 741 throw new WebSocketException("Reserved status code $code");
746 } 742 }
747 _outCloseCode = code; 743 _outCloseCode = code;
748 _outCloseReason = reason; 744 _outCloseReason = reason;
749 _writeClosed = true; 745 _writeClosed = true;
750 } 746 }
751 return _sink.close(); 747 return _sink.close();
752 } 748 }
753 } 749 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698