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

Unified Diff: Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp

Issue 222153002: Disallow connecting an insecure WebSocket from a secure page. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 8 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: Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp
diff --git a/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp b/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp
index 84951e09f38dec2798d1f6f3b512a61686e3ed47..705b99d0087a20c063f983878c68d6e16aa7233e 100644
--- a/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp
+++ b/Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp
@@ -66,6 +66,10 @@ public:
}
// All setters are called on the main thread.
+ void setConnectRequestResult(bool connectRequestResult)
+ {
+ m_connectRequestResult = connectRequestResult;
+ }
void setSendRequestResult(WebSocketChannel::SendResult sendRequestResult)
{
m_sendRequestResult = sendRequestResult;
@@ -76,6 +80,10 @@ public:
}
// All getter are called on the worker thread.
+ bool connectRequestResult() const
+ {
+ return m_connectRequestResult;
+ }
WebSocketChannel::SendResult sendRequestResult() const
{
return m_sendRequestResult;
@@ -100,12 +108,14 @@ public:
private:
ThreadableWebSocketChannelSyncHelper(PassOwnPtr<blink::WebWaitableEvent> event)
: m_event(event)
+ , m_connectRequestResult(false)
, m_sendRequestResult(WebSocketChannel::SendFail)
, m_bufferedAmount(0)
{
}
OwnPtr<blink::WebWaitableEvent> m_event;
+ bool m_connectRequestResult;
WebSocketChannel::SendResult m_sendRequestResult;
unsigned long m_bufferedAmount;
};
@@ -126,10 +136,11 @@ WorkerThreadableWebSocketChannel::~WorkerThreadableWebSocketChannel()
m_bridge->disconnect();
}
-void WorkerThreadableWebSocketChannel::connect(const KURL& url, const String& protocol)
+bool WorkerThreadableWebSocketChannel::connect(const KURL& url, const String& protocol)
{
if (m_bridge)
- m_bridge->connect(url, protocol);
+ return m_bridge->connect(url, protocol);
+ return false;
}
String WorkerThreadableWebSocketChannel::subprotocol()
@@ -259,9 +270,13 @@ void WorkerThreadableWebSocketChannel::Peer::destroy()
void WorkerThreadableWebSocketChannel::Peer::connect(const KURL& url, const String& protocol)
{
ASSERT(isMainThread());
- if (!m_mainWebSocketChannel)
- return;
- m_mainWebSocketChannel->connect(url, protocol);
+ if (!m_mainWebSocketChannel || !m_workerClientWrapper) {
+ m_syncHelper->setConnectRequestResult(false);
+ } else {
+ bool connectRequestResult = m_mainWebSocketChannel->connect(url, protocol);
+ m_syncHelper->setConnectRequestResult(connectRequestResult);
+ }
+ m_syncHelper->signalWorkerThread();
}
void WorkerThreadableWebSocketChannel::Peer::send(const String& message)
@@ -472,10 +487,13 @@ void WorkerThreadableWebSocketChannel::Bridge::initialize(const String& sourceUR
}
}
-void WorkerThreadableWebSocketChannel::Bridge::connect(const KURL& url, const String& protocol)
+bool WorkerThreadableWebSocketChannel::Bridge::connect(const KURL& url, const String& protocol)
{
ASSERT(m_workerClientWrapper);
m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::connect, m_peer, url.copy(), protocol.isolatedCopy())));
+ RefPtr<Bridge> protect(this);
+ waitForMethodCompletion();
+ return m_syncHelper->connectRequestResult();
}
WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(const String& message)
@@ -498,6 +516,7 @@ WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge::send(cons
OwnPtr<Vector<char> > data = adoptPtr(new Vector<char>(byteLength));
if (binaryData.byteLength())
memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteOffset, byteLength);
+
m_loaderProxy.postTaskToLoader(CallClosureTask::create(bind(&Peer::sendArrayBuffer, m_peer, data.release())));
RefPtr<Bridge> protect(this);
waitForMethodCompletion();
« no previous file with comments | « Source/modules/websockets/WorkerThreadableWebSocketChannel.h ('k') | Tools/Scripts/webkitpy/layout_tests/port/base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698