Skip to content

Commit

Permalink
Allow remote debugging using random port provided by OS
Browse files Browse the repository at this point in the history
  • Loading branch information
iradul authored and vitallium committed Jan 8, 2016
1 parent 05eafbe commit e7b7433
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ InspectorServerQt::~InspectorServerQt()
close();
}

void InspectorServerQt::listen(quint16 port)
int InspectorServerQt::listen(quint16 port)
{
if (m_tcpServer)
return;
return m_tcpServer->serverPort();

m_tcpServer = new QTcpServer();
m_tcpServer->listen(QHostAddress::Any, port);
connect(m_tcpServer, SIGNAL(newConnection()), SLOT(newConnection()));

return port;
}

void InspectorServerQt::close()
Expand Down Expand Up @@ -135,7 +137,7 @@ InspectorServerRequestHandlerQt::InspectorServerRequestHandlerQt(QTcpSocket* tcp
, m_server(server)
, m_inspectorClient(0)
{
m_endOfHeaders = false;
m_endOfHeaders = false;
m_contentLength = 0;

connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(tcpReadyRead()));
Expand Down Expand Up @@ -314,7 +316,7 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead()
return;
QByteArray content = m_tcpConnection->read(m_tcpConnection->bytesAvailable());
m_data.append(content);
while (m_data.size() > 0) {
while (m_data.size() > 0) {
const bool isMasked = m_data[1] & 0x80;
quint64 payloadLen = m_data[1] & 0x7F;
int pos = 2;
Expand All @@ -337,13 +339,13 @@ void InspectorServerRequestHandlerQt::webSocketReadyRead()

// Handle fragmentation
if (!(m_data[0] & 0x80)) { // Non-last fragmented payload
m_fragmentedPayload.append(payload);
m_fragmentedPayload.append(payload);
m_data = m_data.mid(pos + payloadLen);
continue;
}

if (!(m_data[0] & 0x0F)) { // Last fragment
m_fragmentedPayload.append(payload);
m_fragmentedPayload.append(payload);
payload = m_fragmentedPayload;
m_fragmentedPayload.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/qt/WebCoreSupport/InspectorServerQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class InspectorServerQt : public QObject {

static InspectorServerQt* server();

void listen(quint16 port);
int listen(quint16 port);

void registerClient(InspectorClientQt*);
void unregisterClient(InspectorClientQt*);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void QWebPageAdapter::dynamicPropertyChangeEvent(QObject* obj, QDynamicPropertyC
QVariant port = obj->property("_q_webInspectorServerPort");
if (port.isValid()) {
InspectorServerQt* inspectorServer = InspectorServerQt::server();
inspectorServer->listen(port.toInt());
obj->setProperty("_q_webInspectorServerPort", inspectorServer->listen(port.toInt()));
}
#endif
} else if (event->propertyName() == "_q_deadDecodedDataDeletionInterval") {
Expand Down

0 comments on commit e7b7433

Please sign in to comment.