From e78497c702447ce15369e18828bf1dc1aa073620 Mon Sep 17 00:00:00 2001 From: Xiaobo Wang <xiaobwang@blackberry.com> Date: Tue, 17 Dec 2013 10:18:32 +0800 Subject: [PATCH] Make inspector listening port configurable Currently we use fixed port 1337 as inspector port. When weblauncher is launched by chromedriver it passes the inspector port as commandline argument --remote-debugging-port=<port>. Later on chromedriver will try to communicate with chrome via that port. We should use that port when starting devtools HTTP handler. Change-Id: I83e3341a535d50a129670bd0056b3ca448c8e2e5 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com> --- src/core/dev_tools_http_handler_delegate_qt.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp index f71f56726..6470a60bd 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/dev_tools_http_handler_delegate_qt.cpp @@ -44,15 +44,28 @@ #include <QByteArray> #include <QFile> +#include "base/command_line.h" #include "base/files/file_path.h" +#include "base/strings/string_number_conversions.h" #include "content/public/browser/devtools_http_handler.h" +#include "content/public/common/content_switches.h" #include "net/socket/stream_listen_socket.h" #include "net/socket/tcp_listen_socket.h" DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt(content::BrowserContext* browser_context) : m_browserContext(browser_context) { - m_devtoolsHttpHandler = content::DevToolsHttpHandler::Start(new net::TCPListenSocketFactory("0.0.0.0", 1337), std::string(), this); + const int defaultPort = 1337; + int listeningPort = defaultPort; + const CommandLine &commandLine = *CommandLine::ForCurrentProcess(); + if (commandLine.HasSwitch(switches::kRemoteDebuggingPort)) { + std::string portString = + commandLine.GetSwitchValueASCII(switches::kRemoteDebuggingPort); + int portInt = 0; + if (base::StringToInt(portString, &portInt) && portInt > 0 && portInt < 65535) + listeningPort = portInt; + } + m_devtoolsHttpHandler = content::DevToolsHttpHandler::Start(new net::TCPListenSocketFactory("0.0.0.0", listeningPort), std::string(), this); } DevToolsHttpHandlerDelegateQt::~DevToolsHttpHandlerDelegateQt() -- GitLab