OLD | NEW |
---|---|
(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; | |
6 | |
7 String detectMimeType(String name) { | |
8 String extension = new Path(name).extension; | |
siva
2013/07/19 17:41:16
var extension:
Style guide link:
http://www.dart
Cutch
2013/07/19 18:15:02
Done.
| |
9 switch (extension) { | |
10 case 'html': | |
11 return 'text/html; charset=UTF-8'; | |
12 case 'dart': | |
13 return 'application/dart; charset=UTF-8'; | |
14 case 'js': | |
15 return 'application/javascript; charset=UTF-8'; | |
16 case 'css': | |
17 return 'text/css; charset=UTF-8'; | |
18 case 'gif': | |
19 return 'image/gif'; | |
20 case 'png': | |
21 return 'image/png'; | |
22 case 'jpg': | |
23 return 'image/jpeg'; | |
24 case 'jpeg': | |
25 return 'image/jpeg'; | |
26 default: | |
27 return 'text/plain'; | |
28 } | |
29 } | |
30 | |
31 | |
32 class Resource { | |
33 final String name; | |
34 final String mimeType; | |
35 final List<int> data; | |
36 Resource(this.name, this.mimeType, this.isText, this.data); | |
siva
2013/07/19 17:41:16
I don't see a field isText in the class, where doe
Cutch
2013/07/19 18:15:02
Done.
| |
37 static final Map<String, Resource> resources = new Map<String, Resource>(); | |
38 } | |
39 | |
40 | |
41 void _addResource(String name, List<int> data) { | |
42 String mimeType = detectMimeType(name); | |
43 Resource resource = new Resource(name, detectMimeType(name), data); | |
siva
2013/07/19 17:41:16
The constructor above has 4 params but it is being
Cutch
2013/07/19 18:15:02
Done.
| |
44 Resource.resources[name] = resource; | |
45 } | |
OLD | NEW |