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

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

Issue 887463003: Turn WorkerLoaderProxy into a threadsafe, ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clarify WorkerLoaderProxyProvider's obligations on shutdown Created 5 years, 10 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
« no previous file with comments | « Source/modules/websockets/WorkerWebSocketChannel.h ('k') | Source/web/WebEmbeddedWorkerImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/WorkerWebSocketChannel.cpp
diff --git a/Source/modules/websockets/WorkerWebSocketChannel.cpp b/Source/modules/websockets/WorkerWebSocketChannel.cpp
index ecd5f7b33a0ecd6e8edfa1582185d5528b276bdc..cf488bd8515629d59beddce1342ea3df410381d2 100644
--- a/Source/modules/websockets/WorkerWebSocketChannel.cpp
+++ b/Source/modules/websockets/WorkerWebSocketChannel.cpp
@@ -182,7 +182,7 @@ void WorkerWebSocketChannel::trace(Visitor* visitor)
WebSocketChannel::trace(visitor);
}
-Peer::Peer(Bridge* bridge, WorkerLoaderProxy& loaderProxy, WebSocketChannelSyncHelper* syncHelper)
+Peer::Peer(Bridge* bridge, PassRefPtr<WorkerLoaderProxy> loaderProxy, WebSocketChannelSyncHelper* syncHelper)
: m_bridge(bridge)
, m_loaderProxy(loaderProxy)
, m_mainWebSocketChannel(nullptr)
@@ -277,7 +277,7 @@ static void workerGlobalScopeDidConnect(ExecutionContext* context, Bridge* bridg
void Peer::didConnect(const String& subprotocol, const String& extensions)
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidConnect, m_bridge, subprotocol, extensions));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidConnect, m_bridge, subprotocol, extensions));
}
static void workerGlobalScopeDidReceiveTextMessage(ExecutionContext* context, Bridge* bridge, const String& payload)
@@ -290,7 +290,7 @@ static void workerGlobalScopeDidReceiveTextMessage(ExecutionContext* context, Br
void Peer::didReceiveTextMessage(const String& payload)
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidReceiveTextMessage, m_bridge, payload));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidReceiveTextMessage, m_bridge, payload));
}
static void workerGlobalScopeDidReceiveBinaryMessage(ExecutionContext* context, Bridge* bridge, PassOwnPtr<Vector<char>> payload)
@@ -303,7 +303,7 @@ static void workerGlobalScopeDidReceiveBinaryMessage(ExecutionContext* context,
void Peer::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload)
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidReceiveBinaryMessage, m_bridge, payload));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidReceiveBinaryMessage, m_bridge, payload));
}
static void workerGlobalScopeDidConsumeBufferedAmount(ExecutionContext* context, Bridge* bridge, uint64_t consumed)
@@ -316,7 +316,7 @@ static void workerGlobalScopeDidConsumeBufferedAmount(ExecutionContext* context,
void Peer::didConsumeBufferedAmount(uint64_t consumed)
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidConsumeBufferedAmount, m_bridge, consumed));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidConsumeBufferedAmount, m_bridge, consumed));
}
static void workerGlobalScopeDidStartClosingHandshake(ExecutionContext* context, Bridge* bridge)
@@ -329,7 +329,7 @@ static void workerGlobalScopeDidStartClosingHandshake(ExecutionContext* context,
void Peer::didStartClosingHandshake()
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidStartClosingHandshake, m_bridge));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidStartClosingHandshake, m_bridge));
}
static void workerGlobalScopeDidClose(ExecutionContext* context, Bridge* bridge, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)
@@ -346,7 +346,7 @@ void Peer::didClose(ClosingHandshakeCompletionStatus closingHandshakeCompletion,
m_mainWebSocketChannel->disconnect();
m_mainWebSocketChannel = nullptr;
}
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidClose, m_bridge, closingHandshakeCompletion, code, reason));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidClose, m_bridge, closingHandshakeCompletion, code, reason));
}
static void workerGlobalScopeDidError(ExecutionContext* context, Bridge* bridge)
@@ -359,7 +359,7 @@ static void workerGlobalScopeDidError(ExecutionContext* context, Bridge* bridge)
void Peer::didError()
{
ASSERT(isMainThread());
- m_loaderProxy.postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidError, m_bridge));
+ m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlobalScopeDidError, m_bridge));
}
void Peer::trace(Visitor* visitor)
@@ -406,7 +406,7 @@ bool Bridge::connect(const KURL& url, const String& protocol)
void Bridge::send(const String& message)
{
ASSERT(m_peer);
- m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get(), message));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get(), message));
}
void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigned byteLength)
@@ -417,25 +417,25 @@ void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne
if (binaryData.byteLength())
memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteOffset, byteLength);
- m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer, m_peer.get(), data.release()));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer, m_peer.get(), data.release()));
}
void Bridge::send(PassRefPtr<BlobDataHandle> data)
{
ASSERT(m_peer);
- m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_peer.get(), data));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, m_peer.get(), data));
}
void Bridge::close(int code, const String& reason)
{
ASSERT(m_peer);
- m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::close, m_peer.get(), code, reason));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, m_peer.get(), code, reason));
}
void Bridge::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber)
{
ASSERT(m_peer);
- m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::fail, m_peer.get(), reason, level, sourceURL, lineNumber));
+ m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, m_peer.get(), reason, level, sourceURL, lineNumber));
}
void Bridge::disconnect()
@@ -460,7 +460,7 @@ bool Bridge::waitForMethodCompletion(PassOwnPtr<ExecutionContextTask> task)
ASSERT(m_workerGlobalScope);
ASSERT(m_syncHelper);
- m_loaderProxy.postTaskToLoader(task);
+ m_loaderProxy->postTaskToLoader(task);
// We wait for the syncHelper event even if a shutdown event is fired.
// See https://codereview.chromium.org/267323004/#msg43 for why we need to wait this.
« no previous file with comments | « Source/modules/websockets/WorkerWebSocketChannel.h ('k') | Source/web/WebEmbeddedWorkerImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698