summaryrefslogtreecommitdiffstats
path: root/dom/websocket/WebSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/websocket/WebSocket.cpp')
-rw-r--r--dom/websocket/WebSocket.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp
index d0be6e1778..04b28798ae 100644
--- a/dom/websocket/WebSocket.cpp
+++ b/dom/websocket/WebSocket.cpp
@@ -1612,6 +1612,19 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
nsresult rv = mWebSocket->CheckCurrentGlobalCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
+ // Assign the sub protocol list and scan it for illegal values
+ for (uint32_t index = 0; index < aProtocolArray.Length(); ++index) {
+ if (!WebSocket::IsValidProtocolString(aProtocolArray[index])) {
+ return NS_ERROR_DOM_SYNTAX_ERR;
+ }
+
+ if (!mRequestedProtocolList.IsEmpty()) {
+ mRequestedProtocolList.AppendLiteral(", ");
+ }
+
+ AppendUTF16toUTF8(aProtocolArray[index], mRequestedProtocolList);
+ }
+
// Shut down websocket if window is frozen or destroyed (only needed for
// "ghost" websockets--see bug 696085)
RefPtr<WebSocketImplProxy> proxy;
@@ -1795,19 +1808,6 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
}
}
- // Assign the sub protocol list and scan it for illegal values
- for (uint32_t index = 0; index < aProtocolArray.Length(); ++index) {
- if (!WebSocket::IsValidProtocolString(aProtocolArray[index])) {
- return NS_ERROR_DOM_SYNTAX_ERR;
- }
-
- if (!mRequestedProtocolList.IsEmpty()) {
- mRequestedProtocolList.AppendLiteral(", ");
- }
-
- AppendUTF16toUTF8(aProtocolArray[index], mRequestedProtocolList);
- }
-
if (mIsMainThread) {
mImplProxy = std::move(proxy);
}
@@ -2639,8 +2639,7 @@ namespace {
class CancelRunnable final : public MainThreadWorkerRunnable {
public:
CancelRunnable(ThreadSafeWorkerRef* aWorkerRef, WebSocketImpl* aImpl)
- : MainThreadWorkerRunnable(aWorkerRef->Private(), "CancelRunnable"),
- mImpl(aImpl) {}
+ : MainThreadWorkerRunnable("CancelRunnable"), mImpl(aImpl) {}
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override {
aWorkerPrivate->AssertIsOnWorkerThread();
@@ -2675,7 +2674,7 @@ WebSocketImpl::Cancel(nsresult aStatus) {
if (!mIsMainThread) {
MOZ_ASSERT(mWorkerRef);
RefPtr<CancelRunnable> runnable = new CancelRunnable(mWorkerRef, this);
- if (!runnable->Dispatch()) {
+ if (!runnable->Dispatch(mWorkerRef->Private())) {
return NS_ERROR_FAILURE;
}
@@ -2785,15 +2784,14 @@ WebSocketImpl::SetTRRMode(nsIRequest::TRRMode aTRRMode) {
namespace {
-class WorkerRunnableDispatcher final : public WorkerRunnable {
+class WorkerRunnableDispatcher final : public WorkerThreadRunnable {
RefPtr<WebSocketImpl> mWebSocketImpl;
public:
WorkerRunnableDispatcher(WebSocketImpl* aImpl,
ThreadSafeWorkerRef* aWorkerRef,
already_AddRefed<nsIRunnable> aEvent)
- : WorkerRunnable(aWorkerRef->Private(), "WorkerRunnableDispatcher",
- WorkerThread),
+ : WorkerThreadRunnable("WorkerRunnableDispatcher"),
mWebSocketImpl(aImpl),
mEvent(std::move(aEvent)) {}
@@ -2861,7 +2859,7 @@ WebSocketImpl::Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags) {
RefPtr<WorkerRunnableDispatcher> event =
new WorkerRunnableDispatcher(this, mWorkerRef, event_ref.forget());
- if (!event->Dispatch()) {
+ if (!event->Dispatch(mWorkerRef->Private())) {
return NS_ERROR_FAILURE;
}