Skip to content
Permalink
Browse files
REGRESSION(r201880): WebSockets based remote inspector is broken sinc…
…e r201880

https://bugs.webkit.org/show_bug.cgi?id=158613

Reviewed by Michael Catanzaro.

In r201880 SocketStreamHandleClient was modified to receive references instead of
pointers. WebSocketServerConnection also implements SocketStreamHandleClient but since it's doesn't use
override, it was unnoticed and not updated, so we ended up using the default empty implementation instead of
the WebSocketServerConnection one.

* UIProcess/InspectorServer/WebSocketServerConnection.cpp:
(WebKit::WebSocketServerConnection::WebSocketServerConnection):
(WebKit::WebSocketServerConnection::setSocketHandle):
(WebKit::WebSocketServerConnection::shutdownNow):
(WebKit::WebSocketServerConnection::didCloseSocketStream):
(WebKit::WebSocketServerConnection::didReceiveSocketStreamData):
(WebKit::WebSocketServerConnection::didUpdateBufferedAmount):
(WebKit::WebSocketServerConnection::didFailSocketStream): Deleted.
* UIProcess/InspectorServer/WebSocketServerConnection.h:

Canonical link: https://commits.webkit.org/177134@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Jun 23, 2016
1 parent a0775be commit 5d4a059c208e027a10bab7e805de3e4e65a26504
@@ -1,3 +1,25 @@
2016-06-22 Carlos Garcia Campos <cgarcia@igalia.com>

REGRESSION(r201880): WebSockets based remote inspector is broken since r201880
https://bugs.webkit.org/show_bug.cgi?id=158613

Reviewed by Michael Catanzaro.

In r201880 SocketStreamHandleClient was modified to receive references instead of
pointers. WebSocketServerConnection also implements SocketStreamHandleClient but since it's doesn't use
override, it was unnoticed and not updated, so we ended up using the default empty implementation instead of
the WebSocketServerConnection one.

* UIProcess/InspectorServer/WebSocketServerConnection.cpp:
(WebKit::WebSocketServerConnection::WebSocketServerConnection):
(WebKit::WebSocketServerConnection::setSocketHandle):
(WebKit::WebSocketServerConnection::shutdownNow):
(WebKit::WebSocketServerConnection::didCloseSocketStream):
(WebKit::WebSocketServerConnection::didReceiveSocketStreamData):
(WebKit::WebSocketServerConnection::didUpdateBufferedAmount):
(WebKit::WebSocketServerConnection::didFailSocketStream): Deleted.
* UIProcess/InspectorServer/WebSocketServerConnection.h:

2016-06-22 Brent Fulgham <bfulgham@apple.com>

[iOS][WK2] Expand sandbox to read voice services preferences
@@ -47,11 +47,8 @@ using namespace WebCore;
namespace WebKit {

WebSocketServerConnection::WebSocketServerConnection(WebSocketServerClient* client, WebSocketServer* server)
: m_identifier(0)
, m_mode(HTTP)
, m_server(server)
: m_server(server)
, m_client(client)
, m_shutdownAfterSend(false)
{
}

@@ -60,17 +57,17 @@ WebSocketServerConnection::~WebSocketServerConnection()
shutdownNow();
}

void WebSocketServerConnection::setSocketHandle(PassRefPtr<WebCore::SocketStreamHandle> socket)
void WebSocketServerConnection::setSocketHandle(Ref<SocketStreamHandle>&& socket)
{
ASSERT(!m_socket);
m_socket = socket;
m_socket = WTFMove(socket);
}

void WebSocketServerConnection::shutdownNow()
{
if (!m_socket)
return;
RefPtr<SocketStreamHandle> socket = m_socket.release();
auto socket = WTFMove(m_socket);
socket->close();
m_shutdownAfterSend = false;
}
@@ -123,7 +120,7 @@ void WebSocketServerConnection::sendRawData(const char* data, size_t length)
m_socket->send(data, length);
}

