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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart

Issue 2504193004: Send CacheCleanUpRequest instead of a List. (Closed)
Patch Set: Make the request class public to work around the problem. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698