| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 import 'dart:sky.internals' as internals; | 7 import 'dart:sky.internals' as internals; |
| 8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
| 9 | 9 |
| 10 import 'package:mojo/core.dart' as core; | 10 import 'package:mojo/core.dart' as core; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 class MojoAssetBundle extends AssetBundle { | 47 class MojoAssetBundle extends AssetBundle { |
| 48 MojoAssetBundle(AssetBundleProxy this._bundle); | 48 MojoAssetBundle(AssetBundleProxy this._bundle); |
| 49 | 49 |
| 50 factory MojoAssetBundle.fromNetwork(String relativeUrl) { | 50 factory MojoAssetBundle.fromNetwork(String relativeUrl) { |
| 51 AssetBundleProxy bundle = new AssetBundleProxy.unbound(); | 51 AssetBundleProxy bundle = new AssetBundleProxy.unbound(); |
| 52 _fetchAndUnpackBundle(relativeUrl, bundle); | 52 _fetchAndUnpackBundle(relativeUrl, bundle); |
| 53 return new MojoAssetBundle(bundle); | 53 return new MojoAssetBundle(bundle); |
| 54 } | 54 } |
| 55 | 55 |
| 56 final AssetBundleProxy _bundle; | 56 AssetBundleProxy _bundle; |
| 57 Map<String, Future<sky.Image>> _imageCache = new Map<String, Future<sky.Image>
>(); | 57 Map<String, Future<sky.Image>> _imageCache = new Map<String, Future<sky.Image>
>(); |
| 58 Map<String, Future<String>> _stringCache = new Map<String, Future<String>>(); | 58 Map<String, Future<String>> _stringCache = new Map<String, Future<String>>(); |
| 59 | 59 |
| 60 void close() { | 60 void close() { |
| 61 _bundle.close(); | 61 _bundle.close(); |
| 62 _bundle = null; | 62 _bundle = null; |
| 63 _imageCache = null; | 63 _imageCache = null; |
| 64 } | 64 } |
| 65 | 65 |
| 66 Future<sky.Image> loadImage(String key) { | 66 Future<sky.Image> loadImage(String key) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 88 try { | 88 try { |
| 89 AssetBundleProxy bundle = new AssetBundleProxy.fromHandle( | 89 AssetBundleProxy bundle = new AssetBundleProxy.fromHandle( |
| 90 new core.MojoHandle(internals.takeRootBundleHandle())); | 90 new core.MojoHandle(internals.takeRootBundleHandle())); |
| 91 return new MojoAssetBundle(bundle); | 91 return new MojoAssetBundle(bundle); |
| 92 } catch (e) { | 92 } catch (e) { |
| 93 return null; | 93 return null; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 final AssetBundle rootBundle = _initRootBundle(); | 97 final AssetBundle rootBundle = _initRootBundle(); |
| OLD | NEW |