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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 // All of these scripts could be imported with a single call to importScripts, | 7 // All of these scripts could be imported with a single call to importScripts, |
8 // but then load and compile time errors would all be reported from the same | 8 // but then load and compile time errors would all be reported from the same |
9 // line. | 9 // line. |
10 importScripts('metadata_parser.js'); | 10 importScripts('metadata_parser.js'); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ]; | 207 ]; |
208 | 208 |
209 nextStep(); | 209 nextStep(); |
210 }; | 210 }; |
211 | 211 |
212 // Webworker spec says that the worker global object is called self. That's | 212 // Webworker spec says that the worker global object is called self. That's |
213 // a terrible name since we use it all over the chrome codebase to capture | 213 // a terrible name since we use it all over the chrome codebase to capture |
214 // the 'this' keyword in lambdas. | 214 // the 'this' keyword in lambdas. |
215 var global = self; | 215 var global = self; |
216 | 216 |
217 if (global.constructor.name == 'SharedWorkerContext') { | 217 // TODO(cdumez): Remove support for SharedWorkerContext name after Blink is |
| 218 // rolled. |
| 219 if (global.constructor.name == 'SharedWorkerContext' || |
| 220 global.constructor.name == 'SharedWorkerGlobalScope') { |
218 global.addEventListener('connect', function(e) { | 221 global.addEventListener('connect', function(e) { |
219 var port = e.ports[0]; | 222 var port = e.ports[0]; |
220 new MetadataDispatcher(port); | 223 new MetadataDispatcher(port); |
221 port.start(); | 224 port.start(); |
222 }); | 225 }); |
223 } else { | 226 } else { |
224 // Non-shared worker. | 227 // Non-shared worker. |
225 new MetadataDispatcher(global); | 228 new MetadataDispatcher(global); |
226 } | 229 } |
OLD | NEW |