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

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

Issue 1411853003: Service isolate requests Observatory assets from embedder (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/run_vm_tests.cc ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of vmservice_io;
6
7 String detectMimeType(String name) {
8 var extensionStart = name.lastIndexOf('.');
9 var extension = name.substring(extensionStart+1);
10 switch (extension) {
11 case 'html':
12 return 'text/html; charset=UTF-8';
13 case 'dart':
14 return 'application/dart; charset=UTF-8';
15 case 'js':
16 return 'application/javascript; charset=UTF-8';
17 case 'css':
18 return 'text/css; charset=UTF-8';
19 case 'gif':
20 return 'image/gif';
21 case 'png':
22 return 'image/png';
23 case 'jpg':
24 return 'image/jpeg';
25 case 'jpeg':
26 return 'image/jpeg';
27 case 'svg':
28 return 'image/svg+xml';
29 default:
30 return 'text/plain';
31 }
32 }
33
34
35 class Resource {
36 final String name;
37 final String mimeType;
38 final List<int> data;
39 Resource(this.name, this.mimeType, this.data);
40 static final Map<String, Resource> resources = new Map<String, Resource>();
41 }
42
43 ZLibCodec _zlib;
44
45 void _addResource(String name, List<int> data, bool compressed) {
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 }
58 Resource resource = new Resource(name, mimeType, data);
59 Resource.resources[name] = resource;
60 }
61
62 void _triggerResourceLoad() native "VMServiceIO_TriggerResourceLoad";
OLDNEW
« no previous file with comments | « runtime/bin/run_vm_tests.cc ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698