| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
| 10 import 'package:path/path.dart'; | 10 import 'package:path/path.dart'; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * [ByteStore] that stores values as files. | 13 * [ByteStore] that stores values as files. |
| 14 */ | 14 */ |
| 15 class FileByteStore implements ByteStore { | 15 class FileByteStore implements ByteStore { |
| 16 static bool _cleanUpSendPortShouldBePrepared = true; | 16 static bool _cleanUpSendPortShouldBePrepared = true; |
| 17 static SendPort _cleanUpSendPort; | 17 static SendPort _cleanUpSendPort; |
| 18 | 18 |
| 19 final String _cachePath; | 19 final String _cachePath; |
| 20 final String _tempName = 'temp_${pid}'; | 20 final String _tempName = 'temp_$pid'; |
| 21 final int _maxSizeBytes; | 21 final int _maxSizeBytes; |
| 22 | 22 |
| 23 int _bytesWrittenSinceCleanup = 0; | 23 int _bytesWrittenSinceCleanup = 0; |
| 24 bool _evictionIsolateIsRunning = false; | 24 bool _evictionIsolateIsRunning = false; |
| 25 | 25 |
| 26 FileByteStore(this._cachePath, this._maxSizeBytes) { | 26 FileByteStore(this._cachePath, this._maxSizeBytes) { |
| 27 _requestCacheCleanUp(); | 27 _requestCacheCleanUp(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 @override | 30 @override |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (currentSizeBytes < maxSizeBytes) { | 132 if (currentSizeBytes < maxSizeBytes) { |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 try { | 135 try { |
| 136 await file.delete(); | 136 await file.delete(); |
| 137 } catch (_) {} | 137 } catch (_) {} |
| 138 currentSizeBytes -= fileStatMap[file].size; | 138 currentSizeBytes -= fileStatMap[file].size; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| OLD | NEW |