OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // All of these scripts could be imported with a single call to importScripts, | 5 // All of these scripts could be imported with a single call to importScripts, |
6 // but then load and compile time errors would all be reported from the same | 6 // but then load and compile time errors would all be reported from the same |
7 // line. | 7 // line. |
8 importScripts('metadata_parser.js'); | 8 importScripts('metadata_parser.js'); |
9 importScripts('byte_reader.js'); | 9 importScripts('byte_reader.js'); |
10 importScripts('../util.js'); | 10 importScripts('../util.js'); |
11 | 11 |
12 /** | 12 /** |
13 * Dispatches metadata requests to the correct parser. | 13 * Dispatches metadata requests to the correct parser. |
14 * | 14 * |
| 15 * @param {Object} port Worker port. |
15 * @constructor | 16 * @constructor |
16 * @param {Object} port Worker port. | |
17 */ | 17 */ |
18 function MetadataDispatcher(port) { | 18 function MetadataDispatcher(port) { |
19 this.port_ = port; | 19 this.port_ = port; |
20 this.port_.onmessage = this.onMessage.bind(this); | 20 this.port_.onmessage = this.onMessage.bind(this); |
21 | 21 |
22 // Make sure to update component_extension_resources.grd | 22 // Make sure to update component_extension_resources.grd |
23 // when adding new parsers. | 23 // when adding new parsers. |
24 importScripts('exif_parser.js'); | 24 importScripts('exif_parser.js'); |
25 importScripts('image_parsers.js'); | 25 importScripts('image_parsers.js'); |
26 importScripts('mpeg_parser.js'); | 26 importScripts('mpeg_parser.js'); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (global.constructor.name == 'SharedWorkerContext') { | 215 if (global.constructor.name == 'SharedWorkerContext') { |
216 global.addEventListener('connect', function(e) { | 216 global.addEventListener('connect', function(e) { |
217 var port = e.ports[0]; | 217 var port = e.ports[0]; |
218 new MetadataDispatcher(port); | 218 new MetadataDispatcher(port); |
219 port.start(); | 219 port.start(); |
220 }); | 220 }); |
221 } else { | 221 } else { |
222 // Non-shared worker. | 222 // Non-shared worker. |
223 new MetadataDispatcher(global); | 223 new MetadataDispatcher(global); |
224 } | 224 } |
OLD | NEW |