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

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

Issue 1232313002: Use package:sky imports consistently (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix BUILD.gn 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/mojo/net/fetch.dart ('k') | sky/sdk/lib/mojo/shell.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 import 'package:sky/mojo/net/fetch.dart';
11 import 'fetch.dart';
12 11
13 final HashMap<String, Future<sky.Image>> _cache = 12 final HashMap<String, Future<sky.Image>> _cache =
14 new HashMap<String, Future<sky.Image>>(); 13 new HashMap<String, Future<sky.Image>>();
15 14
16 Future<sky.Image> load(String url) { 15 Future<sky.Image> load(String url) {
17 return _cache.putIfAbsent(url, () { 16 return _cache.putIfAbsent(url, () {
18 Completer<sky.Image> completer = new Completer<sky.Image>(); 17 Completer<sky.Image> completer = new Completer<sky.Image>();
19 fetchUrl(url).then((UrlResponse response) { 18 fetchUrl(url).then((UrlResponse response) {
20 if (response.statusCode >= 400) { 19 if (response.statusCode >= 400) {
21 print("Failed to load image ${url}"); 20 print("Failed to load image ${url}");
22 completer.complete(null); 21 completer.complete(null);
23 } else { 22 } else {
24 new sky.ImageDecoder(response.body.handle.h, completer.complete); 23 new sky.ImageDecoder(response.body.handle.h, completer.complete);
25 } 24 }
26 }); 25 });
27 return completer.future; 26 return completer.future;
28 }); 27 });
29 } 28 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/mojo/net/fetch.dart ('k') | sky/sdk/lib/mojo/shell.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698