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

Unified Diff: third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js

Issue 2195113002: DevTools: improve UX for hosted mode + fix bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address CL feedback 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/inspector.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
diff --git a/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js b/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
index 8d6dfd1e5751bad773a5ecf25263f179d303fce8..ba93b1114e69805b4062194e97165ed8808a45c2 100644
--- a/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
+++ b/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
@@ -7,17 +7,20 @@ var http = require("http");
var https = require("https");
var path = require("path");
var parseURL = require("url").parse;
+var Stream = require("stream").Transform;
-var port = parseInt(process.env.PORT, 10) || 8090;
+var remoteDebuggingPort = parseInt(process.env.REMOTE_DEBUGGING_PORT, 10) || 9222;
+var serverPort = parseInt(process.env.PORT, 10) || 8090;
+var entryLink = `http://localhost:${remoteDebuggingPort}#http://localhost:${serverPort}/front_end/inspector.html?experiments=true`;
lushnikov 2016/08/04 01:17:27 let's put this where it's used, no need to make it
chenwilliam 2016/08/04 17:56:23 Done.
-http.createServer(requestHandler).listen(port);
-console.log("Started hosted mode server at http://localhost:" + port);
+http.createServer(requestHandler).listen(serverPort);
+console.log("Started hosted mode server at http://localhost:" + serverPort);
function requestHandler(request, response)
{
var filePath = parseURL(request.url).pathname;
- if (filePath === "/front_end/InspectorBackendCommands.js") {
- sendResponse(200, " ");
+ if (filePath === "/") {
+ sendResponse(200, `<html>Please go to <a href="${entryLink}">${entryLink}</a></html>`);
return;
}
@@ -32,6 +35,7 @@ function requestHandler(request, response)
function handleProxyError(err)
{
console.log(`Error fetching over the internet file ${filePath}:`, err);
+ console.log(`Make sure you opened Chrome with the flag "--remote-debugging-port=${remoteDebuggingPort}"`);
sendResponse(500, "500 - Internal Server Error");
}
@@ -67,25 +71,14 @@ function requestHandler(request, response)
}
var proxyFilePathToURL = {
- "/front_end/sdk/protocol/js_protocol.json": getWebKitURL.bind(null, "platform/v8_inspector/js_protocol.json"),
- "/front_end/sdk/protocol/browser_protocol.json": getWebKitURL.bind(null, "core/inspector/browser_protocol.json"),
- "/front_end/SupportedCSSProperties.js": getFrontendURL.bind(null, "SupportedCSSProperties.js")
+ "/front_end/SupportedCSSProperties.js": cloudURL.bind(null, "SupportedCSSProperties.js"),
+ "/front_end/InspectorBackendCommands.js": cloudURL.bind(null, "InspectorBackendCommands.js"),
+ "/favicon.ico": () => "https://chrome-devtools-frontend.appspot.com/favicon.ico"
};
-function getWebKitURL(path, commitHash)
+function cloudURL(path, commitHash)
{
- return {
- url: `https://chromium.googlesource.com/chromium/src/+/${commitHash}/third_party/WebKit/Source/${path}?format=TEXT`,
- isBase64: true
- }
-}
-
-function getFrontendURL(path, commitHash)
-{
- return {
- url: `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitHash}/${path}`,
- isBase64: false
- }
+ return `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitHash}/${path}`;
}
var proxyFileCache = new Map();
@@ -94,7 +87,7 @@ function proxy(filePath)
{
if (!(filePath in proxyFilePathToURL))
return null;
- return fetch("http://localhost:9222/json/version")
+ return fetch(`http://localhost:${remoteDebuggingPort}/json/version`)
.then(onBrowserMetadata);
function onBrowserMetadata(metadata)
@@ -102,12 +95,10 @@ function proxy(filePath)
var metadataObject = JSON.parse(metadata);
var match = metadataObject["WebKit-Version"].match(/\s\(@(\b[0-9a-f]{5,40}\b)/);
var commitHash = match[1];
- var proxyFile = proxyFilePathToURL[filePath](commitHash);
- var proxyFileURL = proxyFile.url;
+ var proxyFileURL= proxyFilePathToURL[filePath](commitHash);
lushnikov 2016/08/04 01:17:27 nit: space's missing
chenwilliam 2016/08/04 17:56:23 Done.
if (proxyFileCache.has(proxyFileURL))
return proxyFileCache.get(proxyFileURL);
return fetch(proxyFileURL)
- .then(text => proxyFile.isBase64 ? new Buffer(text, "base64").toString("binary") : text)
.then(cacheProxyFile.bind(null, proxyFileURL));
}
@@ -143,9 +134,9 @@ function fetch(url)
reject(new Error(`Request error: + ${response.statusCode}`));
return;
}
- var body = "";
- response.on("data", chunk => body += chunk);
- response.on("end", () => resolve(body));
+ var body = new Stream();
chenwilliam 2016/08/03 22:30:39 Using a stream to properly fetch images (e.g. favi
+ response.on("data", chunk => body.push(chunk));
+ response.on("end", () => resolve(body.read()));
}
}
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/inspector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698