summaryrefslogtreecommitdiffstats
path: root/src/core/dev_tools_http_handler_delegate_qt.cpp
diff options
context:
space:
mode:
authorXiaobo Wang <xiaobwang@blackberry.com>2013-12-17 10:18:32 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-21 00:09:56 +0100
commite78497c702447ce15369e18828bf1dc1aa073620 (patch)
tree76c227145a44df2623586ffb3a85330c1bff1f14 /src/core/dev_tools_http_handler_delegate_qt.cpp
parent68b9545aef894d8ba6b4ff0d4ccdb349d9aca818 (diff)
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>
Diffstat (limited to 'src/core/dev_tools_http_handler_delegate_qt.cpp')
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.cpp15
1 files changed, 14 insertions, 1 deletions
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()