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

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

Issue 9474004: Make FileInputStream and FileOutputStream actually asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove accidental edit 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
OLDNEW
1 // Copyright (c) 2011, 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);
11 11
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (_clientCloseHandler !== null) _clientCloseHandler(); 353 if (_clientCloseHandler !== null) _clientCloseHandler();
354 _closed = true; 354 _closed = true;
355 } 355 }
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) _scheduledLineCallback.cancel(); 363 if (_scheduledLineCallback != null) {
364 _scheduledLineCallback.cancel();
365 }
364 _scheduledDataCallback = new Timer(issueDataCallback, 0); 366 _scheduledDataCallback = new Timer(issueDataCallback, 0);
365 } 367 }
366 368
367 // Schedule line callback if a line is available. 369 // Schedule line callback if a line is available.
368 if (_clientLineHandler != null && 370 if (_clientLineHandler != null &&
369 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) && 371 (_decoder.lineBreaks > 0 || (!_decoder.isEmpty() && _inputClosed)) &&
370 _scheduledLineCallback == null) { 372 _scheduledLineCallback == null) {
371 if (_scheduledDataCallback != null) _scheduledDataCallback.cancel(); 373 if (_scheduledDataCallback != null) {
374 _scheduledDataCallback.cancel();
375 }
372 _scheduledLineCallback = new Timer(issueLineCallback, 0); 376 _scheduledLineCallback = new Timer(issueLineCallback, 0);
373 } 377 }
374 378
375 // Schedule close callback if no more data and input is closed. 379 // Schedule close callback if no more data and input is closed.
376 if (_decoder.isEmpty() && 380 if (_decoder.isEmpty() &&
377 _inputClosed && 381 _inputClosed &&
378 _scheduledCloseCallback == null) { 382 _scheduledCloseCallback == null) {
379 _scheduledCloseCallback = new Timer(issueCloseCallback, 0); 383 _scheduledCloseCallback = new Timer(issueCloseCallback, 0);
380 } 384 }
381 } 385 }
382 } 386 }
383 387
384 InputStream _input; 388 InputStream _input;
385 String _encoding; 389 String _encoding;
386 _StringDecoder _decoder; 390 _StringDecoder _decoder;
387 bool _inputClosed = false; // Is the underlying input stream closed? 391 bool _inputClosed = false; // Is the underlying input stream closed?
388 bool _closed = false; // Is this stream closed. 392 bool _closed = false; // Is this stream closed.
389 bool _eof = false; // Has all data been read from the decoder? 393 bool _eof = false; // Has all data been read from the decoder?
390 Timer _scheduledDataCallback; 394 Timer _scheduledDataCallback;
391 Timer _scheduledLineCallback; 395 Timer _scheduledLineCallback;
392 Timer _scheduledCloseCallback; 396 Timer _scheduledCloseCallback;
393 Function _clientDataHandler; 397 Function _clientDataHandler;
394 Function _clientLineHandler; 398 Function _clientLineHandler;
395 Function _clientCloseHandler; 399 Function _clientCloseHandler;
396 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698