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

Unified Diff: lib/src/dependency_graph.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/codegen/js_codegen.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/dependency_graph.dart
diff --git a/lib/src/dependency_graph.dart b/lib/src/dependency_graph.dart
index 4b2c4c189f075e9d8f13c563305fda0e00d28143..d7c61199a04f9b5b616394ffa82cea05b3a4135b 100644
--- a/lib/src/dependency_graph.dart
+++ b/lib/src/dependency_graph.dart
@@ -27,6 +27,7 @@ import 'package:path/path.dart' as path;
import 'package:source_span/source_span.dart' show SourceSpan;
import 'info.dart';
+import 'options.dart';
import 'report.dart';
import 'utils.dart';
@@ -41,8 +42,9 @@ class SourceGraph {
/// Analyzer used to resolve source files.
final AnalysisContext _context;
final CheckerReporter _reporter;
+ final CompilerOptions _options;
- SourceGraph(this._context, this._reporter);
+ SourceGraph(this._context, this._reporter, this._options);
/// Node associated with a resolved [uri].
SourceNode nodeFromUri(Uri uri) {
@@ -75,6 +77,10 @@ abstract class SourceNode {
/// Last stamp read from `source.modificationStamp`.
int _lastStamp = 0;
+ /// A hash used to help browsers cache the output that would be produced from
+ /// building this node.
+ String cachingHash;
+
/// Whether we need to rebuild this source file.
bool needsRebuild = false;
@@ -128,11 +134,13 @@ class HtmlSourceNode extends SourceNode {
HtmlSourceNode(uri, source, graph) : super(uri, source) {
var prefix = 'package:dev_compiler/runtime';
- runtimeDeps
- ..add(graph.nodeFromUri(Uri.parse('$prefix/dart_runtime.js')))
- ..add(graph.nodeFromUri(Uri.parse('$prefix/harmony_feature_check.js')))
- ..add(graph.nodeFromUri(Uri.parse('$prefix/messages_widget.js')))
- ..add(graph.nodeFromUri(Uri.parse('$prefix/messages.css')));
+ var files = ['harmony_feature_check.js', 'dart_runtime.js'];
+ if (graph._options.serverMode) {
+ files.addAll(const ['messages_widget.js', 'messages.css']);
+ }
+ files.forEach((file) {
+ runtimeDeps.add(graph.nodeFromUri(Uri.parse('$prefix/$file')));
+ });
}
void update(SourceGraph graph) {
@@ -340,20 +348,22 @@ rebuild(SourceNode start, SourceGraph graph, bool build(SourceNode node)) {
// of those transitive cases, but is not sufficient. See
// https://github.com/dart-lang/dev_compiler/issues/76
var apiChangeDetected = new HashSet<SourceNode>();
- bool structureHasChanged = false;
+ bool htmlNeedsRebuild = false;
bool shouldBuildNode(SourceNode n) {
if (n.needsRebuild) return true;
- if (n is HtmlSourceNode) return structureHasChanged;
+ if (n is HtmlSourceNode) return htmlNeedsRebuild;
if (n is ResourceSourceNode) return false;
return (n as DartSourceNode).imports
.any((i) => apiChangeDetected.contains(i));
}
visitInPostOrder(start, (n) {
- if (n.structureChanged) structureHasChanged = true;
+ if (n.structureChanged) htmlNeedsRebuild = true;
if (shouldBuildNode(n)) {
+ var oldHash = n.cachingHash;
if (build(n)) apiChangeDetected.add(n);
+ if (oldHash != n.cachingHash) htmlNeedsRebuild = true;
} else if (n is DartSourceNode &&
n.exports.any((e) => apiChangeDetected.contains(e))) {
apiChangeDetected.add(n);
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698