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

Side by Side Diff: sky/sdk/lib/mojo/asset_bundle.dart

Issue 1221023002: Fix a bug found by the analyzer (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « no previous file | no next file » | 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:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import 'package:mojo/core.dart' as core; 8 import 'package:mojo/core.dart' as core;
9 import 'package:mojom/mojo/asset_bundle/asset_bundle.mojom.dart'; 9 import 'package:mojom/mojo/asset_bundle/asset_bundle.mojom.dart';
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 void close() { } 25 void close() { }
26 26
27 Future<sky.Image> loadImage(String name) { 27 Future<sky.Image> loadImage(String name) {
28 Uri url = _baseUrl.resolve(name); 28 Uri url = _baseUrl.resolve(name);
29 return image_cache.load(url.toString()); 29 return image_cache.load(url.toString());
30 } 30 }
31 } 31 }
32 32
33 Future _fetchAndUnpackBundle(String relativeUrl, AssetBundleProxy bundle) async { 33 Future _fetchAndUnpackBundle(String relativeUrl, AssetBundleProxy bundle) async {
34 core.MojoDataPipeConsumer bundleData = (await fetchUrl(url)).body; 34 core.MojoDataPipeConsumer bundleData = (await fetchUrl(relativeUrl)).body;
35 AssetUnpackerProxy unpacker = new AssetUnpackerProxy.unbound(); 35 AssetUnpackerProxy unpacker = new AssetUnpackerProxy.unbound();
36 shell.requestService("mojo:asset_bundle", unpacker); 36 shell.requestService("mojo:asset_bundle", unpacker);
37 unpacker.ptr.unpackZipStream(bundleData, bundle); 37 unpacker.ptr.unpackZipStream(bundleData, bundle);
38 unpacker.close(); 38 unpacker.close();
39 } 39 }
40 40
41 class MojoAssetBundle extends AssetBundle { 41 class MojoAssetBundle extends AssetBundle {
42 MojoAssetBundle(AssetBundleProxy this._bundle); 42 MojoAssetBundle(AssetBundleProxy this._bundle);
43 43
44 factory MojoAssetBundle.fromNetwork(String relativeUrl) { 44 factory MojoAssetBundle.fromNetwork(String relativeUrl) {
(...skipping 14 matching lines...) Expand all
59 Future<sky.Image> loadImage(String name) { 59 Future<sky.Image> loadImage(String name) {
60 return _imageCache.putIfAbsent(name, () { 60 return _imageCache.putIfAbsent(name, () {
61 Completer<sky.Image> completer = new Completer<sky.Image>(); 61 Completer<sky.Image> completer = new Completer<sky.Image>();
62 _bundle.ptr.getAsStream(name).then((response) { 62 _bundle.ptr.getAsStream(name).then((response) {
63 new sky.ImageDecoder(response.assetData.handle.h, completer.complete); 63 new sky.ImageDecoder(response.assetData.handle.h, completer.complete);
64 }); 64 });
65 return completer.future; 65 return completer.future;
66 }); 66 });
67 } 67 }
68 } 68 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698