OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Webworker spec says that the worker global object is called self. That's | 5 // Webworker spec says that the worker global object is called self. That's |
6 // a terrible name since we use it all over the chrome codebase to capture | 6 // a terrible name since we use it all over the chrome codebase to capture |
7 // the 'this' keyword in lambdas. | 7 // the 'this' keyword in lambdas. |
8 var global = self; | 8 var global = self; |
9 | 9 |
10 // All of these scripts could be imported with a single call to importScripts, | 10 // All of these scripts could be imported with a single call to importScripts, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 /** | 45 /** |
46 * Verbose logging for the dispatcher. | 46 * Verbose logging for the dispatcher. |
47 * | 47 * |
48 * Individual parsers also take this as their default verbosity setting. | 48 * Individual parsers also take this as their default verbosity setting. |
49 */ | 49 */ |
50 MetadataDispatcher.prototype.verbose = false; | 50 MetadataDispatcher.prototype.verbose = false; |
51 | 51 |
52 MetadataDispatcher.prototype.messageHandlers = { | 52 MetadataDispatcher.prototype.messageHandlers = { |
53 init: function() { | 53 init: function() { |
54 this.postMessage('filter', [this.parserRegexp_]); | 54 // Inform our owner that we're done initializing. |
| 55 // If we need to pass more data back, we can add it to the param array. |
| 56 this.postMessage('initialized', [this.parserRegexp_]); |
55 this.log('initialized with URL filter ' + this.parserRegexp_); | 57 this.log('initialized with URL filter ' + this.parserRegexp_); |
56 }, | 58 }, |
57 | 59 |
58 request: function(fileURL) { | 60 request: function(fileURL) { |
59 var self = this; | 61 var self = this; |
60 | 62 |
61 try { | 63 try { |
62 this.processOneFile(fileURL, function callback(metadata) { | 64 this.processOneFile(fileURL, function callback(metadata) { |
63 self.postMessage('result', [fileURL, metadata]); | 65 self.postMessage('result', [fileURL, metadata]); |
64 }); | 66 }); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 function parseContent(file, parser) { | 158 function parseContent(file, parser) { |
157 parser.parse(file, callback, onError); | 159 parser.parse(file, callback, onError); |
158 } | 160 } |
159 ]; | 161 ]; |
160 | 162 |
161 nextStep(); | 163 nextStep(); |
162 }; | 164 }; |
163 | 165 |
164 var dispatcher = new MetadataDispatcher(); | 166 var dispatcher = new MetadataDispatcher(); |
165 global.onmessage = dispatcher.onMessage.bind(dispatcher); | 167 global.onmessage = dispatcher.onMessage.bind(dispatcher); |
OLD | NEW |