Remove unused DevFsProgressReporter (#11249)
Discovered dead code during review of #10791
diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart
index 39b9766..72c0369 100644
--- a/packages/flutter_tools/lib/src/devfs.dart
+++ b/packages/flutter_tools/lib/src/devfs.dart
@@ -16,8 +16,6 @@
import 'globals.dart';
import 'vmservice.dart';
-typedef void DevFSProgressReporter(int progress, int max);
-
class DevFSConfig {
/// Should DevFS assume that symlink targets are stable?
bool cacheSymlinks = false;
@@ -240,23 +238,18 @@
Map<Uri, DevFSContent> _outstanding;
Completer<Null> _completer;
HttpClient _client;
- int _done;
- int _max;
- Future<Null> write(Map<Uri, DevFSContent> entries,
- {DevFSProgressReporter progressReporter}) async {
+ Future<Null> write(Map<Uri, DevFSContent> entries) async {
_client = new HttpClient();
_client.maxConnectionsPerHost = kMaxInFlight;
_completer = new Completer<Null>();
_outstanding = new Map<Uri, DevFSContent>.from(entries);
- _done = 0;
- _max = _outstanding.length;
- _scheduleWrites(progressReporter);
+ _scheduleWrites();
await _completer.future;
_client.close();
}
- void _scheduleWrites(DevFSProgressReporter progressReporter) {
+ void _scheduleWrites() {
while (_inFlight < kMaxInFlight) {
if (_outstanding.isEmpty) {
// Finished.
@@ -264,15 +257,14 @@
}
final Uri deviceUri = _outstanding.keys.first;
final DevFSContent content = _outstanding.remove(deviceUri);
- _scheduleWrite(deviceUri, content, progressReporter);
+ _scheduleWrite(deviceUri, content);
_inFlight++;
}
}
Future<Null> _scheduleWrite(
Uri deviceUri,
- DevFSContent content,
- DevFSProgressReporter progressReporter, [
+ DevFSContent content, [
int retry = 0,
]) async {
try {
@@ -293,21 +285,17 @@
} catch (e) {
if (retry < kMaxRetries) {
printTrace('Retrying writing "$deviceUri" to DevFS due to error: $e');
- _scheduleWrite(deviceUri, content, progressReporter, retry + 1);
+ _scheduleWrite(deviceUri, content, retry + 1);
return;
} else {
printError('Error writing "$deviceUri" to DevFS: $e');
}
}
- if (progressReporter != null) {
- _done++;
- progressReporter(_done, _max);
- }
_inFlight--;
if ((_outstanding.isEmpty) && (_inFlight == 0)) {
_completer.complete(null);
} else {
- _scheduleWrites(progressReporter);
+ _scheduleWrites();
}
}
}
@@ -372,10 +360,11 @@
}
/// Update files on the device and return the number of bytes sync'd
- Future<int> update({ DevFSProgressReporter progressReporter,
- AssetBundle bundle,
- bool bundleDirty: false,
- Set<String> fileFilter}) async {
+ Future<int> update({
+ AssetBundle bundle,
+ bool bundleDirty: false,
+ Set<String> fileFilter,
+ }) async {
// Mark all entries as possibly deleted.
for (DevFSContent content in _entries.values) {
content._exists = false;
@@ -440,8 +429,7 @@
printTrace('Updating files');
if (_httpWriter != null) {
try {
- await _httpWriter.write(dirtyEntries,
- progressReporter: progressReporter);
+ await _httpWriter.write(dirtyEntries);
} on SocketException catch (socketException, stackTrace) {
printTrace("DevFS sync failed. Lost connection to device: $socketException");
throw new DevFSException('Lost connection to device.', socketException, stackTrace);
@@ -457,17 +445,6 @@
if (operation != null)
_pendingOperations.add(operation);
});
- if (progressReporter != null) {
- final int max = _pendingOperations.length;
- int complete = 0;
- _pendingOperations.forEach((Future<dynamic> f) => f.whenComplete(() {
- // TODO(ianh): If one of the pending operations fail, we'll keep
- // calling progressReporter long after update() has completed its
- // future, assuming that doesn't crash the app.
- complete += 1;
- progressReporter(complete, max);
- }));
- }
await Future.wait(_pendingOperations, eagerError: true);
_pendingOperations.clear();
}