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

Unified Diff: sky/sdk/lib/framework/net/image_cache.dart

Issue 1179923004: Fix data loading in the stocks app (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « sky/sdk/lib/framework/net/fetch.dart ('k') | sky/sdk/lib/framework/shell.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/net/image_cache.dart
diff --git a/sky/sdk/lib/framework/net/image_cache.dart b/sky/sdk/lib/framework/net/image_cache.dart
deleted file mode 100644
index 1ec669866ae476be20818a05b2526fecdf54a9ec..0000000000000000000000000000000000000000
--- a/sky/sdk/lib/framework/net/image_cache.dart
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:sky';
-import 'dart:collection';
-import 'fetch.dart';
-import 'package:mojom/mojo/url_response.mojom.dart';
-
-final HashMap<String, List<ImageDecoderCallback>> _pendingRequests =
- new HashMap<String, List<ImageDecoderCallback>>();
-
-final HashMap<String, Image> _completedRequests =
- new HashMap<String, Image>();
-
-void _loadComplete(url, image) {
- _completedRequests[url] = image;
- _pendingRequests[url].forEach((c) => c(image));
- _pendingRequests.remove(url);
-}
-
-void load(String url, ImageDecoderCallback callback) {
- Image result = _completedRequests[url];
- if (result != null) {
- callback(_completedRequests[url]);
- return;
- }
-
- bool newRequest = false;
- _pendingRequests.putIfAbsent(url, () {
- newRequest = true;
- return new List<ImageDecoderCallback>();
- }).add(callback);
- if (newRequest) {
- fetchUrl(url).then((UrlResponse response) {
- if (response.statusCode >= 400) {
- _loadComplete(url, null);
- return;
- }
- new ImageDecoder(response.body.handle.h,
- (image) => _loadComplete(url, image));
- });
- }
-}
« no previous file with comments | « sky/sdk/lib/framework/net/fetch.dart ('k') | sky/sdk/lib/framework/shell.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698