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

Side by Side Diff: sky/sdk/lib/mojo/net/image_cache.dart

Issue 1223843014: Update material design icons (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: alphabetize 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 unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/download_material_design_icons ('k') | sky/sdk/lib/widgets/menu_item.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:sky' as sky; 7 import 'dart:sky' as sky;
8 8
9 import 'package:mojom/mojo/url_response.mojom.dart'; 9 import 'package:mojom/mojo/url_response.mojom.dart';
10 10
11 import 'fetch.dart'; 11 import 'fetch.dart';
12 12
13 final HashMap<String, Future<sky.Image>> _cache = 13 final HashMap<String, Future<sky.Image>> _cache =
14 new HashMap<String, Future<sky.Image>>(); 14 new HashMap<String, Future<sky.Image>>();
15 15
16 Future<sky.Image> load(String url) { 16 Future<sky.Image> load(String url) {
17 return _cache.putIfAbsent(url, () { 17 return _cache.putIfAbsent(url, () {
18 Completer<sky.Image> completer = new Completer<sky.Image>(); 18 Completer<sky.Image> completer = new Completer<sky.Image>();
19 fetchUrl(url).then((UrlResponse response) { 19 fetchUrl(url).then((UrlResponse response) {
20 if (response.statusCode >= 400) { 20 if (response.statusCode >= 400) {
21 print("Failed to load image ${url}");
21 completer.complete(null); 22 completer.complete(null);
22 } else { 23 } else {
23 new sky.ImageDecoder(response.body.handle.h, completer.complete); 24 new sky.ImageDecoder(response.body.handle.h, completer.complete);
24 } 25 }
25 }); 26 });
26 return completer.future; 27 return completer.future;
27 }); 28 });
28 } 29 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/download_material_design_icons ('k') | sky/sdk/lib/widgets/menu_item.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698