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

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

Issue 2124203002: DevTools: copy protocol files to front-end to fix hosted mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pre-load json files for hosted mode Created 4 years, 5 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 * @type {!Object.<string, string>} 207 * @type {!Object.<string, string>}
208 */ 208 */
209 Runtime._queryParamsObject = { __proto__: null }; 209 Runtime._queryParamsObject = { __proto__: null };
210 210
211 /** 211 /**
212 * @type {!Object.<string, string>} 212 * @type {!Object.<string, string>}
213 */ 213 */
214 Runtime.cachedResources = { __proto__: null }; 214 Runtime.cachedResources = { __proto__: null };
215 215
216 /** 216 /**
217 * @param {string} url
218 * @param {boolean=} doNotAddSourceURL
dgozman 2016/07/08 05:45:07 Let's make it non-optional |addSourceURL|.
lushnikov 2016/07/08 17:09:53 Done.
219 * @return {!Promise<undefined>}
220 */
221 Runtime.loadResourceIntoCache = function(url, doNotAddSourceURL)
222 {
223 return loadResourcePromise(url).then(cacheResource.bind(this, url), cacheRes ource.bind(this, url, undefined));
224
225 /**
226 * @param {string} path
227 * @param {string=} content
228 */
229 function cacheResource(path, content)
230 {
231 if (!content) {
232 console.error("Failed to load resource: " + path);
233 return;
234 }
235 var sourceURL = doNotAddSourceURL ? "" : Runtime.resolveSourceURL(path);
236 Runtime.cachedResources[path] = content + sourceURL;
237 }
238 }
239
240 /**
217 * @return {boolean} 241 * @return {boolean}
218 */ 242 */
219 Runtime.isReleaseMode = function() 243 Runtime.isReleaseMode = function()
220 { 244 {
221 return !!allDescriptors.length; 245 return !!allDescriptors.length;
222 } 246 }
223 247
224 /** 248 /**
225 * @param {string} appName 249 * @param {string} appName
226 * @return {!Promise.<undefined>} 250 * @return {!Promise.<undefined>}
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 * @this {Runtime.Module} 790 * @this {Runtime.Module}
767 */ 791 */
768 _loadResources: function() 792 _loadResources: function()
769 { 793 {
770 var resources = this._descriptor["resources"]; 794 var resources = this._descriptor["resources"];
771 if (!resources) 795 if (!resources)
772 return Promise.resolve(); 796 return Promise.resolve();
773 var promises = []; 797 var promises = [];
774 for (var i = 0; i < resources.length; ++i) { 798 for (var i = 0; i < resources.length; ++i) {
775 var url = this._modularizeURL(resources[i]); 799 var url = this._modularizeURL(resources[i]);
776 promises.push(loadResourcePromise(url).then(cacheResource.bind(this, url), cacheResource.bind(this, url, undefined))); 800 promises.push(Runtime.loadResourceIntoCache(url));
777 } 801 }
778 return Promise.all(promises).then(undefined); 802 return Promise.all(promises).then(undefined);
779
780 /**
781 * @param {string} path
782 * @param {string=} content
783 */
784 function cacheResource(path, content)
785 {
786 if (!content) {
787 console.error("Failed to load resource: " + path);
788 return;
789 }
790 Runtime.cachedResources[path] = content + Runtime.resolveSourceURL(p ath);
791 }
792 }, 803 },
793 804
794 /** 805 /**
795 * @return {!Promise.<undefined>} 806 * @return {!Promise.<undefined>}
796 */ 807 */
797 _loadScripts: function() 808 _loadScripts: function()
798 { 809 {
799 if (!this._descriptor.scripts) 810 if (!this._descriptor.scripts)
800 return Promise.resolve(); 811 return Promise.resolve();
801 812
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 { 1189 {
1179 var sourceURL = self.location.href; 1190 var sourceURL = self.location.href;
1180 if (self.location.search) 1191 if (self.location.search)
1181 sourceURL = sourceURL.replace(self.location.search, ""); 1192 sourceURL = sourceURL.replace(self.location.search, "");
1182 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; 1193 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path;
1183 return "\n/*# sourceURL=" + sourceURL + " */"; 1194 return "\n/*# sourceURL=" + sourceURL + " */";
1184 } 1195 }
1185 1196
1186 /** @type {!Runtime} */ 1197 /** @type {!Runtime} */
1187 var runtime; 1198 var runtime;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698