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

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

Issue 18031023: Remove _BufferList from dart:io and now use BytesBuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use takeBytes not toBytes. Created 7 years, 5 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 }); 104 });
105 break; 105 break;
106 106
107 case _WebSocketOpcode.BINARY: 107 case _WebSocketOpcode.BINARY:
108 if (_currentMessageType != _WebSocketMessageType.NONE) { 108 if (_currentMessageType != _WebSocketMessageType.NONE) {
109 throw new WebSocketException("Protocol error"); 109 throw new WebSocketException("Protocol error");
110 } 110 }
111 _currentMessageType = _WebSocketMessageType.BINARY; 111 _currentMessageType = _WebSocketMessageType.BINARY;
112 _controller = new StreamController(sync: true); 112 _controller = new StreamController(sync: true);
113 _controller.stream 113 _controller.stream
114 .fold(new _BufferList(), (buffer, data) => buffer..add(data)) 114 .fold(new BytesBuilder(), (buffer, data) => buffer..add(data))
115 .then((buffer) { 115 .then((buffer) {
116 sink.add(buffer.readBytes()); 116 sink.add(buffer.takeBytes());
117 }, onError: (error) { 117 }, onError: (error) {
118 sink.addError(error); 118 sink.addError(error);
119 }); 119 });
120 break; 120 break;
121 121
122 case _WebSocketOpcode.CLOSE: 122 case _WebSocketOpcode.CLOSE:
123 case _WebSocketOpcode.PING: 123 case _WebSocketOpcode.PING:
124 case _WebSocketOpcode.PONG: 124 case _WebSocketOpcode.PONG:
125 // Control frames cannot be fragmented. 125 // Control frames cannot be fragmented.
126 if (!_fin) throw new WebSocketException("Protocol error"); 126 if (!_fin) throw new WebSocketException("Protocol error");
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 (code < WebSocketStatus.NORMAL_CLOSURE || 814 (code < WebSocketStatus.NORMAL_CLOSURE ||
815 code == WebSocketStatus.RESERVED_1004 || 815 code == WebSocketStatus.RESERVED_1004 ||
816 code == WebSocketStatus.NO_STATUS_RECEIVED || 816 code == WebSocketStatus.NO_STATUS_RECEIVED ||
817 code == WebSocketStatus.ABNORMAL_CLOSURE || 817 code == WebSocketStatus.ABNORMAL_CLOSURE ||
818 (code > WebSocketStatus.INTERNAL_SERVER_ERROR && 818 (code > WebSocketStatus.INTERNAL_SERVER_ERROR &&
819 code < WebSocketStatus.RESERVED_1015) || 819 code < WebSocketStatus.RESERVED_1015) ||
820 (code >= WebSocketStatus.RESERVED_1015 && 820 (code >= WebSocketStatus.RESERVED_1015 &&
821 code < 3000)); 821 code < 3000));
822 } 822 }
823 } 823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698