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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 continue; | 52 continue; |
53 } | 53 } |
54 assets[asset.name] = asset; | 54 assets[asset.name] = asset; |
55 } | 55 } |
56 return assets; | 56 return assets; |
57 } | 57 } |
58 | 58 |
59 String toString() => '$name ($mimeType)'; | 59 String toString() => '$name ($mimeType)'; |
60 } | 60 } |
61 | 61 |
| 62 HashMap<String, Asset> _assets; |
| 63 HashMap<String, Asset> get assets { |
| 64 if (_assets == null) { |
| 65 try { |
| 66 _assets = Asset.request(); |
| 67 } catch (e) { |
| 68 print('Could not load Observatory assets: $e'); |
| 69 } |
| 70 } |
| 71 return _assets; |
| 72 } |
62 | 73 |
63 class _ByteStream { | 74 class _ByteStream { |
64 final Uint8List bytes; | 75 final Uint8List bytes; |
65 final int offset; | 76 final int offset; |
66 int get length => bytes.length - offset; | 77 int get length => bytes.length - offset; |
67 int _cursor = 0; | 78 int _cursor = 0; |
68 | 79 |
69 _ByteStream(this.bytes, [this.offset = 0]); | 80 _ByteStream(this.bytes, [this.offset = 0]); |
70 | 81 |
71 void reset() { | 82 void reset() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int type = _readType(_bs); | 207 int type = _readType(_bs); |
197 _bs.seekToNextBlock(tarHeaderSize); | 208 _bs.seekToNextBlock(tarHeaderSize); |
198 if (type != tarHeaderFileType) { | 209 if (type != tarHeaderFileType) { |
199 _skipContents(_bs, size); | 210 _skipContents(_bs, size); |
200 return null; | 211 return null; |
201 } | 212 } |
202 Uint8List bytes = _readContents(_bs, size); | 213 Uint8List bytes = _readContents(_bs, size); |
203 return new Asset(filename, bytes); | 214 return new Asset(filename, bytes); |
204 } | 215 } |
205 } | 216 } |
OLD | NEW |