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

Unified Diff: lib/src/utils.dart

Issue 993213003: Support browser caching using hashes in serverMode (fixes #93, fixes #92) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 | « lib/src/dependency_graph.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 211a726a6efa5815237b929223b185bb198ab3cc..a30473d5290f12642b1e68ccc6c3b0ba57396915 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -22,6 +22,7 @@ import 'package:analyzer/src/generated/engine.dart'
import 'package:analyzer/src/generated/source.dart' show Source;
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/analyzer.dart' show parseDirectives;
+import 'package:crypto/crypto.dart' show CryptoUtils, MD5;
import 'package:source_span/source_span.dart';
bool isDartPrivateLibrary(LibraryElement library) {
@@ -183,6 +184,8 @@ String colorOf(String levelName) {
const String _RED_COLOR = '\u001b[31m';
const String _MAGENTA_COLOR = '\u001b[35m';
const String _CYAN_COLOR = '\u001b[36m';
+const String GREEN_COLOR = '\u001b[32m';
+const String NO_COLOR = '\u001b[0m';
class OutWriter {
final String _path;
@@ -256,3 +259,11 @@ SourceSpan spanForNode(CompilationUnit unit, Source source, AstNode node) {
return new SourceSpan(locationForOffset(unit, uri, begin),
locationForOffset(unit, uri, end), '$text');
}
+
+/// Computes a hash for the given contents.
+String computeHash(String contents) {
+ if (contents == null || contents == '') return null;
+ return CryptoUtils.bytesToHex((new MD5()..add(contents.codeUnits)).close());
+}
+
+String resourceOutputPath(Uri resourceUri) => resourceUri.path;
« no previous file with comments | « lib/src/dependency_graph.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698