void WebSocketServerConnection::didCloseSocketStream(SocketStreamHandle*)
void WebSocketServerConnection::didCloseSocketStream(SocketStreamHandle&)
{
// Destroy the SocketStreamHandle now to prevent closing an already closed socket later.
m_socket = nullptr;
@@ -136,7 +133,7 @@ void WebSocketServerConnection::didCloseSocketStream(SocketStreamHandle*)
m_server->didCloseWebSocketServerConnection(this);
}

void WebSocketServerConnection::didReceiveSocketStreamData(SocketStreamHandle*, const char* data, int length)
void WebSocketServerConnection::didReceiveSocketStreamData(SocketStreamHandle&, const char* data, int length)
{
// Each didReceiveData call adds more data to our buffer.
// We clear the buffer when we have handled data from it.
@@ -155,17 +152,12 @@ void WebSocketServerConnection::didReceiveSocketStreamData(SocketStreamHandle*,
}
}

void WebSocketServerConnection::didUpdateBufferedAmount(WebCore::SocketStreamHandle*, size_t)
void WebSocketServerConnection::didUpdateBufferedAmount(SocketStreamHandle&, size_t)
{
if (m_shutdownAfterSend && !m_socket->bufferedAmount())
shutdownNow();
}

void WebSocketServerConnection::didFailSocketStream(SocketStreamHandle*, const SocketStreamError&)
{
// Possible read or write error.
}

void WebSocketServerConnection::readHTTPMessage()
{
String failureReason;
@@ -46,15 +46,15 @@ class HTTPRequest;
class WebSocketServer;
class WebSocketServerClient;

class WebSocketServerConnection : public WebCore::SocketStreamHandleClient {
class WebSocketServerConnection final : public WebCore::SocketStreamHandleClient {
public:
enum WebSocketServerMode { HTTP, WebSocket };
WebSocketServerConnection(WebSocketServerClient*, WebSocketServer*);
virtual ~WebSocketServerConnection();

unsigned identifier() const { return m_identifier; }
void setIdentifier(unsigned id) { m_identifier = id; }
void setSocketHandle(PassRefPtr<WebCore::SocketStreamHandle>);
void setSocketHandle(Ref<WebCore::SocketStreamHandle>&&);

// Sending data over the connection.
void sendWebSocketMessage(const String& message);
@@ -65,13 +65,12 @@ class WebSocketServerConnection : public WebCore::SocketStreamHandleClient {
void shutdownNow();
void shutdownAfterSendOrNow();

private:
// SocketStreamHandleClient implementation.
virtual void didCloseSocketStream(WebCore::SocketStreamHandle*);
virtual void didReceiveSocketStreamData(WebCore::SocketStreamHandle*, const char* data, int length);
virtual void didUpdateBufferedAmount(WebCore::SocketStreamHandle*, size_t bufferedAmount);
virtual void didFailSocketStream(WebCore::SocketStreamHandle*, const WebCore::SocketStreamError&);
void didCloseSocketStream(WebCore::SocketStreamHandle&) override;
void didReceiveSocketStreamData(WebCore::SocketStreamHandle&, const char* data, int length) override;
void didUpdateBufferedAmount(WebCore::SocketStreamHandle&, size_t bufferedAmount) override;

private:
// HTTP Mode.
void readHTTPMessage();

@@ -80,14 +79,13 @@ class WebSocketServerConnection : public WebCore::SocketStreamHandleClient {
void readWebSocketFrames();
bool readWebSocketFrame();

protected:
unsigned m_identifier;
unsigned m_identifier { 0 };
Vector<char> m_bufferedData;
WebSocketServerMode m_mode;
WebSocketServerMode m_mode { HTTP };
RefPtr<WebCore::SocketStreamHandle> m_socket;
WebSocketServer* m_server;
WebSocketServerClient* m_client;
bool m_shutdownAfterSend;
WebSocketServer* m_server { nullptr };
WebSocketServerClient* m_client { nullptr };
bool m_shutdownAfterSend { false };
};

}

0 comments on commit 5d4a059

Please sign in to comment.