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

Side by Side Diff: runtime/bin/vmservice/resources.dart

Issue 1151743002: Decrease Dart binary size by 1.7MB (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/bin/bin.gypi ('k') | runtime/bin/vmservice_impl.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 vmservice_io; 5 part of vmservice_io;
6 6
7 String detectMimeType(String name) { 7 String detectMimeType(String name) {
8 var extensionStart = name.lastIndexOf('.'); 8 var extensionStart = name.lastIndexOf('.');
9 var extension = name.substring(extensionStart+1); 9 var extension = name.substring(extensionStart+1);
10 switch (extension) { 10 switch (extension) {
(...skipping 22 matching lines...) Expand all
33 33
34 34
35 class Resource { 35 class Resource {
36 final String name; 36 final String name;
37 final String mimeType; 37 final String mimeType;
38 final List<int> data; 38 final List<int> data;
39 Resource(this.name, this.mimeType, this.data); 39 Resource(this.name, this.mimeType, this.data);
40 static final Map<String, Resource> resources = new Map<String, Resource>(); 40 static final Map<String, Resource> resources = new Map<String, Resource>();
41 } 41 }
42 42
43 ZLibCodec _zlib;
43 44
44 void _addResource(String name, List<int> data) { 45 void _addResource(String name, List<int> data, bool compressed) {
45 var mimeType = detectMimeType(name); 46 var mimeType = detectMimeType(name);
47 if (compressed) {
48 if (_zlib == null) {
49 _zlib = new ZLibCodec();
50 }
51 try {
52 data = _zlib.decode(data);
53 } catch(e) {
54 print('error decompressing service isolate resource: $name');
55 return;
56 }
57 }
46 Resource resource = new Resource(name, mimeType, data); 58 Resource resource = new Resource(name, mimeType, data);
47 Resource.resources[name] = resource; 59 Resource.resources[name] = resource;
48 } 60 }
49 61
50 void _triggerResourceLoad() native "VMServiceIO_TriggerResourceLoad"; 62 void _triggerResourceLoad() native "VMServiceIO_TriggerResourceLoad";
OLDNEW
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698