| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 var workerURL = window.URL.createObjectURL(blob); | 210 var workerURL = window.URL.createObjectURL(blob); |
| 211 try { | 211 try { |
| 212 var worker = new Worker(workerURL); | 212 var worker = new Worker(workerURL); |
| 213 worker.postMessage(message); | 213 worker.postMessage(message); |
| 214 return worker; | 214 return worker; |
| 215 } finally { | 215 } finally { |
| 216 window.URL.revokeObjectURL(workerURL); | 216 window.URL.revokeObjectURL(workerURL); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 Runtime._coreModules = ["common", "host", "sdk", "ui", "components", "workspace"
, "bindings", "screencast", "toolbox", "main"]; |
| 221 |
| 220 Runtime.prototype = { | 222 Runtime.prototype = { |
| 221 /** | 223 /** |
| 222 * @param {!Array.<string>} configuration | 224 * @param {!Array.<string>} configuration |
| 223 */ | 225 */ |
| 224 registerModules: function(configuration) | 226 registerModules: function(configuration) |
| 225 { | 227 { |
| 226 for (var i = 0; i < configuration.length; ++i) | 228 for (var i = 0; i < configuration.length; ++i) |
| 227 this._registerModule(configuration[i]); | 229 this._registerModule(configuration[i]); |
| 228 }, | 230 }, |
| 229 | 231 |
| 230 /** | 232 /** |
| 231 * @param {string} moduleName | 233 * @param {string} moduleName |
| 232 */ | 234 */ |
| 233 _registerModule: function(moduleName) | 235 _registerModule: function(moduleName) |
| 234 { | 236 { |
| 235 if (!this._descriptorsMap[moduleName]) { | 237 if (!this._descriptorsMap[moduleName]) { |
| 236 var content = loadResource(moduleName + "/module.json"); | 238 var content; |
| 239 // FIXME: This is a temp workaround to avoid core module loading att
empts in the release mode. |
| 240 // It should be removed when the new application loader is implement
ed. |
| 241 if (Runtime._coreModules.indexOf(moduleName) === -1) |
| 242 content = loadResource(moduleName + "/module.json"); |
| 243 else |
| 244 content = "{}"; |
| 245 |
| 237 if (!content) | 246 if (!content) |
| 238 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); | 247 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); |
| 248 |
| 239 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); | 249 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); |
| 240 module["name"] = moduleName; | 250 module["name"] = moduleName; |
| 241 this._descriptorsMap[moduleName] = module; | 251 this._descriptorsMap[moduleName] = module; |
| 242 } | 252 } |
| 243 var module = new Runtime.Module(this, this._descriptorsMap[moduleName]); | 253 var module = new Runtime.Module(this, this._descriptorsMap[moduleName]); |
| 244 this._modules.push(module); | 254 this._modules.push(module); |
| 245 this._modulesMap[moduleName] = module; | 255 this._modulesMap[moduleName] = module; |
| 246 }, | 256 }, |
| 247 | 257 |
| 248 /** | 258 /** |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 Error.stackTraceLimit = oldStackTraceLimit; | 540 Error.stackTraceLimit = oldStackTraceLimit; |
| 531 return; | 541 return; |
| 532 } | 542 } |
| 533 | 543 |
| 534 this._isLoading = true; | 544 this._isLoading = true; |
| 535 var dependencies = this._descriptor.dependencies; | 545 var dependencies = this._descriptor.dependencies; |
| 536 for (var i = 0; dependencies && i < dependencies.length; ++i) | 546 for (var i = 0; dependencies && i < dependencies.length; ++i) |
| 537 this._manager.loadModule(dependencies[i]); | 547 this._manager.loadModule(dependencies[i]); |
| 538 if (this._descriptor.scripts) { | 548 if (this._descriptor.scripts) { |
| 539 if (Runtime.isReleaseMode()) { | 549 if (Runtime.isReleaseMode()) { |
| 540 loadScript(this._name + ".js"); | 550 // FIXME: This is a temp workaround to avoid core module loading
attempts in the release mode. |
| 551 // It should be removed when the new application loader is imple
mented. |
| 552 if (Runtime._coreModules.indexOf(this._name) === -1) |
| 553 loadScript(this._name + ".js"); |
| 541 } else { | 554 } else { |
| 542 var scripts = this._descriptor.scripts; | 555 var scripts = this._descriptor.scripts; |
| 543 for (var i = 0; i < scripts.length; ++i) | 556 for (var i = 0; i < scripts.length; ++i) |
| 544 loadScript(this._name + "/" + scripts[i]); | 557 loadScript(this._name + "/" + scripts[i]); |
| 545 } | 558 } |
| 546 } | 559 } |
| 547 this._isLoading = false; | 560 this._isLoading = false; |
| 548 this._loaded = true; | 561 this._loaded = true; |
| 549 } | 562 } |
| 550 } | 563 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 this._instance = new constructorFunction(); | 635 this._instance = new constructorFunction(); |
| 623 } | 636 } |
| 624 return this._instance; | 637 return this._instance; |
| 625 } | 638 } |
| 626 } | 639 } |
| 627 | 640 |
| 628 /** | 641 /** |
| 629 * @type {!Runtime} | 642 * @type {!Runtime} |
| 630 */ | 643 */ |
| 631 var runtime; | 644 var runtime; |
| OLD | NEW |