Index: pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
index 46f464893673534eab60990e81807bf568681fed..a050ad1c4dcdf35937905ff3c56c65d0b3201cc5 100644 |
--- a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
+++ b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart |
@@ -10,6 +10,17 @@ import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
import 'package:path/path.dart'; |
/** |
+ * The request that is sent from the main isolate to the clean-up isolate. |
+ */ |
+class CacheCleanUpRequest { |
+ final String cachePath; |
+ final int maxSizeBytes; |
+ final SendPort replyTo; |
+ |
+ CacheCleanUpRequest(this.cachePath, this.maxSizeBytes, this.replyTo); |
+} |
+ |
+/** |
* [ByteStore] that stores values as files. |
*/ |
class FileByteStore implements ByteStore { |
@@ -74,7 +85,8 @@ class FileByteStore implements ByteStore { |
_evictionIsolateIsRunning = true; |
try { |
ReceivePort response = new ReceivePort(); |
- _cleanUpSendPort.send([_cachePath, _maxSizeBytes, response.sendPort]); |
+ _cleanUpSendPort.send(new CacheCleanUpRequest( |
+ _cachePath, _maxSizeBytes, response.sendPort)); |
await response.first; |
} finally { |
_evictionIsolateIsRunning = false; |
@@ -90,18 +102,11 @@ class FileByteStore implements ByteStore { |
static void _cacheCleanUpFunction(SendPort initialReplyTo) { |
ReceivePort port = new ReceivePort(); |
initialReplyTo.send(port.sendPort); |
- port.listen((args) async { |
- if (args is List && |
- args.length == 3 && |
- args[0] is String && |
- args[1] is int && |
- args[2] is SendPort) { |
- String cachePath = args[0] as String; |
- int maxSizeBytes = args[1] as int; |
- await _cleanUpFolder(cachePath, maxSizeBytes); |
- // Let that client know that we're done. |
- SendPort replyTo = args[2] as SendPort; |
- replyTo.send(true); |
+ port.listen((request) async { |
+ if (request is CacheCleanUpRequest) { |
+ await _cleanUpFolder(request.cachePath, request.maxSizeBytes); |
+ // Let the client know that we're done. |
+ request.replyTo.send(true); |
} |
}); |
} |