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

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

Issue 8992007: Make the repeating argument to timers optional. (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 // Interface for decoders decoding binary data into string data. The 5 // Interface for decoders decoding binary data into string data. The
6 // decoder keeps track of line breaks during decoding. 6 // decoder keeps track of line breaks during decoding.
7 interface _StringDecoder { 7 interface _StringDecoder {
8 // Add more binary data to be decoded. The ownership of the buffer 8 // Add more binary data to be decoded. The ownership of the buffer
9 // is transfered to the decoder and the caller most not modify it any more. 9 // is transfered to the decoder and the caller most not modify it any more.
10 int write(List<int> buffer); 10 int write(List<int> buffer);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 _closed = true; 350 _closed = true;
351 } 351 }
352 } 352 }
353 353
354 if (!_closed) { 354 if (!_closed) {
355 // Schedule data callback if string data available. 355 // Schedule data callback if string data available.
356 if (_clientDataHandler != null && 356 if (_clientDataHandler != null &&
357 !_decoder.isEmpty() && 357 !_decoder.isEmpty() &&
358 _scheduledDataCallback == null) { 358 _scheduledDataCallback == null) {
359 if (_scheduledLineCallback != null) _scheduledLineCallback.cancel(); 359 if (_scheduledLineCallback != null) _scheduledLineCallback.cancel();
360 _scheduledDataCallback = new Timer(issueDataCallback, 0, false); 360 _scheduledDataCallback = new Timer(issueDataCallback, 0);
361 } 361 }
362 362
363 // Schedule line callback if a line is available. 363 // Schedule line callback if a line is available.
364 if (_clientLineHandler != null && 364 if (_clientLineHandler != null &&
365 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) && 365 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) &&
366 _scheduledLineCallback == null) { 366 _scheduledLineCallback == null) {
367 if (_scheduledDataCallback != null) _scheduledDataCallback.cancel(); 367 if (_scheduledDataCallback != null) _scheduledDataCallback.cancel();
368 _scheduledLineCallback = new Timer(issueLineCallback, 0, false); 368 _scheduledLineCallback = new Timer(issueLineCallback, 0);
369 } 369 }
370 370
371 // Schedule close callback if no more data and input is closed. 371 // Schedule close callback if no more data and input is closed.
372 if (_decoder.isEmpty() && 372 if (_decoder.isEmpty() &&
373 _inputClosed && 373 _inputClosed &&
374 _scheduledCloseCallback == null) { 374 _scheduledCloseCallback == null) {
375 _scheduledCloseCallback = new Timer(issueCloseCallback, 0, false); 375 _scheduledCloseCallback = new Timer(issueCloseCallback, 0);
376 } 376 }
377 } 377 }
378 } 378 }
379 379
380 InputStream _input; 380 InputStream _input;
381 String _encoding; 381 String _encoding;
382 _StringDecoder _decoder; 382 _StringDecoder _decoder;
383 bool _inputClosed = false; // Is the underlying input stream closed? 383 bool _inputClosed = false; // Is the underlying input stream closed?
384 bool _closed = false; // Is this stream closed. 384 bool _closed = false; // Is this stream closed.
385 bool _eof = false; // Has all data been read from the decoder? 385 bool _eof = false; // Has all data been read from the decoder?
386 Timer _scheduledDataCallback; 386 Timer _scheduledDataCallback;
387 Timer _scheduledLineCallback; 387 Timer _scheduledLineCallback;
388 Timer _scheduledCloseCallback; 388 Timer _scheduledCloseCallback;
389 Function _clientDataHandler; 389 Function _clientDataHandler;
390 Function _clientLineHandler; 390 Function _clientLineHandler;
391 Function _clientCloseHandler; 391 Function _clientCloseHandler;
392 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698