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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 2697653004: If the state location is not accessible, use MemoryByteStore. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 1ea9e8d24cceb13a7a178d2b8d1aab557f9cf068..b021c5587e6ec904ef810738444e41d962207483 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -380,15 +380,7 @@ class AnalysisServer {
}
_analysisPerformanceLogger = new nd.PerformanceLog(sink);
}
- if (resourceProvider is PhysicalResourceProvider) {
- byteStore = new MemoryCachingByteStore(
- new EvictingFileByteStore(
- resourceProvider.getStateLocation('.analysis-driver').path,
- 1024 * 1024 * 1024 /*1 GiB*/),
- 64 * 1024 * 1024 /*64 MiB*/);
- } else {
- byteStore = new MemoryByteStore();
- }
+ byteStore = _createByteStore();
analysisDriverScheduler =
new nd.AnalysisDriverScheduler(_analysisPerformanceLogger);
analysisDriverScheduler.status.listen(sendStatusNotificationNew);
@@ -837,23 +829,6 @@ class AnalysisServer {
return null;
}
-// TODO(brianwilkerson) Add the following method after 'prioritySources' has
-// been added to InternalAnalysisContext.
-// /**
-// * Return a list containing the full names of all of the sources that are
-// * priority sources.
-// */
-// List<String> getPriorityFiles() {
-// List<String> priorityFiles = new List<String>();
-// folderMap.values.forEach((ContextDirectory directory) {
-// InternalAnalysisContext context = directory.context;
-// context.prioritySources.forEach((Source source) {
-// priorityFiles.add(source.fullName);
-// });
-// });
-// return priorityFiles;
-// }
-
/**
* Return a [Future] that completes with the resolved [CompilationUnit] for
* the Dart file with the given [path], or with `null` if the file is not a
@@ -879,6 +854,23 @@ class AnalysisServer {
});
}
+// TODO(brianwilkerson) Add the following method after 'prioritySources' has
+// been added to InternalAnalysisContext.
+// /**
+// * Return a list containing the full names of all of the sources that are
+// * priority sources.
+// */
+// List<String> getPriorityFiles() {
+// List<String> priorityFiles = new List<String>();
+// folderMap.values.forEach((ContextDirectory directory) {
+// InternalAnalysisContext context = directory.context;
+// context.prioritySources.forEach((Source source) {
+// priorityFiles.add(source.fullName);
+// });
+// });
+// return priorityFiles;
+// }
+
/**
* Handle a [request] that was read from the communication channel.
*/
@@ -1665,6 +1657,24 @@ class AnalysisServer {
}
/**
+ * If the state location can be accessed, return the file byte store,
+ * otherwise return the memory byte store.
+ */
+ ByteStore _createByteStore() {
+ const int M = 1024 * 1024 /*1 MiB*/;
+ const int G = 1024 * 1024 * 1024 /*1 GiB*/;
+ if (resourceProvider is PhysicalResourceProvider) {
+ Folder stateLocation =
+ resourceProvider.getStateLocation('.analysis-driver');
+ if (stateLocation != null) {
+ return new MemoryCachingByteStore(
+ new EvictingFileByteStore(stateLocation.path, G), 64 * M);
+ }
+ }
+ return new MemoryCachingByteStore(new NullByteStore(), 64 * M);
+ }
+
+ /**
* Return a set of all contexts whose associated folder is contained within,
* or equal to, one of the resources in the given list of [resources].
*/
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698