mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
backout c42ff6847631 (bug 1250572) for causing aborts during startup
This commit is contained in:
parent
a0b679dacc
commit
123c5edeab
@ -295,7 +295,6 @@ StructuredCloneHolder::Read(nsISupports* aParent,
|
||||
{
|
||||
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
|
||||
mCreationThread == NS_GetCurrentThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
mozilla::AutoRestore<nsISupports*> guard(mParent);
|
||||
mParent = aParent;
|
||||
@ -1045,11 +1044,9 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
|
||||
MOZ_ASSERT(aExtraData < mPortIdentifiers.Length());
|
||||
const MessagePortIdentifier& portIdentifier = mPortIdentifiers[aExtraData];
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<MessagePort> port =
|
||||
MessagePort::Create(global, portIdentifier, rv);
|
||||
MessagePort::Create(mParent, portIdentifier, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -13,14 +13,14 @@
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MessageChannel, mGlobal, mPort1, mPort2)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MessageChannel, mWindow, mPort1, mPort2)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MessageChannel)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MessageChannel)
|
||||
|
||||
@ -29,10 +29,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MessageChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
MessageChannel::MessageChannel(nsIGlobalObject* aGlobal)
|
||||
: mGlobal(aGlobal)
|
||||
MessageChannel::MessageChannel(nsPIDOMWindowInner* aWindow)
|
||||
: mWindow(aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
}
|
||||
|
||||
MessageChannel::~MessageChannel()
|
||||
@ -48,15 +47,14 @@ MessageChannel::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
/* static */ already_AddRefed<MessageChannel>
|
||||
MessageChannel::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
return Constructor(global, aRv);
|
||||
// window can be null in workers.
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
return Constructor(window, aRv);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessageChannel>
|
||||
MessageChannel::Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv)
|
||||
MessageChannel::Constructor(nsPIDOMWindowInner* aWindow, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
nsID portUUID1;
|
||||
aRv = nsContentUtils::GenerateUUIDInPlace(portUUID1);
|
||||
if (aRv.Failed()) {
|
||||
@ -69,14 +67,14 @@ MessageChannel::Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<MessageChannel> channel = new MessageChannel(aGlobal);
|
||||
RefPtr<MessageChannel> channel = new MessageChannel(aWindow);
|
||||
|
||||
channel->mPort1 = MessagePort::Create(aGlobal, portUUID1, portUUID2, aRv);
|
||||
channel->mPort1 = MessagePort::Create(aWindow, portUUID1, portUUID2, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
channel->mPort2 = MessagePort::Create(aGlobal, portUUID2, portUUID1, aRv);
|
||||
channel->mPort2 = MessagePort::Create(aWindow, portUUID2, portUUID1, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -28,10 +28,10 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel)
|
||||
|
||||
nsIGlobalObject*
|
||||
nsPIDOMWindowInner*
|
||||
GetParentObject() const
|
||||
{
|
||||
return mGlobal;
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
@ -41,7 +41,7 @@ public:
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<MessageChannel>
|
||||
Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv);
|
||||
Constructor(nsPIDOMWindowInner* aWindow, ErrorResult& aRv);
|
||||
|
||||
MessagePort*
|
||||
Port1() const
|
||||
@ -56,10 +56,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MessageChannel(nsIGlobalObject* aGlobal);
|
||||
explicit MessageChannel(nsPIDOMWindowInner* aWindow);
|
||||
~MessageChannel();
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||
|
||||
RefPtr<MessagePort> mPort1;
|
||||
RefPtr<MessagePort> mPort2;
|
||||
|
@ -86,8 +86,15 @@ private:
|
||||
nsresult
|
||||
DispatchMessage() const
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = mPort->GetParentObject();
|
||||
MOZ_ASSERT(globalObject);
|
||||
nsCOMPtr<nsIGlobalObject> globalObject;
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
globalObject = do_QueryInterface(mPort->GetParentObject());
|
||||
} else {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
globalObject = workerPrivate->GlobalScope();
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!globalObject || !jsapi.Init(globalObject)) {
|
||||
@ -252,17 +259,20 @@ NS_IMPL_ISUPPORTS(ForceCloseHelper, nsIIPCBackgroundChildCreateCallback)
|
||||
|
||||
} // namespace
|
||||
|
||||
MessagePort::MessagePort(nsIGlobalObject* aGlobal)
|
||||
: DOMEventTargetHelper(aGlobal)
|
||||
, mInnerID(0)
|
||||
MessagePort::MessagePort(nsISupports* aSupports)
|
||||
: mInnerID(0)
|
||||
, mMessageQueueEnabled(false)
|
||||
, mIsKeptAlive(false)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
mIdentifier = new MessagePortIdentifier();
|
||||
mIdentifier->neutered() = true;
|
||||
mIdentifier->sequenceId() = 0;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(aSupports);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return;
|
||||
}
|
||||
BindToOwner(globalObject);
|
||||
}
|
||||
|
||||
MessagePort::~MessagePort()
|
||||
@ -272,25 +282,21 @@ MessagePort::~MessagePort()
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessagePort>
|
||||
MessagePort::Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
|
||||
MessagePort::Create(nsISupports* aSupport, const nsID& aUUID,
|
||||
const nsID& aDestinationUUID, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
|
||||
RefPtr<MessagePort> mp = new MessagePort(aSupport);
|
||||
mp->Initialize(aUUID, aDestinationUUID, 1 /* 0 is an invalid sequence ID */,
|
||||
false /* Neutered */, eStateUnshippedEntangled, aRv);
|
||||
return mp.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<MessagePort>
|
||||
MessagePort::Create(nsIGlobalObject* aGlobal,
|
||||
MessagePort::Create(nsISupports* aSupport,
|
||||
const MessagePortIdentifier& aIdentifier,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
RefPtr<MessagePort> mp = new MessagePort(aGlobal);
|
||||
RefPtr<MessagePort> mp = new MessagePort(aSupport);
|
||||
mp->Initialize(aIdentifier.uuid(), aIdentifier.destinationUuid(),
|
||||
aIdentifier.sequenceId(), aIdentifier.neutered(),
|
||||
eStateEntangling, aRv);
|
||||
|
@ -16,7 +16,7 @@
|
||||
#undef PostMessage
|
||||
#endif
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -45,12 +45,11 @@ public:
|
||||
DOMEventTargetHelper)
|
||||
|
||||
static already_AddRefed<MessagePort>
|
||||
Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
|
||||
Create(nsISupports* aSupport, const nsID& aUUID,
|
||||
const nsID& aDestinationUUID, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<MessagePort>
|
||||
Create(nsIGlobalObject* aGlobal,
|
||||
const MessagePortIdentifier& aIdentifier,
|
||||
Create(nsISupports* aSupport, const MessagePortIdentifier& aIdentifier,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// For IPC.
|
||||
@ -89,7 +88,7 @@ public:
|
||||
void Closed();
|
||||
|
||||
private:
|
||||
explicit MessagePort(nsIGlobalObject* aGlobal);
|
||||
explicit MessagePort(nsISupports* nsISupports);
|
||||
~MessagePort();
|
||||
|
||||
enum State {
|
||||
|
@ -2386,14 +2386,13 @@ RuntimeService::CreateSharedWorkerFromLoadInfo(JSContext* aCx,
|
||||
|
||||
// We don't actually care about this MessageChannel, but we use it to 'steal'
|
||||
// its 2 connected ports.
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window);
|
||||
RefPtr<MessageChannel> channel = MessageChannel::Constructor(global, rv);
|
||||
RefPtr<MessageChannel> channel = MessageChannel::Constructor(window, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
RefPtr<SharedWorker> sharedWorker = new SharedWorker(window, workerPrivate,
|
||||
channel->Port1());
|
||||
channel->Port1());
|
||||
|
||||
if (!workerPrivate->RegisterSharedWorker(aCx, sharedWorker,
|
||||
channel->Port2())) {
|
||||
|
@ -672,8 +672,10 @@ public:
|
||||
DispatchDOMEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
DOMEventTargetHelper* aTarget, bool aIsMainThread)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> parent = do_QueryInterface(aTarget->GetParentObject());
|
||||
MOZ_ASSERT(parent);
|
||||
nsCOMPtr<nsPIDOMWindowInner> parent;
|
||||
if (aIsMainThread) {
|
||||
parent = do_QueryInterface(aTarget->GetParentObject());
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> messageData(aCx);
|
||||
ErrorResult rv;
|
||||
@ -6382,7 +6384,7 @@ WorkerPrivate::ConnectMessagePort(JSContext* aCx,
|
||||
// This MessagePortIdentifier is used to create a new port, still connected
|
||||
// with the other one, but in the worker thread.
|
||||
ErrorResult rv;
|
||||
RefPtr<MessagePort> port = MessagePort::Create(globalScope, aIdentifier, rv);
|
||||
RefPtr<MessagePort> port = MessagePort::Create(nullptr, aIdentifier, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "nsVariant.h"
|
||||
|
||||
#include "RuntimeService.h"
|
||||
#include "WorkerScope.h"
|
||||
#include "WorkerPrivate.h"
|
||||
#include "WorkerRunnable.h"
|
||||
#include "XMLHttpRequestUpload.h"
|
||||
@ -1337,12 +1336,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
|
||||
ErrorResult rv;
|
||||
JS::Rooted<JS::Value> response(aCx);
|
||||
|
||||
GlobalObject globalObj(aCx, aWorkerPrivate->GlobalScope()->GetWrapper());
|
||||
nsCOMPtr<nsIGlobalObject> global =
|
||||
do_QueryInterface(globalObj.GetAsSupports());
|
||||
|
||||
Read(global, aCx, &response, rv);
|
||||
Read(nullptr, aCx, &response, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
rv.SuppressException();
|
||||
return false;
|
||||
@ -1519,18 +1513,8 @@ SendRunnable::MainThreadRun()
|
||||
|
||||
ErrorResult rv;
|
||||
|
||||
JS::Rooted<JSObject*> globalObject(cx, JS::CurrentGlobalOrNull(cx));
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> parent = xpc::NativeGlobal(globalObject);
|
||||
if (NS_WARN_IF(!parent)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> body(cx);
|
||||
Read(parent, cx, &body, rv);
|
||||
Read(nullptr, cx, &body, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user