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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/InspectorBackendHostedMode.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 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 // This should be executed immediately after InspectorBackend and InspectorBacke ndCommands 5 // This should be executed immediately after InspectorBackend and InspectorBacke ndCommands
6 6
7 WebInspector.InspectorBackendHostedMode = {}; 7 WebInspector.InspectorBackendHostedMode = {};
8 8
9 /** 9 WebInspector.InspectorBackendHostedMode.loadFromJSONIfNeeded = function()
10 * @param {string} jsonUrl
11 */
12 WebInspector.InspectorBackendHostedMode.loadFromJSONIfNeeded = function(jsonUrl)
13 { 10 {
14 if (InspectorBackend.isInitialized()) 11 if (InspectorBackend.isInitialized())
15 return; 12 return;
16 13
17 var xhr = new XMLHttpRequest(); 14 var protocolURLs = Object.keys(Runtime.cachedResources).filter(url => url.in dexOf("protocol.json") !== -1);
dgozman 2016/07/08 05:45:07 This code will be much easier without fancy functi
lushnikov 2016/07/08 17:09:53 Done.
18 xhr.open("GET", jsonUrl, false); 15 var protocols = protocolURLs.map(url => Runtime.cachedResources[url]);
19 xhr.send(null); 16 for (var protocol of protocols) {
20 17 var code = WebInspector.InspectorBackendHostedMode.generateCommands(JSON .parse(protocol));
21 var schema = JSON.parse(xhr.responseText); 18 eval(code);
22 var code = WebInspector.InspectorBackendHostedMode.generateCommands(schema); 19 }
23 eval(code);
24 } 20 }
25 21
26 /** 22 /**
27 * @param {*} schema 23 * @param {*} schema
28 * @return {string} 24 * @return {string}
29 */ 25 */
30 WebInspector.InspectorBackendHostedMode.generateCommands = function(schema) 26 WebInspector.InspectorBackendHostedMode.generateCommands = function(schema)
31 { 27 {
32 var jsTypes = { integer: "number", array: "object" }; 28 var jsTypes = { integer: "number", array: "object" };
33 var rawTypes = {}; 29 var rawTypes = {};
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 for (var k = 0; event.parameters && k < event.parameters.length; ++k ) { 111 for (var k = 0; event.parameters && k < event.parameters.length; ++k ) {
116 var parameter = event.parameters[k]; 112 var parameter = event.parameters[k];
117 paramsText.push("\"" + parameter.name + "\""); 113 paramsText.push("\"" + parameter.name + "\"");
118 } 114 }
119 result.push("InspectorBackend.registerEvent(\"" + domain.domain + ". " + event.name + "\", [" + paramsText.join(", ") + "]);"); 115 result.push("InspectorBackend.registerEvent(\"" + domain.domain + ". " + event.name + "\", [" + paramsText.join(", ") + "]);");
120 } 116 }
121 } 117 }
122 return result.join("\n"); 118 return result.join("\n");
123 } 119 }
124 120
125 WebInspector.InspectorBackendHostedMode.loadFromJSONIfNeeded("../inspector.json" ); 121 WebInspector.InspectorBackendHostedMode.loadFromJSONIfNeeded();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698