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

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

Issue 12213092: Rework Timer interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 10 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/secure_socket.dart ('k') | sdk/lib/io/stream_util.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _SocketInputStream implements InputStream { 7 class _SocketInputStream implements InputStream {
8 _SocketInputStream(Socket socket) : _socket = socket { 8 _SocketInputStream(Socket socket) : _socket = socket {
9 if (_socket._closed) _closed = true; 9 if (_socket._closed) _closed = true;
10 _socket.onClosed = _onClosed; 10 _socket.onClosed = _onClosed;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (_closing) return; 95 if (_closing) return;
96 _closing = true; 96 _closing = true;
97 if (!_pendingWrites.isEmpty) { 97 if (!_pendingWrites.isEmpty) {
98 // Mark the socket for close when all data is written. 98 // Mark the socket for close when all data is written.
99 _socket._onWrite = _onWrite; 99 _socket._onWrite = _onWrite;
100 } else { 100 } else {
101 // Close the socket for writing. 101 // Close the socket for writing.
102 _socket._closeWrite(); 102 _socket._closeWrite();
103 _closed = true; 103 _closed = true;
104 // Invoke the callback asynchronously. 104 // Invoke the callback asynchronously.
105 new Timer(0, (t) { 105 Timer.run(() {
106 if (_onClosed != null) _onClosed(); 106 if (_onClosed != null) _onClosed();
107 }); 107 });
108 } 108 }
109 } 109 }
110 110
111 void destroy() { 111 void destroy() {
112 _socket._onWrite = null; 112 _socket._onWrite = null;
113 _pendingWrites.clear(); 113 _pendingWrites.clear();
114 _socket.close(); 114 _socket.close();
115 _closed = true; 115 _closed = true;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 Socket _socket; 225 Socket _socket;
226 _BufferList _pendingWrites; 226 _BufferList _pendingWrites;
227 Function _onNoPendingWrites; 227 Function _onNoPendingWrites;
228 Function _onClosed; 228 Function _onClosed;
229 bool _closing = false; 229 bool _closing = false;
230 bool _closed = false; 230 bool _closed = false;
231 bool _error = false; 231 bool _error = false;
232 } 232 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | sdk/lib/io/stream_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698