| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart._vmservice; | 5 part of dart._vmservice; |
| 6 | 6 |
| 7 class Asset { | 7 class Asset { |
| 8 final String name; | 8 final String name; |
| 9 final Uint8List data; | 9 final Uint8List data; |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 case 'jpeg': | 31 case 'jpeg': |
| 32 return 'image/jpeg'; | 32 return 'image/jpeg'; |
| 33 case 'svg': | 33 case 'svg': |
| 34 return 'image/svg+xml'; | 34 return 'image/svg+xml'; |
| 35 default: | 35 default: |
| 36 return 'text/plain'; | 36 return 'text/plain'; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 /// Call to request assets from the embedder. | 40 /// Call to request assets from the embedder. |
| 41 static Map<String, Asset> request() { | 41 static HashMap<String, Asset> request() { |
| 42 Map<String, Asset> assets = new Map<String, Asset>(); | 42 HashMap<String, Asset> assets = new HashMap<String, Asset>(); |
| 43 Uint8List tarBytes = _requestAssets(); | 43 Uint8List tarBytes = _requestAssets(); |
| 44 if (tarBytes == null) { | 44 if (tarBytes == null) { |
| 45 return assets; | 45 return assets; |
| 46 } | 46 } |
| 47 _TarArchive archive = new _TarArchive(tarBytes); | 47 _TarArchive archive = new _TarArchive(tarBytes); |
| 48 while (archive.hasNext()) { | 48 while (archive.hasNext()) { |
| 49 Asset asset = archive.next(); | 49 Asset asset = archive.next(); |
| 50 if (asset == null) { | 50 if (asset == null) { |
| 51 // Skip over special files. | 51 // Skip over special files. |
| 52 continue; | 52 continue; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 int type = _readType(_bs); | 196 int type = _readType(_bs); |
| 197 _bs.seekToNextBlock(tarHeaderSize); | 197 _bs.seekToNextBlock(tarHeaderSize); |
| 198 if (type != tarHeaderFileType) { | 198 if (type != tarHeaderFileType) { |
| 199 _skipContents(_bs, size); | 199 _skipContents(_bs, size); |
| 200 return null; | 200 return null; |
| 201 } | 201 } |
| 202 Uint8List bytes = _readContents(_bs, size); | 202 Uint8List bytes = _readContents(_bs, size); |
| 203 return new Asset(filename, bytes); | 203 return new Asset(filename, bytes); |
| 204 } | 204 } |
| 205 } | 205 } |
| OLD | NEW |