| OLD | NEW |
| 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:sky'; | 5 import 'dart:sky'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 |
| 8 import 'package:mojom/mojo/url_response.mojom.dart'; |
| 9 |
| 7 import 'fetch.dart'; | 10 import 'fetch.dart'; |
| 8 import 'package:mojom/mojo/url_response.mojom.dart'; | |
| 9 | 11 |
| 10 final HashMap<String, List<ImageDecoderCallback>> _pendingRequests = | 12 final HashMap<String, List<ImageDecoderCallback>> _pendingRequests = |
| 11 new HashMap<String, List<ImageDecoderCallback>>(); | 13 new HashMap<String, List<ImageDecoderCallback>>(); |
| 12 | 14 |
| 13 final HashMap<String, Image> _completedRequests = | 15 final HashMap<String, Image> _completedRequests = |
| 14 new HashMap<String, Image>(); | 16 new HashMap<String, Image>(); |
| 15 | 17 |
| 16 void _loadComplete(url, image) { | 18 void _loadComplete(url, image) { |
| 17 _completedRequests[url] = image; | 19 _completedRequests[url] = image; |
| 18 _pendingRequests[url].forEach((c) => c(image)); | 20 _pendingRequests[url].forEach((c) => c(image)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 fetchUrl(url).then((UrlResponse response) { | 37 fetchUrl(url).then((UrlResponse response) { |
| 36 if (response.statusCode >= 400) { | 38 if (response.statusCode >= 400) { |
| 37 _loadComplete(url, null); | 39 _loadComplete(url, null); |
| 38 return; | 40 return; |
| 39 } | 41 } |
| 40 new ImageDecoder(response.body.handle.h, | 42 new ImageDecoder(response.body.handle.h, |
| 41 (image) => _loadComplete(url, image)); | 43 (image) => _loadComplete(url, image)); |
| 42 }); | 44 }); |
| 43 } | 45 } |
| 44 } | 46 } |
| OLD | NEW |