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

Unified Diff: third_party/mojo/src/mojo/public/dart/src/drain_data.dart

Issue 1157843002: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/dart/src/drain_data.dart
diff --git a/third_party/mojo/src/mojo/public/dart/src/drain_data.dart b/third_party/mojo/src/mojo/public/dart/src/drain_data.dart
deleted file mode 100644
index b5929e567a3191f1582a32bcc011bb28a9a43549..0000000000000000000000000000000000000000
--- a/third_party/mojo/src/mojo/public/dart/src/drain_data.dart
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-part of core;
-
-class DataPipeDrainer {
- MojoDataPipeConsumer _consumer;
- MojoEventStream _eventStream;
- List<ByteData> _dataList;
- int _dataSize;
-
- DataPipeDrainer(this._consumer) {
- _eventStream = new MojoEventStream(_consumer.handle);
- _dataList = new List();
- _dataSize = 0;
- }
-
- ByteData _copy(ByteData byteData) =>
- new ByteData.view(
- new Uint8List.fromList(byteData.buffer.asUint8List()).buffer);
-
- MojoResult _doRead() {
- ByteData thisRead = _consumer.beginRead();
- if (thisRead == null) {
- throw 'Data pipe beginRead failed: ${_consumer.status}';
- }
- _dataList.add(_copy(thisRead));
- _dataSize += thisRead.lengthInBytes;
- return _consumer.endRead(thisRead.lengthInBytes);
- }
-
- ByteData _concatData() {
- var data = new ByteData(_dataSize);
- int end = 0;
- for (var chunk in _dataList) {
- data.buffer.asUint8List().setRange(
- end, end + chunk.lengthInBytes, chunk.buffer.asUint8List());
- end += chunk.lengthInBytes;
- }
- return data;
- }
-
- Future<ByteData> drain() {
- var completer = new Completer();
- _eventStream.listen((List<int> event) {
- var mojoSignals = new MojoHandleSignals(event[1]);
- if (mojoSignals.isReadable) {
- var result = _doRead();
- if (!result.isOk) {
- _eventStream.close();
- _eventStream = null;
- completer.complete(_concatData());
- } else {
- _eventStream.enableReadEvents();
- }
- } else if (mojoSignals.isPeerClosed) {
- _eventStream.close();
- _eventStream = null;
- completer.complete(_concatData());
- } else {
- throw 'Unexpected handle event: $mojoSignals';
- }
- });
- return completer.future;
- }
-
- static Future<ByteData> drainHandle(MojoDataPipeConsumer consumer) {
- var drainer = new DataPipeDrainer(consumer);
- return drainer.drain();
- }
-}
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/src/data_pipe.dart ('k') | third_party/mojo/src/mojo/public/dart/src/event_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698