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

Unified Diff: sky/sdk/example/stocks/lib/stock_data.dart

Issue 1229743002: Teach sky_shell.exe to run from a snapshot (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | sky/sdk/lib/mojo/net/fetch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/stocks/lib/stock_data.dart
diff --git a/sky/sdk/example/stocks/lib/stock_data.dart b/sky/sdk/example/stocks/lib/stock_data.dart
index 57d73ecd48b0443b9eec69477b7d5f687ba27af6..5526a9c9cd4f01d4c551f4025e3aa7c9f533c595 100644
--- a/sky/sdk/example/stocks/lib/stock_data.dart
+++ b/sky/sdk/example/stocks/lib/stock_data.dart
@@ -59,7 +59,7 @@ String _urlToFetch(int chunk) {
}
class StockDataFetcher {
- int _currentChunk = 0;
+ int _nextChunk = 0;
final StockDataCallback callback;
StockDataFetcher(this.callback) {
@@ -67,13 +67,17 @@ class StockDataFetcher {
}
void _fetchNextChunk() {
- fetchBody(_urlToFetch(_currentChunk++)).then((Response response) {
+ fetchBody(_urlToFetch(_nextChunk++)).then((Response response) {
String json = response.bodyAsString();
+ if (json == null) {
+ print("Failed to load stock data chunk ${_nextChunk - 1}");
+ return;
+ }
JsonDecoder decoder = new JsonDecoder();
callback(new StockData(decoder.convert(json)));
- if (_currentChunk < _kChunkCount)
+ if (_nextChunk < _kChunkCount)
_fetchNextChunk();
});
}
« no previous file with comments | « no previous file | sky/sdk/lib/mojo/net/fetch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698