зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1877744 - Make sure WebSocketImpl::OnStart is called on target thread, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D200368
This commit is contained in:
Родитель
19b287adc9
Коммит
4b94532a31
|
@ -33,6 +33,7 @@
|
|||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsXPCOM.h"
|
||||
|
@ -766,6 +767,15 @@ WebSocketImpl::OnBinaryMessageAvailable(nsISupports* aContext,
|
|||
|
||||
NS_IMETHODIMP
|
||||
WebSocketImpl::OnStart(nsISupports* aContext) {
|
||||
if (!IsTargetThread()) {
|
||||
nsCOMPtr<nsISupports> context = aContext;
|
||||
return Dispatch(NS_NewRunnableFunction("WebSocketImpl::OnStart",
|
||||
[self = RefPtr{this}, context]() {
|
||||
Unused << self->OnStart(context);
|
||||
}),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
AssertIsOnTargetThread();
|
||||
|
||||
if (mDisconnectingOrDisconnected) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче