Chromium Code Reviews| 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..2007497e4927aebce671e677fd8e0bd50b907085 100644 |
| --- a/dart/site/try/src/cache.dart |
| +++ b/dart/site/try/src/cache.dart |
| @@ -20,6 +20,7 @@ import 'ui.dart' show |
| /// Called when the window has finished loading. |
| void onLoad(Event event) { |
| + if (!ApplicationCache.supported) return; |
| window.applicationCache.onUpdateReady.listen((_) => updateCacheStatus()); |
|
kasperl
2014/05/06 04:42:22
Consider having a local helper function for the (_
ahe
2014/05/06 08:10:16
I've changed updateCacheStatus to take an argument
|
| window.applicationCache.onCached.listen((_) => updateCacheStatus()); |
| window.applicationCache.onChecking.listen((_) => updateCacheStatus()); |
| @@ -30,11 +31,19 @@ void onLoad(Event event) { |
| window.applicationCache.onProgress.listen(onCacheProgress); |
| } |
| -onCacheProgress(ProgressEvent event) { |
| - if (!event.lengthComputable) { |
| - updateCacheStatus(); |
| - return; |
| +onCacheProgress(Event event) { |
|
kasperl
2014/05/06 04:42:22
I'd add a void here -- if nothing else then for co
ahe
2014/05/06 08:10:16
Done.
|
| + 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(); |
| +} |
| + |
| +void updateCacheStatusFromEvent(ProgressEvent event) { |
| cacheStatusElement.nodes.clear(); |
| cacheStatusElement.appendText('Downloading SDK '); |
| var progress = '${event.loaded} of ${event.total}'; |