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

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

Issue 9597015: Update Timer API to take the callback as the last parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « runtime/bin/stream_util.dart ('k') | runtime/bin/timer.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 // 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 if (!_closed) { 358 if (!_closed) {
359 // Schedule data callback if string data available. 359 // Schedule data callback if string data available.
360 if (_clientDataHandler != null && 360 if (_clientDataHandler != null &&
361 !_decoder.isEmpty() && 361 !_decoder.isEmpty() &&
362 _scheduledDataCallback == null) { 362 _scheduledDataCallback == null) {
363 if (_scheduledLineCallback != null) { 363 if (_scheduledLineCallback != null) {
364 _scheduledLineCallback.cancel(); 364 _scheduledLineCallback.cancel();
365 } 365 }
366 _scheduledDataCallback = new Timer(issueDataCallback, 0); 366 _scheduledDataCallback = new Timer(0, issueDataCallback);
367 } 367 }
368 368
369 // Schedule line callback if a line is available. 369 // Schedule line callback if a line is available.
370 if (_clientLineHandler != null && 370 if (_clientLineHandler != null &&
371 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) && 371 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) &&
372 _scheduledLineCallback == null) { 372 _scheduledLineCallback == null) {
373 if (_scheduledDataCallback != null) { 373 if (_scheduledDataCallback != null) {
374 _scheduledDataCallback.cancel(); 374 _scheduledDataCallback.cancel();
375 } 375 }
376 _scheduledLineCallback = new Timer(issueLineCallback, 0); 376 _scheduledLineCallback = new Timer(0, issueLineCallback);
377 } 377 }
378 378
379 // Schedule close callback if no more data and input is closed. 379 // Schedule close callback if no more data and input is closed.
380 if (_decoder.isEmpty() && 380 if (_decoder.isEmpty() &&
381 _inputClosed && 381 _inputClosed &&
382 _scheduledCloseCallback == null) { 382 _scheduledCloseCallback == null) {
383 _scheduledCloseCallback = new Timer(issueCloseCallback, 0); 383 _scheduledCloseCallback = new Timer(0, issueCloseCallback);
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388 InputStream _input; 388 InputStream _input;
389 String _encoding; 389 String _encoding;
390 _StringDecoder _decoder; 390 _StringDecoder _decoder;
391 bool _inputClosed = false; // Is the underlying input stream closed? 391 bool _inputClosed = false; // Is the underlying input stream closed?
392 bool _closed = false; // Is this stream closed. 392 bool _closed = false; // Is this stream closed.
393 bool _eof = false; // Has all data been read from the decoder? 393 bool _eof = false; // Has all data been read from the decoder?
394 Timer _scheduledDataCallback; 394 Timer _scheduledDataCallback;
395 Timer _scheduledLineCallback; 395 Timer _scheduledLineCallback;
396 Timer _scheduledCloseCallback; 396 Timer _scheduledCloseCallback;
397 Function _clientDataHandler; 397 Function _clientDataHandler;
398 Function _clientLineHandler; 398 Function _clientLineHandler;
399 Function _clientCloseHandler; 399 Function _clientCloseHandler;
400 } 400 }
OLDNEW
« no previous file with comments | « runtime/bin/stream_util.dart ('k') | runtime/bin/timer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698