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

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

Issue 2191473005: DevTools: remove release mode from runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (!content) { 231 if (!content) {
232 console.error("Failed to load resource: " + path); 232 console.error("Failed to load resource: " + path);
233 return; 233 return;
234 } 234 }
235 var sourceURL = appendSourceURL ? Runtime.resolveSourceURL(path) : ""; 235 var sourceURL = appendSourceURL ? Runtime.resolveSourceURL(path) : "";
236 Runtime.cachedResources[path] = content + sourceURL; 236 Runtime.cachedResources[path] = content + sourceURL;
237 } 237 }
238 } 238 }
239 239
240 /** 240 /**
241 * @return {boolean}
242 */
243 Runtime.isReleaseMode = function()
244 {
245 return !!allDescriptors.length;
246 }
247
248 /**
249 * @param {string} appName 241 * @param {string} appName
250 * @return {!Promise.<undefined>} 242 * @return {!Promise.<undefined>}
251 */ 243 */
252 Runtime.startApplication = function(appName) 244 Runtime.startApplication = function(appName)
253 { 245 {
254 console.timeStamp("Runtime.startApplication"); 246 console.timeStamp("Runtime.startApplication");
255 247
256 var allDescriptorsByName = {}; 248 var allDescriptorsByName = {};
257 for (var i = 0; Runtime.isReleaseMode() && i < allDescriptors.length; ++i) { 249 for (var i = 0; i < allDescriptors.length; ++i) {
258 var d = allDescriptors[i]; 250 var d = allDescriptors[i];
259 allDescriptorsByName[d["name"]] = d; 251 allDescriptorsByName[d["name"]] = d;
260 } 252 }
261 253
262 var applicationPromise; 254 var applicationPromise;
263 if (applicationDescriptor) 255 if (applicationDescriptor)
264 applicationPromise = Promise.resolve(applicationDescriptor); 256 applicationPromise = Promise.resolve(applicationDescriptor);
265 else 257 else
266 applicationPromise = loadResourcePromise(appName + ".json").then(JSON.pa rse.bind(JSON)); 258 applicationPromise = loadResourcePromise(appName + ".json").then(JSON.pa rse.bind(JSON));
267 259
(...skipping 21 matching lines...) Expand all
289 } 281 }
290 282
291 return Promise.all(moduleJSONPromises).then(instantiateRuntime); 283 return Promise.all(moduleJSONPromises).then(instantiateRuntime);
292 284
293 /** 285 /**
294 * @param {!Array.<!Object>} moduleDescriptors 286 * @param {!Array.<!Object>} moduleDescriptors
295 * @return {!Promise.<undefined>} 287 * @return {!Promise.<undefined>}
296 */ 288 */
297 function instantiateRuntime(moduleDescriptors) 289 function instantiateRuntime(moduleDescriptors)
298 { 290 {
299 for (var i = 0; !Runtime.isReleaseMode() && i < moduleDescriptors.le ngth; ++i) { 291 for (var i = 0; i < moduleDescriptors.length; ++i) {
300 moduleDescriptors[i]["name"] = configuration[i]["name"]; 292 moduleDescriptors[i]["name"] = configuration[i]["name"];
301 moduleDescriptors[i]["condition"] = configuration[i]["condition" ]; 293 moduleDescriptors[i]["condition"] = configuration[i]["condition" ];
302 } 294 }
303 self.runtime = new Runtime(moduleDescriptors); 295 self.runtime = new Runtime(moduleDescriptors);
304 if (coreModuleNames) 296 if (coreModuleNames)
305 return /** @type {!Promise<undefined>} */ (self.runtime._loadAut oStartModules(coreModuleNames)); 297 return /** @type {!Promise<undefined>} */ (self.runtime._loadAut oStartModules(coreModuleNames));
306 return Promise.resolve(); 298 return Promise.resolve();
307 } 299 }
308 } 300 }
309 } 301 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return this._modulesMap[moduleName]._loadPromise(); 482 return this._modulesMap[moduleName]._loadPromise();
491 }, 483 },
492 484
493 /** 485 /**
494 * @param {!Array.<string>} moduleNames 486 * @param {!Array.<string>} moduleNames
495 * @return {!Promise.<!Array.<*>>} 487 * @return {!Promise.<!Array.<*>>}
496 */ 488 */
497 _loadAutoStartModules: function(moduleNames) 489 _loadAutoStartModules: function(moduleNames)
498 { 490 {
499 var promises = []; 491 var promises = [];
500 for (var i = 0; i < moduleNames.length; ++i) { 492 for (var i = 0; i < moduleNames.length; ++i)
501 if (Runtime.isReleaseMode()) 493 promises.push(this.loadModulePromise(moduleNames[i]));
502 this._modulesMap[moduleNames[i]]._loaded = true;
503 else
504 promises.push(this.loadModulePromise(moduleNames[i]));
505 }
506 return Promise.all(promises); 494 return Promise.all(promises);
507 }, 495 },
508 496
509 /** 497 /**
510 * @param {!Runtime.Extension} extension 498 * @param {!Runtime.Extension} extension
511 * @param {?function(function(new:Object)):boolean} predicate 499 * @param {?function(function(new:Object)):boolean} predicate
512 * @return {boolean} 500 * @return {boolean}
513 */ 501 */
514 _checkExtensionApplicability: function(extension, predicate) 502 _checkExtensionApplicability: function(extension, predicate)
515 { 503 {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 if (!content) 758 if (!content)
771 throw new Error(fullName + " not preloaded. Check module.json"); 759 throw new Error(fullName + " not preloaded. Check module.json");
772 return content; 760 return content;
773 }, 761 },
774 762
775 /** 763 /**
776 * @return {!Promise.<undefined>} 764 * @return {!Promise.<undefined>}
777 */ 765 */
778 _loadPromise: function() 766 _loadPromise: function()
779 { 767 {
780 if (this._loaded)
781 return Promise.resolve();
782
783 if (!this.enabled()) 768 if (!this.enabled())
784 return Promise.reject(new Error("Module " + this._name + " is not en abled")); 769 return Promise.reject(new Error("Module " + this._name + " is not en abled"));
785 770
786 if (this._pendingLoadPromise) 771 if (this._pendingLoadPromise)
787 return this._pendingLoadPromise; 772 return this._pendingLoadPromise;
788 773
789 var dependencies = this._descriptor.dependencies; 774 var dependencies = this._descriptor.dependencies;
790 var dependencyPromises = []; 775 var dependencyPromises = [];
791 for (var i = 0; dependencies && i < dependencies.length; ++i) 776 for (var i = 0; dependencies && i < dependencies.length; ++i)
792 dependencyPromises.push(this._manager._modulesMap[dependencies[i]]._ loadPromise()); 777 dependencyPromises.push(this._manager._modulesMap[dependencies[i]]._ loadPromise());
793 778
794 this._pendingLoadPromise = Promise.all(dependencyPromises) 779 this._pendingLoadPromise = Promise.all(dependencyPromises)
795 .then(this._loadResources.bind(this)) 780 .then(this._loadResources.bind(this))
796 .then(this._loadScripts.bind(this)) 781 .then(this._loadScripts.bind(this))
797 .then(markAsLoaded.bind(this)); 782 .then(() => this._loadedForTest = true);
798 783
799 return this._pendingLoadPromise; 784 return this._pendingLoadPromise;
800
801 /**
802 * @this {Runtime.Module}
803 */
804 function markAsLoaded()
805 {
806 delete this._pendingLoadPromise;
807 this._loaded = true;
808 }
809 }, 785 },
810 786
811 /** 787 /**
812 * @return {!Promise.<undefined>} 788 * @return {!Promise.<undefined>}
813 * @this {Runtime.Module} 789 * @this {Runtime.Module}
814 */ 790 */
815 _loadResources: function() 791 _loadResources: function()
816 { 792 {
817 var resources = this._descriptor["resources"]; 793 var resources = this._descriptor["resources"];
818 if (!resources) 794 if (!resources || !resources.length)
819 return Promise.resolve(); 795 return Promise.resolve();
820 var promises = []; 796 var promises = [];
821 for (var i = 0; i < resources.length; ++i) { 797 for (var i = 0; i < resources.length; ++i) {
822 var url = this._modularizeURL(resources[i]); 798 var url = this._modularizeURL(resources[i]);
823 promises.push(Runtime.loadResourceIntoCache(url, true)); 799 promises.push(Runtime.loadResourceIntoCache(url, true));
824 } 800 }
825 return Promise.all(promises).then(undefined); 801 return Promise.all(promises).then(undefined);
826 }, 802 },
827 803
828 /** 804 /**
829 * @return {!Promise.<undefined>} 805 * @return {!Promise.<undefined>}
830 */ 806 */
831 _loadScripts: function() 807 _loadScripts: function()
832 { 808 {
833 if (!this._descriptor.scripts) 809 if (!this._descriptor.scripts || !this._descriptor.scripts.length)
834 return Promise.resolve(); 810 return Promise.resolve();
835 811 return loadScriptsPromise(this._descriptor.scripts.map(this._modularizeU RL, this), this._remoteBase());
dgozman 2016/07/27 22:10:46 This makes it hard to develop remote modules - the
836 if (Runtime.isReleaseMode())
837 return loadScriptsPromise([this._name + "_module.js"], this._remoteB ase());
838
839 return loadScriptsPromise(this._descriptor.scripts.map(this._modularizeU RL, this));
840 }, 812 },
841 813
842 /** 814 /**
843 * @param {string} resourceName 815 * @param {string} resourceName
844 */ 816 */
845 _modularizeURL: function(resourceName) 817 _modularizeURL: function(resourceName)
846 { 818 {
847 return normalizePath(this._name + "/" + resourceName); 819 return normalizePath(this._name + "/" + resourceName);
848 }, 820 },
849 821
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 { 1183 {
1212 var sourceURL = self.location.href; 1184 var sourceURL = self.location.href;
1213 if (self.location.search) 1185 if (self.location.search)
1214 sourceURL = sourceURL.replace(self.location.search, ""); 1186 sourceURL = sourceURL.replace(self.location.search, "");
1215 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; 1187 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path;
1216 return "\n/*# sourceURL=" + sourceURL + " */"; 1188 return "\n/*# sourceURL=" + sourceURL + " */";
1217 } 1189 }
1218 1190
1219 /** @type {!Runtime} */ 1191 /** @type {!Runtime} */
1220 var runtime; 1192 var runtime;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698