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

Side by Side Diff: utils/archive/entry.dart

Issue 11785028: Commit Martin's patch for pub + lib_v2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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 | « pkg/http/lib/src/multipart_file.dart ('k') | utils/archive/input_stream.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 library entry; 5 library entry;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'archive.dart' as archive; 8 import 'archive.dart' as archive;
9 import 'entry_request.dart'; 9 import 'entry_request.dart';
10 import 'read_request.dart' as read; 10 import 'read_request.dart' as read;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } else if (_input != null) { 265 } else if (_input != null) {
266 throw new UnsupportedError("An input stream has already been" 266 throw new UnsupportedError("An input stream has already been"
267 "opened for archive entry $pathname."); 267 "opened for archive entry $pathname.");
268 } 268 }
269 269
270 var inputCompleter = new Completer(); 270 var inputCompleter = new Completer();
271 inputComplete = inputCompleter.future; 271 inputComplete = inputCompleter.future;
272 272
273 _input = new ListInputStream(); 273 _input = new ListInputStream();
274 // TODO(nweiz): Report errors once issue 3657 is fixed 274 // TODO(nweiz): Report errors once issue 3657 is fixed
275 var future = _consumeInput().chain((_) { 275 var future = _consumeInput().then((_) {
276 if (!_input.closed) _input.markEndOfStream(); 276 if (!_input.closed) _input.markEndOfStream();
277 // Asynchronously complete to give the InputStream callbacks a chance to 277 // Asynchronously complete to give the InputStream callbacks a chance to
278 // fire. 278 // fire.
279 return async(); 279 return async();
280 }).then((_) => inputCompleter.complete(null)); 280 }).then((_) => inputCompleter.complete(null));
281 281
282 future.handleException((e) { 282 future.handleException((e) {
283 print(e); 283 print(e);
284 print(future.stackTrace); 284 print(future.stackTrace);
285 }); 285 });
(...skipping 14 matching lines...) Expand all
300 /** 300 /**
301 * Read all data from the archive and write it to [_input]. Returns a future 301 * Read all data from the archive and write it to [_input]. Returns a future
302 * that completes once this is done. 302 * that completes once this is done.
303 * 303 *
304 * This assumes that both [_input] and [_archiveId] are non-null and that 304 * This assumes that both [_input] and [_archiveId] are non-null and that
305 * [_input] is open, although if that changes before this completes it will 305 * [_input] is open, although if that changes before this completes it will
306 * handle it gracefully. 306 * handle it gracefully.
307 */ 307 */
308 Future _consumeInput() { 308 Future _consumeInput() {
309 var data; 309 var data;
310 return call(read.DATA_BLOCK, _archiveId).chain((_data) { 310 return call(read.DATA_BLOCK, _archiveId).then((_data) {
311 data = _data; 311 data = _data;
312 // TODO(nweiz): This async() call is only necessary because of issue 4222. 312 // TODO(nweiz): This async() call is only necessary because of issue 4222.
313 return async(); 313 return async();
314 }).chain((_) { 314 }).then((_) {
315 if (_input.closed || _archiveId == null || data == null) { 315 if (_input.closed || _archiveId == null || data == null) {
316 return new Future.immediate(null); 316 return new Future.immediate(null);
317 } 317 }
318 _input.write(data); 318 _input.write(data);
319 return _consumeInput(); 319 return _consumeInput();
320 }); 320 });
321 } 321 }
322 } 322 }
323 323
324 /** 324 /**
325 * An [ArchiveEntry] that contains the complete decompressed contents of the 325 * An [ArchiveEntry] that contains the complete decompressed contents of the
326 * file. 326 * file.
327 */ 327 */
328 class CompleteArchiveEntry extends ArchiveEntry { 328 class CompleteArchiveEntry extends ArchiveEntry {
329 /** The contents of the entry as bytes. */ 329 /** The contents of the entry as bytes. */
330 final List<int> contentBytes; 330 final List<int> contentBytes;
331 331
332 /** The contents of the entry as a string. */ 332 /** The contents of the entry as a string. */
333 String get contents => new String.fromCharCodes(contentBytes); 333 String get contents => new String.fromCharCodes(contentBytes);
334 334
335 CompleteArchiveEntry._(List properties, this.contentBytes) 335 CompleteArchiveEntry._(List properties, this.contentBytes)
336 : super.internal(properties, null); 336 : super.internal(properties, null);
337 } 337 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/multipart_file.dart ('k') | utils/archive/input_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698