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

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

Issue 2344353004: DevTools: Build release mode using JS and Python (Closed)
Patch Set: fix Created 4 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 side-by-side diff with in-line comments
Download patch
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 305c2b68709f1e538a39fe8f6982099a11e8e12d..3287785bff3073984a2b5a84cd18602d20ebff05 100644
--- a/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
+++ b/third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js
@@ -3,10 +3,10 @@
// found in the LICENSE file.
var fs = require("fs");
var http = require("http");
-var https = require("https");
var path = require("path");
var parseURL = require("url").parse;
-var Stream = require("stream").Transform;
+
+var utils = require("../utils");
var remoteDebuggingPort = parseInt(process.env.REMOTE_DEBUGGING_PORT, 10) || 9222;
var serverPort = parseInt(process.env.PORT, 10) || 8090;
@@ -98,7 +98,7 @@ function proxy(filePath)
return null;
if (process.env.CHROMIUM_COMMIT)
return onProxyFileURL(proxyFilePathToURL[filePath](process.env.CHROMIUM_COMMIT));
- return fetch(`http://localhost:${remoteDebuggingPort}/json/version`)
+ return utils.fetch(`http://localhost:${remoteDebuggingPort}/json/version`)
.then(onBrowserMetadata)
.then(onProxyFileURL);
@@ -115,7 +115,7 @@ function proxy(filePath)
{
if (proxyFileCache.has(proxyFileURL))
return Promise.resolve(proxyFileCache.get(proxyFileURL));
- return fetch(proxyFileURL)
+ return utils.fetch(proxyFileURL)
.then(cacheProxyFile.bind(null, proxyFileURL));
}
@@ -125,36 +125,3 @@ function proxy(filePath)
return data;
}
}
-
-function fetch(url)
-{
- return new Promise(fetchPromise);
-
- function fetchPromise(resolve, reject)
- {
- var request;
- var protocol = parseURL(url).protocol;
- var handleResponse = getCallback.bind(null, resolve, reject);
- if (protocol === "https:") {
- request = https.get(url, handleResponse);
- } else if (protocol === "http:") {
- request = http.get(url, handleResponse);
- } else {
- reject(new Error(`Invalid protocol for url: ${url}`));
- return;
- }
- request.on("error", err => reject(err));
- }
-
- function getCallback(resolve, reject, response)
- {
- if (response.statusCode !== 200) {
- reject(new Error(`Request error: + ${response.statusCode}`));
- return;
- }
- var body = new Stream();
- response.on("data", chunk => body.push(chunk));
- response.on("end", () => resolve(body.read()));
- }
-}
-

Powered by Google App Engine
This is Rietveld 408576698