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

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

Issue 9029001: Add close to input stream and cleanup socket and streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class _BaseDataInputStream { 5 class _BaseDataInputStream {
6 abstract int available(); 6 abstract int available();
7 7
8 List<int> read([int len]) { 8 List<int> read([int len]) {
9 if (_closeCallbackCalled) return null; 9 if (_closeCallbackCalled) return null;
10 int bytesToRead = available(); 10 int bytesToRead = available();
(...skipping 17 matching lines...) Expand all
28 if (offset < 0) throw new StreamException("Illegal offset $offset"); 28 if (offset < 0) throw new StreamException("Illegal offset $offset");
29 if (len < 0) throw new StreamException("Illegal length $len"); 29 if (len < 0) throw new StreamException("Illegal length $len");
30 int bytesToRead = Math.min(len, available()); 30 int bytesToRead = Math.min(len, available());
31 return _readInto(buffer, offset, bytesToRead); 31 return _readInto(buffer, offset, bytesToRead);
32 } 32 }
33 33
34 void pipe(OutputStream output, [bool close = true]) { 34 void pipe(OutputStream output, [bool close = true]) {
35 _pipe(this, output, close: close); 35 _pipe(this, output, close: close);
36 } 36 }
37 37
38 void close() {
39 if (_scheduledDataCallback != null) _scheduledDataCallback.cancel();
40 _close();
41 _checkScheduleCallbacks();
42 }
43
38 bool get closed() => _closeCallbackCalled; 44 bool get closed() => _closeCallbackCalled;
39 45
40 void set dataHandler(void callback()) { 46 void set dataHandler(void callback()) {
41 _clientDataHandler = callback; 47 _clientDataHandler = callback;
42 _checkScheduleCallbacks(); 48 _checkScheduleCallbacks();
43 } 49 }
44 50
45 void set closeHandler(void callback()) { 51 void set closeHandler(void callback()) {
46 _clientCloseHandler = callback; 52 _clientCloseHandler = callback;
47 _checkScheduleCallbacks(); 53 _checkScheduleCallbacks();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 input.dataHandler = pipeDataHandler; 132 input.dataHandler = pipeDataHandler;
127 output.noPendingWriteHandler = null; 133 output.noPendingWriteHandler = null;
128 }; 134 };
129 135
130 _inputCloseHandler = input._clientCloseHandler; 136 _inputCloseHandler = input._clientCloseHandler;
131 input.dataHandler = pipeDataHandler; 137 input.dataHandler = pipeDataHandler;
132 input.closeHandler = pipeCloseHandler; 138 input.closeHandler = pipeCloseHandler;
133 output.noPendingWriteHandler = null; 139 output.noPendingWriteHandler = null;
134 } 140 }
135 141
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698