Chromium Code Reviews| Index: runtime/bin/vmservice/resources.dart |
| diff --git a/runtime/bin/vmservice/resources.dart b/runtime/bin/vmservice/resources.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0868664d41cf0e4b4c4a03001841135ef890dd1f |
| --- /dev/null |
| +++ b/runtime/bin/vmservice/resources.dart |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +part of vmservice; |
| + |
| +String detectMimeType(String name) { |
| + 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.
|
| + switch (extension) { |
| + case 'html': |
| + return 'text/html; charset=UTF-8'; |
| + case 'dart': |
| + return 'application/dart; charset=UTF-8'; |
| + case 'js': |
| + return 'application/javascript; charset=UTF-8'; |
| + case 'css': |
| + return 'text/css; charset=UTF-8'; |
| + case 'gif': |
| + return 'image/gif'; |
| + case 'png': |
| + return 'image/png'; |
| + case 'jpg': |
| + return 'image/jpeg'; |
| + case 'jpeg': |
| + return 'image/jpeg'; |
| + default: |
| + return 'text/plain'; |
| + } |
| +} |
| + |
| + |
| +class Resource { |
| + final String name; |
| + final String mimeType; |
| + final List<int> data; |
| + 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.
|
| + static final Map<String, Resource> resources = new Map<String, Resource>(); |
| +} |
| + |
| + |
| +void _addResource(String name, List<int> data) { |
| + String mimeType = detectMimeType(name); |
| + 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.
|
| + Resource.resources[name] = resource; |
| +} |