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

Side by Side Diff: sdk/lib/vmservice/asset.dart

Issue 2946773002: Remove vmservice_patch.dart. (Closed)
Patch Set: Created 3 years, 6 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 | « runtime/lib/vmservice_sources.gypi ('k') | sdk/lib/vmservice/message.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 return 'image/jpeg'; 30 return 'image/jpeg';
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 static HashMap<String, Asset> request() {
41 external static HashMap<String, Asset> request(); 41 Uint8List tarBytes = _requestAssets();
42 if (tarBytes == null) {
43 return null;
44 }
45 List assetList = _decodeAssets(tarBytes);
46 HashMap<String, Asset> assets = new HashMap<String, Asset>();
47 for (int i = 0; i < assetList.length; i += 2) {
48 var a = new Asset(assetList[i], assetList[i + 1]);
49 assets[a.name] = a;
50 }
51 return assets;
52 }
42 53
43 String toString() => '$name ($mimeType)'; 54 String toString() => '$name ($mimeType)';
44 } 55 }
45 56
57 List _decodeAssets(Uint8List data) native "VMService_DecodeAssets";
58
46 HashMap<String, Asset> _assets; 59 HashMap<String, Asset> _assets;
47 HashMap<String, Asset> get assets { 60 HashMap<String, Asset> get assets {
48 if (_assets == null) { 61 if (_assets == null) {
49 try { 62 try {
50 _assets = Asset.request(); 63 _assets = Asset.request();
51 } catch (e) { 64 } catch (e) {
52 print('Could not load Observatory assets: $e'); 65 print('Could not load Observatory assets: $e');
53 } 66 }
54 } 67 }
55 return _assets; 68 return _assets;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 int type = _readType(_bs); 201 int type = _readType(_bs);
189 _bs.seekToNextBlock(tarHeaderSize); 202 _bs.seekToNextBlock(tarHeaderSize);
190 if (type != tarHeaderFileType) { 203 if (type != tarHeaderFileType) {
191 _skipContents(_bs, size); 204 _skipContents(_bs, size);
192 return null; 205 return null;
193 } 206 }
194 Uint8List bytes = _readContents(_bs, size); 207 Uint8List bytes = _readContents(_bs, size);
195 return new Asset(filename, bytes); 208 return new Asset(filename, bytes);
196 } 209 }
197 } 210 }
OLDNEW
« no previous file with comments | « runtime/lib/vmservice_sources.gypi ('k') | sdk/lib/vmservice/message.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698