Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: Source/devtools/front_end/Runtime.js

Issue 573453004: DevTools: Get rid of frontend_modules.json (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/audits/module.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 /** 131 /**
132 * @type {!Object.<string, !function(new:Object)>} 132 * @type {!Object.<string, !function(new:Object)>}
133 */ 133 */
134 this._cachedTypeClasses = {}; 134 this._cachedTypeClasses = {};
135 135
136 /** 136 /**
137 * @type {!Object.<string, !Runtime.ModuleDescriptor>} 137 * @type {!Object.<string, !Runtime.ModuleDescriptor>}
138 */ 138 */
139 this._descriptorsMap = {}; 139 this._descriptorsMap = {};
140
141 /**
142 * @type {!Object.<string, boolean>}
143 */
144 this._coreModules = {};
145
140 for (var i = 0; i < allDescriptors.length; ++i) 146 for (var i = 0; i < allDescriptors.length; ++i)
141 this._descriptorsMap[allDescriptors[i]["name"]] = allDescriptors[i]; 147 this._descriptorsMap[allDescriptors[i]["name"]] = allDescriptors[i];
142 } 148 }
143 149
144 /** 150 /**
145 * @return {boolean} 151 * @return {boolean}
146 */ 152 */
147 Runtime.isReleaseMode = function() 153 Runtime.isReleaseMode = function()
148 { 154 {
149 return !!allDescriptors.length; 155 return !!allDescriptors.length;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 worker.postMessage(message); 219 worker.postMessage(message);
214 return worker; 220 return worker;
215 } finally { 221 } finally {
216 window.URL.revokeObjectURL(workerURL); 222 window.URL.revokeObjectURL(workerURL);
217 } 223 }
218 } 224 }
219 225
220 Runtime.prototype = { 226 Runtime.prototype = {
221 /** 227 /**
222 * @param {!Array.<string>} configuration 228 * @param {!Array.<string>} configuration
229 * @param {!Array.<string>} coreModules
223 */ 230 */
224 registerModules: function(configuration) 231 registerModules: function(configuration, coreModules)
225 { 232 {
233 for (var i = 0; i < coreModules.length; ++i)
234 this._coreModules[coreModules[i]] = true;
226 for (var i = 0; i < configuration.length; ++i) 235 for (var i = 0; i < configuration.length; ++i)
227 this._registerModule(configuration[i]); 236 this._registerModule(configuration[i]);
228 }, 237 },
229 238
230 /** 239 /**
231 * @param {string} moduleName 240 * @param {string} moduleName
232 */ 241 */
233 _registerModule: function(moduleName) 242 _registerModule: function(moduleName)
234 { 243 {
235 if (!this._descriptorsMap[moduleName]) { 244 if (!this._descriptorsMap[moduleName]) {
236 var content = loadResource(moduleName + "/module.json"); 245 var content;
246 // FIXME: This is a temp workaround to avoid core module loading att empts in the release mode.
247 // It should be removed when the new application loader is implement ed.
248 if (!this._coreModules.hasOwnProperty(moduleName))
249 content = loadResource(moduleName + "/module.json");
250 else
251 content = "{}";
252
237 if (!content) 253 if (!content)
238 throw new Error("Module is not defined: " + moduleName + " " + n ew Error().stack); 254 throw new Error("Module is not defined: " + moduleName + " " + n ew Error().stack);
255
239 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("(" + content + ")")); 256 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("(" + content + ")"));
240 module["name"] = moduleName; 257 module["name"] = moduleName;
241 this._descriptorsMap[moduleName] = module; 258 this._descriptorsMap[moduleName] = module;
242 } 259 }
243 var module = new Runtime.Module(this, this._descriptorsMap[moduleName]); 260 var module = new Runtime.Module(this, this._descriptorsMap[moduleName]);
244 this._modules.push(module); 261 this._modules.push(module);
245 this._modulesMap[moduleName] = module; 262 this._modulesMap[moduleName] = module;
246 }, 263 },
247 264
248 /** 265 /**
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 Error.stackTraceLimit = oldStackTraceLimit; 547 Error.stackTraceLimit = oldStackTraceLimit;
531 return; 548 return;
532 } 549 }
533 550
534 this._isLoading = true; 551 this._isLoading = true;
535 var dependencies = this._descriptor.dependencies; 552 var dependencies = this._descriptor.dependencies;
536 for (var i = 0; dependencies && i < dependencies.length; ++i) 553 for (var i = 0; dependencies && i < dependencies.length; ++i)
537 this._manager.loadModule(dependencies[i]); 554 this._manager.loadModule(dependencies[i]);
538 if (this._descriptor.scripts) { 555 if (this._descriptor.scripts) {
539 if (Runtime.isReleaseMode()) { 556 if (Runtime.isReleaseMode()) {
540 loadScript(this._name + ".js"); 557 // FIXME: This is a temp workaround to avoid core module loading attempts in the release mode.
558 // It should be removed when the new application loader is imple mented.
559 if (!this._manager._coreModules.hasOwnProperty(this._name))
560 loadScript(this._name + ".js");
541 } else { 561 } else {
542 var scripts = this._descriptor.scripts; 562 var scripts = this._descriptor.scripts;
543 for (var i = 0; i < scripts.length; ++i) 563 for (var i = 0; i < scripts.length; ++i)
544 loadScript(this._name + "/" + scripts[i]); 564 loadScript(this._name + "/" + scripts[i]);
545 } 565 }
546 } 566 }
547 this._isLoading = false; 567 this._isLoading = false;
548 this._loaded = true; 568 this._loaded = true;
549 } 569 }
550 } 570 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 this._instance = new constructorFunction(); 642 this._instance = new constructorFunction();
623 } 643 }
624 return this._instance; 644 return this._instance;
625 } 645 }
626 } 646 }
627 647
628 /** 648 /**
629 * @type {!Runtime} 649 * @type {!Runtime}
630 */ 650 */
631 var runtime; 651 var runtime;
OLDNEW
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/audits/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698