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

Unified Diff: dart/site/try/src/cache.dart

Issue 266293002: Make Try Dart tests run on Firefox. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r35787 Created 6 years, 7 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 | dart/site/try/src/editor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/cache.dart
diff --git a/dart/site/try/src/cache.dart b/dart/site/try/src/cache.dart
index fd4cce08a90434a70bdc2cd7c876112cd22a03d1..a61ec0a79a5bfc2992daecc42a08f7203e963317 100644
--- a/dart/site/try/src/cache.dart
+++ b/dart/site/try/src/cache.dart
@@ -20,21 +20,30 @@ import 'ui.dart' show
/// Called when the window has finished loading.
void onLoad(Event event) {
- window.applicationCache.onUpdateReady.listen((_) => updateCacheStatus());
- window.applicationCache.onCached.listen((_) => updateCacheStatus());
- window.applicationCache.onChecking.listen((_) => updateCacheStatus());
- window.applicationCache.onDownloading.listen((_) => updateCacheStatus());
- window.applicationCache.onError.listen((_) => updateCacheStatus());
- window.applicationCache.onNoUpdate.listen((_) => updateCacheStatus());
- window.applicationCache.onObsolete.listen((_) => updateCacheStatus());
+ if (!ApplicationCache.supported) return;
+ window.applicationCache.onUpdateReady.listen(updateCacheStatus);
+ window.applicationCache.onCached.listen(updateCacheStatus);
+ window.applicationCache.onChecking.listen(updateCacheStatus);
+ window.applicationCache.onDownloading.listen(updateCacheStatus);
+ window.applicationCache.onError.listen(updateCacheStatus);
+ window.applicationCache.onNoUpdate.listen(updateCacheStatus);
+ window.applicationCache.onObsolete.listen(updateCacheStatus);
window.applicationCache.onProgress.listen(onCacheProgress);
}
-onCacheProgress(ProgressEvent event) {
- if (!event.lengthComputable) {
- updateCacheStatus();
- return;
+void onCacheProgress(Event event) {
+ if (event is ProgressEvent) {
+ // Firefox doesn't fire a ProgressEvent on cache progress. Just a plain
+ // Event with type == "progress".
+ if (event.lengthComputable) {
+ updateCacheStatusFromEvent(event);
+ return;
+ }
}
+ updateCacheStatus(null);
+}
+
+void updateCacheStatusFromEvent(ProgressEvent event) {
cacheStatusElement.nodes.clear();
cacheStatusElement.appendText('Downloading SDK ');
var progress = '${event.loaded} of ${event.total}';
@@ -62,7 +71,7 @@ String cacheStatus() {
return '?';
}
-void updateCacheStatus() {
+void updateCacheStatus(_) {
cacheStatusElement.nodes.clear();
int status = window.applicationCache.status;
if (status == ApplicationCache.UPDATEREADY) {
« no previous file with comments | « no previous file | dart/site/try/src/editor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698