rename from dom/base/nsInProcessTabChildGlobal.cpp
rename to dom/base/InProcessTabChildMessageManager.cpp
--- a/dom/base/nsInProcessTabChildGlobal.cpp
+++ b/dom/base/InProcessTabChildMessageManager.cpp
@@ -1,15 +1,15 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "nsInProcessTabChildGlobal.h"
+#include "InProcessTabChildMessageManager.h"
#include "nsContentUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsComponentManagerUtils.h"
#include "nsFrameLoader.h"
#include "xpcpublic.h"
@@ -20,23 +20,23 @@
#include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ScriptLoader.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
bool
-nsInProcessTabChildGlobal::DoSendBlockingMessage(JSContext* aCx,
- const nsAString& aMessage,
- StructuredCloneData& aData,
- JS::Handle<JSObject *> aCpows,
- nsIPrincipal* aPrincipal,
- nsTArray<StructuredCloneData>* aRetVal,
- bool aIsSync)
+InProcessTabChildMessageManager::DoSendBlockingMessage(JSContext* aCx,
+ const nsAString& aMessage,
+ StructuredCloneData& aData,
+ JS::Handle<JSObject *> aCpows,
+ nsIPrincipal* aPrincipal,
+ nsTArray<StructuredCloneData>* aRetVal,
+ bool aIsSync)
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
queue->Flush();
if (mChromeMessageManager) {
SameProcessCpowHolder cpows(JS::RootingContext::get(aCx), aCpows);
RefPtr<nsFrameMessageManager> mm = mChromeMessageManager;
RefPtr<nsFrameLoader> fl = GetFrameLoader();
@@ -47,54 +47,54 @@ nsInProcessTabChildGlobal::DoSendBlockin
}
class nsAsyncMessageToParent : public nsSameProcessAsyncMessageBase,
public SameProcessMessageQueue::Runnable
{
public:
nsAsyncMessageToParent(JS::RootingContext* aRootingCx,
JS::Handle<JSObject*> aCpows,
- nsInProcessTabChildGlobal* aTabChild)
+ InProcessTabChildMessageManager* aTabChild)
: nsSameProcessAsyncMessageBase(aRootingCx, aCpows)
, mTabChild(aTabChild)
{ }
virtual nsresult HandleMessage() override
{
RefPtr<nsFrameLoader> fl = mTabChild->GetFrameLoader();
ReceiveMessage(mTabChild->mOwner, fl, mTabChild->mChromeMessageManager);
return NS_OK;
}
- RefPtr<nsInProcessTabChildGlobal> mTabChild;
+ RefPtr<InProcessTabChildMessageManager> mTabChild;
};
nsresult
-nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
- const nsAString& aMessage,
- StructuredCloneData& aData,
- JS::Handle<JSObject *> aCpows,
- nsIPrincipal* aPrincipal)
+InProcessTabChildMessageManager::DoSendAsyncMessage(JSContext* aCx,
+ const nsAString& aMessage,
+ StructuredCloneData& aData,
+ JS::Handle<JSObject *> aCpows,
+ nsIPrincipal* aPrincipal)
{
SameProcessMessageQueue* queue = SameProcessMessageQueue::Get();
JS::RootingContext* rcx = JS::RootingContext::get(aCx);
RefPtr<nsAsyncMessageToParent> ev =
new nsAsyncMessageToParent(rcx, aCpows, this);
nsresult rv = ev->Init(aMessage, aData, aPrincipal);
if (NS_FAILED(rv)) {
return rv;
}
queue->Push(ev);
return NS_OK;
}
-nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
- nsIContent* aOwner,
- nsFrameMessageManager* aChrome)
+InProcessTabChildMessageManager::InProcessTabChildMessageManager(nsIDocShell* aShell,
+ nsIContent* aOwner,
+ nsFrameMessageManager* aChrome)
: ContentFrameMessageManager(new nsFrameMessageManager(this)),
mDocShell(aShell), mLoadingScript(false),
mPreventEventsEscaping(false),
mOwner(aOwner), mChromeMessageManager(aChrome)
{
mozilla::HoldJSObjects(this);
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
@@ -103,123 +103,123 @@ nsInProcessTabChildGlobal::nsInProcessTa
if (browserFrame) {
mIsBrowserFrame = browserFrame->GetReallyIsBrowser();
}
else {
mIsBrowserFrame = false;
}
}
-nsInProcessTabChildGlobal::~nsInProcessTabChildGlobal()
+InProcessTabChildMessageManager::~InProcessTabChildMessageManager()
{
mAnonymousGlobalScopes.Clear();
mozilla::DropJSObjects(this);
}
// This method isn't automatically forwarded safely because it's notxpcom, so
// the IDL binding doesn't know what value to return.
void
-nsInProcessTabChildGlobal::MarkForCC()
+InProcessTabChildMessageManager::MarkForCC()
{
MarkScopesForCC();
MessageManagerGlobal::MarkForCC();
}
bool
-nsInProcessTabChildGlobal::Init()
+InProcessTabChildMessageManager::Init()
{
// If you change this, please change GetCompartmentName() in XPCJSContext.cpp
// accordingly.
nsAutoCString id;
id.AssignLiteral("inProcessTabChildGlobal");
nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
if (uri) {
nsAutoCString u;
nsresult rv = uri->GetSpec(u);
NS_ENSURE_SUCCESS(rv, false);
id.AppendLiteral("?ownedBy=");
id.Append(u);
}
return InitChildGlobalInternal(id);
}
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsInProcessTabChildGlobal)
+NS_IMPL_CYCLE_COLLECTION_CLASS(InProcessTabChildMessageManager)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(InProcessTabChildMessageManager,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocShell)
tmp->TraverseHostObjectURIs(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(InProcessTabChildMessageManager,
DOMEventTargetHelper)
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
NS_IMPL_CYCLE_COLLECTION_TRACE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal,
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(InProcessTabChildMessageManager,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocShell)
tmp->nsMessageManagerScriptExecutor::Unlink();
tmp->UnlinkHostObjectURIs();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InProcessTabChildMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
+NS_IMPL_ADDREF_INHERITED(InProcessTabChildMessageManager, DOMEventTargetHelper)
+NS_IMPL_RELEASE_INHERITED(InProcessTabChildMessageManager, DOMEventTargetHelper)
bool
-nsInProcessTabChildGlobal::WrapGlobalObject(JSContext* aCx,
- JS::RealmOptions& aOptions,
- JS::MutableHandle<JSObject*> aReflector)
+InProcessTabChildMessageManager::WrapGlobalObject(JSContext* aCx,
+ JS::RealmOptions& aOptions,
+ JS::MutableHandle<JSObject*> aReflector)
{
bool ok = ContentFrameMessageManager_Binding::Wrap(aCx, this, this, aOptions,
nsJSPrincipals::get(mPrincipal),
true, aReflector);
if (ok) {
// Since we can't rewrap we have to preserve the global's wrapper here.
PreserveWrapper(ToSupports(this));
}
return ok;
}
void
-nsInProcessTabChildGlobal::CacheFrameLoader(nsFrameLoader* aFrameLoader)
+InProcessTabChildMessageManager::CacheFrameLoader(nsFrameLoader* aFrameLoader)
{
mFrameLoader = aFrameLoader;
}
already_AddRefed<nsPIDOMWindowOuter>
-nsInProcessTabChildGlobal::GetContent(ErrorResult& aError)
+InProcessTabChildMessageManager::GetContent(ErrorResult& aError)
{
nsCOMPtr<nsPIDOMWindowOuter> content;
if (mDocShell) {
content = mDocShell->GetWindow();
}
return content.forget();
}
already_AddRefed<nsIEventTarget>
-nsInProcessTabChildGlobal::GetTabEventTarget()
+InProcessTabChildMessageManager::GetTabEventTarget()
{
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
return target.forget();
}
uint64_t
-nsInProcessTabChildGlobal::ChromeOuterWindowID()
+InProcessTabChildMessageManager::ChromeOuterWindowID()
{
if (!mDocShell) {
return 0;
}
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeItem> root;
nsresult rv = item->GetRootTreeItem(getter_AddRefs(root));
@@ -231,75 +231,75 @@ nsInProcessTabChildGlobal::ChromeOuterWi
if (!topWin) {
return 0;
}
return topWin->WindowID();
}
void
-nsInProcessTabChildGlobal::FireUnloadEvent()
+InProcessTabChildMessageManager::FireUnloadEvent()
{
// We're called from nsDocument::MaybeInitializeFinalizeFrameLoaders, so it
// should be safe to run script.
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
// Don't let the unload event propagate to chrome event handlers.
mPreventEventsEscaping = true;
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
// Allow events fired during docshell destruction (pagehide, unload) to
// propagate to the <browser> element since chrome code depends on this.
mPreventEventsEscaping = false;
}
void
-nsInProcessTabChildGlobal::DisconnectEventListeners()
+InProcessTabChildMessageManager::DisconnectEventListeners()
{
if (mDocShell) {
if (nsCOMPtr<nsPIDOMWindowOuter> win = mDocShell->GetWindow()) {
win->SetChromeEventHandler(win->GetChromeEventHandler());
}
}
if (mListenerManager) {
mListenerManager->Disconnect();
}
mDocShell = nullptr;
}
void
-nsInProcessTabChildGlobal::Disconnect()
+InProcessTabChildMessageManager::Disconnect()
{
mChromeMessageManager = nullptr;
mOwner = nullptr;
if (mMessageManager) {
static_cast<nsFrameMessageManager*>(mMessageManager.get())->Disconnect();
mMessageManager = nullptr;
}
}
NS_IMETHODIMP_(nsIContent *)
-nsInProcessTabChildGlobal::GetOwnerContent()
+InProcessTabChildMessageManager::GetOwnerContent()
{
return mOwner;
}
void
-nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
+InProcessTabChildMessageManager::GetEventTargetParent(EventChainPreVisitor& aVisitor)
{
aVisitor.mForceContentDispatch = true;
aVisitor.mCanHandle = true;
#ifdef DEBUG
if (mOwner) {
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
RefPtr<nsFrameLoader> fl = owner->GetFrameLoader();
if (fl) {
- NS_ASSERTION(this == fl->GetTabChildGlobal(),
+ NS_ASSERTION(this == fl->GetTabChildMessageManager(),
"Wrong event target!");
NS_ASSERTION(fl->mMessageManager == mChromeMessageManager,
"Wrong message manager!");
}
}
#endif
if (mPreventEventsEscaping) {
@@ -319,52 +319,52 @@ nsInProcessTabChildGlobal::GetEventTarge
} else {
aVisitor.SetParentTarget(mOwner, false);
}
}
class nsAsyncScriptLoad : public Runnable
{
public:
- nsAsyncScriptLoad(nsInProcessTabChildGlobal* aTabChild,
+ nsAsyncScriptLoad(InProcessTabChildMessageManager* aTabChild,
const nsAString& aURL,
bool aRunInGlobalScope)
: mozilla::Runnable("nsAsyncScriptLoad")
, mTabChild(aTabChild)
, mURL(aURL)
, mRunInGlobalScope(aRunInGlobalScope)
{
}
NS_IMETHOD Run() override
{
mTabChild->LoadFrameScript(mURL, mRunInGlobalScope);
return NS_OK;
}
- RefPtr<nsInProcessTabChildGlobal> mTabChild;
+ RefPtr<InProcessTabChildMessageManager> mTabChild;
nsString mURL;
bool mRunInGlobalScope;
};
void
-nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope)
+InProcessTabChildMessageManager::LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope)
{
if (!nsContentUtils::IsSafeToRunScript()) {
nsContentUtils::AddScriptRunner(new nsAsyncScriptLoad(this, aURL, aRunInGlobalScope));
return;
}
bool tmp = mLoadingScript;
mLoadingScript = true;
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
LoadScriptInternal(global, aURL, aRunInGlobalScope);
mLoadingScript = tmp;
}
already_AddRefed<nsFrameLoader>
-nsInProcessTabChildGlobal::GetFrameLoader()
+InProcessTabChildMessageManager::GetFrameLoader()
{
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
RefPtr<nsFrameLoader> fl = owner ? owner->GetFrameLoader() : nullptr;
if (!fl) {
fl = mFrameLoader;
}
return fl.forget();
}
rename from dom/base/nsInProcessTabChildGlobal.h
rename to dom/base/InProcessTabChildMessageManager.h
--- a/dom/base/nsInProcessTabChildGlobal.h
+++ b/dom/base/InProcessTabChildMessageManager.h
@@ -21,66 +21,73 @@
#include "nsCOMArray.h"
#include "nsIRunnable.h"
#include "nsIGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsWeakReference.h"
namespace mozilla {
class EventChainPreVisitor;
-} // namespace mozilla
+
+namespace dom {
-class nsInProcessTabChildGlobal final : public mozilla::dom::ContentFrameMessageManager,
- public nsMessageManagerScriptExecutor,
- public nsIInProcessContentFrameMessageManager,
- public nsIGlobalObject,
- public nsIScriptObjectPrincipal,
- public nsSupportsWeakReference,
- public mozilla::dom::ipc::MessageManagerCallback
+/**
+ * This class implements a ContentFrameMessageManager for use by frame loaders
+ * in the parent process. It is bound to a DocShell rather than a TabChild, and
+ * does not use any IPC infrastructure for its message passing.
+ */
+
+class InProcessTabChildMessageManager final : public ContentFrameMessageManager,
+ public nsMessageManagerScriptExecutor,
+ public nsIInProcessContentFrameMessageManager,
+ public nsIGlobalObject,
+ public nsIScriptObjectPrincipal,
+ public nsSupportsWeakReference,
+ public mozilla::dom::ipc::MessageManagerCallback
{
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
private:
- nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
- nsFrameMessageManager* aChrome);
+ InProcessTabChildMessageManager(nsIDocShell* aShell, nsIContent* aOwner,
+ nsFrameMessageManager* aChrome);
bool Init();
public:
- static already_AddRefed<nsInProcessTabChildGlobal> Create(nsIDocShell* aShell,
- nsIContent* aOwner,
- nsFrameMessageManager* aChrome)
+ static already_AddRefed<InProcessTabChildMessageManager> Create(nsIDocShell* aShell,
+ nsIContent* aOwner,
+ nsFrameMessageManager* aChrome)
{
- RefPtr<nsInProcessTabChildGlobal> global =
- new nsInProcessTabChildGlobal(aShell, aOwner, aChrome);
+ RefPtr<InProcessTabChildMessageManager> global =
+ new InProcessTabChildMessageManager(aShell, aOwner, aChrome);
NS_ENSURE_TRUE(global->Init(), nullptr);
return global.forget();
}
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
- mozilla::DOMEventTargetHelper)
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(InProcessTabChildMessageManager,
+ DOMEventTargetHelper)
void MarkForCC();
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override
{
MOZ_CRASH("We should never get here!");
}
virtual bool WrapGlobalObject(JSContext* aCx,
JS::RealmOptions& aOptions,
JS::MutableHandle<JSObject*> aReflector) override;
virtual already_AddRefed<nsPIDOMWindowOuter>
- GetContent(mozilla::ErrorResult& aError) override;
+ GetContent(ErrorResult& aError) override;
virtual already_AddRefed<nsIDocShell>
- GetDocShell(mozilla::ErrorResult& aError) override
+ GetDocShell(ErrorResult& aError) override
{
nsCOMPtr<nsIDocShell> docShell(mDocShell);
return docShell.forget();
}
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
virtual uint64_t ChromeOuterWindowID() override;
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
@@ -100,17 +107,17 @@ public:
nsTArray<StructuredCloneData>* aRetVal,
bool aIsSync) override;
virtual nsresult DoSendAsyncMessage(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneData& aData,
JS::Handle<JSObject *> aCpows,
nsIPrincipal* aPrincipal) override;
- void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
+ void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
void FireUnloadEvent();
void DisconnectEventListeners();
void Disconnect();
void SendMessageToParent(const nsString& aMessage, bool aSync,
const nsString& aJSON,
@@ -133,17 +140,17 @@ public:
virtual JSObject* GetGlobalJSObject() override
{
return GetWrapper();
}
already_AddRefed<nsFrameLoader> GetFrameLoader();
protected:
- virtual ~nsInProcessTabChildGlobal();
+ virtual ~InProcessTabChildMessageManager();
nsCOMPtr<nsIDocShell> mDocShell;
bool mLoadingScript;
// Is this the message manager for an in-process <iframe mozbrowser>? This
// affects where events get sent, so it affects GetEventTargetParent.
bool mIsBrowserFrame;
bool mPreventEventsEscaping;
@@ -152,9 +159,12 @@ protected:
// teardown. This allows us to dispatch message manager messages during this
// time.
RefPtr<nsFrameLoader> mFrameLoader;
public:
nsIContent* mOwner;
nsFrameMessageManager* mChromeMessageManager;
};
+} // namespace dom
+} // namespace mozilla
+
#endif
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -273,16 +273,17 @@ UNIFIED_SOURCES += [
'FormData.cpp',
'FragmentOrElement.cpp',
'GeneratedImageContent.cpp',
'IdleDeadline.cpp',
'IdleRequest.cpp',
'IDTracker.cpp',
'ImageEncoder.cpp',
'ImageTracker.cpp',
+ 'InProcessTabChildMessageManager.cpp',
'IntlUtils.cpp',
'Link.cpp',
'Location.cpp',
'MessageBroadcaster.cpp',
'MessageListenerManager.cpp',
'MessageManagerGlobal.cpp',
'MessageSender.cpp',
'MozQueryInterface.cpp',
@@ -313,17 +314,16 @@ UNIFIED_SOURCES += [
'nsDOMWindowList.cpp',
'nsFocusManager.cpp',
'nsFrameLoader.cpp',
'nsGlobalWindowCommands.cpp',
'nsHistory.cpp',
'nsHTMLContentSerializer.cpp',
'nsIGlobalObject.cpp',
'nsINode.cpp',
- 'nsInProcessTabChildGlobal.cpp',
'nsJSEnvironment.cpp',
'nsJSTimeoutHandler.cpp',
'nsJSUtils.cpp',
'nsLineBreaker.cpp',
'nsMappedAttributeElement.cpp',
'nsMappedAttributes.cpp',
'nsMimeTypeArray.cpp',
'nsNameSpaceManager.cpp',
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -6,31 +6,31 @@
#include "nsCCUncollectableMarker.h"
#include "nsIObserverService.h"
#include "nsIDocShell.h"
#include "nsServiceManagerUtils.h"
#include "nsIContentViewer.h"
#include "nsIDocument.h"
#include "XULDocument.h"
+#include "InProcessTabChildMessageManager.h"
#include "nsIWindowMediator.h"
#include "nsPIDOMWindow.h"
#include "nsIWebNavigation.h"
#include "nsISHistory.h"
#include "nsISHEntry.h"
#include "nsISHContainer.h"
#include "nsIWindowWatcher.h"
#include "mozilla/Services.h"
#include "nsIXULWindow.h"
#include "nsIAppShellService.h"
#include "nsAppShellCID.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "nsJSEnvironment.h"
-#include "nsInProcessTabChildGlobal.h"
#include "nsFrameLoader.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/ContentProcessMessageManager.h"
#include "mozilla/dom/Element.h"
@@ -115,17 +115,17 @@ MarkChildMessageManagers(MessageBroadcas
tabMM->MarkForCC();
//XXX hack warning, but works, since we know that
// callback is frameloader.
mozilla::dom::ipc::MessageManagerCallback* cb = tabMM->GetCallback();
if (cb) {
nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
- nsInProcessTabChildGlobal* et = fl->GetTabChildGlobal();
+ InProcessTabChildMessageManager* et = fl->GetTabChildMessageManager();
if (!et) {
continue;
}
et->MarkForCC();
EventListenerManager* elm = et->GetExistingListenerManager();
if (elm) {
elm->MarkForCC();
}
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -116,17 +116,16 @@
#include "nsFocusManager.h"
#include "nsGenericHTMLElement.h"
#include "nsGenericHTMLFrameElement.h"
#include "nsGkAtoms.h"
#include "nsHtml5Module.h"
#include "nsHtml5StringParser.h"
#include "nsHTMLDocument.h"
#include "nsHTMLTags.h"
-#include "nsInProcessTabChildGlobal.h"
#include "nsIAddonPolicyService.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsICategoryManager.h"
#include "nsIChannelEventSink.h"
#include "nsICharsetDetectionObserver.h"
#include "nsIChromeRegistry.h"
#include "nsIConsoleService.h"
@@ -210,16 +209,17 @@
#include "nsViewManager.h"
#include "nsViewportInfo.h"
#include "nsWidgetsCID.h"
#include "nsIWindowProvider.h"
#include "nsWrapperCacheInlines.h"
#include "nsXULPopupManager.h"
#include "xpcprivate.h" // nsXPConnect
#include "HTMLSplitOnSpacesTokenizer.h"
+#include "InProcessTabChildMessageManager.h"
#include "nsContentTypeParser.h"
#include "nsICookiePermission.h"
#include "mozIThirdPartyUtil.h"
#include "nsICookieService.h"
#include "mozilla/EnumSet.h"
#include "mozilla/BloomFilter.h"
#include "TabChild.h"
#include "mozilla/dom/DocGroup.h"
@@ -11096,17 +11096,17 @@ nsContentUtils::TryGetTabChildGlobal(nsI
return nullptr;
}
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return nullptr;
}
- RefPtr<ContentFrameMessageManager> manager = frameLoader->GetTabChildGlobal();
+ RefPtr<ContentFrameMessageManager> manager = frameLoader->GetTabChildMessageManager();
return manager.forget();
}
/* static */ uint32_t
nsContentUtils::InnerOrOuterWindowCreated()
{
MOZ_ASSERT(NS_IsMainThread());
++sInnerOrOuterWindowCount;
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -59,17 +59,17 @@
#include "nsNetUtil.h"
#include "nsGkAtoms.h"
#include "nsNameSpaceManager.h"
#include "nsThreadUtils.h"
#include "nsIDOMChromeWindow.h"
-#include "nsInProcessTabChildGlobal.h"
+#include "InProcessTabChildMessageManager.h"
#include "Layers.h"
#include "ClientLayerManager.h"
#include "ContentParent.h"
#include "TabParent.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/BasePrincipal.h"
@@ -1596,22 +1596,22 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
ourWindow->SetFrameElementInternal(otherFrameElement);
otherWindow->SetFrameElementInternal(ourFrameElement);
RefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
// Swap pointers in child message managers.
if (mChildMessageManager) {
- nsInProcessTabChildGlobal* tabChild = mChildMessageManager;
+ InProcessTabChildMessageManager* tabChild = mChildMessageManager;
tabChild->SetOwner(otherContent);
tabChild->SetChromeMessageManager(otherMessageManager);
}
if (aOther->mChildMessageManager) {
- nsInProcessTabChildGlobal* otherTabChild = aOther->mChildMessageManager;
+ InProcessTabChildMessageManager* otherTabChild = aOther->mChildMessageManager;
otherTabChild->SetOwner(ourContent);
otherTabChild->SetChromeMessageManager(ourMessageManager);
}
// Swap and setup things in parent message managers.
if (mMessageManager) {
mMessageManager->SetCallback(aOther);
}
if (aOther->mMessageManager) {
@@ -2815,17 +2815,17 @@ nsFrameLoader::CreateStaticClone(nsFrame
bool
nsFrameLoader::DoLoadMessageManagerScript(const nsAString& aURL, bool aRunInGlobalScope)
{
auto* tabParent = TabParent::GetFrom(GetRemoteBrowser());
if (tabParent) {
return tabParent->SendLoadRemoteScript(nsString(aURL), aRunInGlobalScope);
}
- RefPtr<nsInProcessTabChildGlobal> tabChild = GetTabChildGlobal();
+ RefPtr<InProcessTabChildMessageManager> tabChild = GetTabChildMessageManager();
if (tabChild) {
tabChild->LoadFrameScript(aURL, aRunInGlobalScope);
}
return true;
}
class nsAsyncMessageToChild : public nsSameProcessAsyncMessageBase,
public Runnable
@@ -2837,17 +2837,17 @@ public:
: nsSameProcessAsyncMessageBase(aRootingCx, aCpows)
, mozilla::Runnable("nsAsyncMessageToChild")
, mFrameLoader(aFrameLoader)
{
}
NS_IMETHOD Run() override
{
- nsInProcessTabChildGlobal* tabChild = mFrameLoader->mChildMessageManager;
+ InProcessTabChildMessageManager* tabChild = mFrameLoader->mChildMessageManager;
// Since bug 1126089, messages can arrive even when the docShell is destroyed.
// Here we make sure that those messages are not delivered.
if (tabChild && tabChild->GetInnerManager() && mFrameLoader->GetExistingDocShell()) {
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetWrapper());
ReceiveMessage(static_cast<EventTarget*>(tabChild), mFrameLoader,
tabChild->GetInnerManager());
}
return NS_OK;
@@ -2954,17 +2954,17 @@ nsFrameLoader::EnsureMessageManager()
return rv;
}
NS_ASSERTION(mDocShell,
"MaybeCreateDocShell succeeded, but null mDocShell");
if (!mDocShell) {
return NS_ERROR_FAILURE;
}
mChildMessageManager =
- nsInProcessTabChildGlobal::Create(mDocShell, mOwnerContent, mMessageManager);
+ InProcessTabChildMessageManager::Create(mDocShell, mOwnerContent, mMessageManager);
NS_ENSURE_TRUE(mChildMessageManager, NS_ERROR_UNEXPECTED);
}
return NS_OK;
}
nsresult
nsFrameLoader::ReallyLoadFrameScripts()
{
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -27,17 +27,16 @@
#include "nsStubMutationObserver.h"
#include "Units.h"
#include "nsIFrame.h"
#include "nsPluginTags.h"
class nsIURI;
class nsSubDocumentFrame;
class nsView;
-class nsInProcessTabChildGlobal;
class AutoResetInShow;
class AutoResetInFrameSwap;
class nsITabParent;
class nsIDocShellTreeItem;
class nsIDocShellTreeOwner;
class nsILoadContext;
class nsIMessageSender;
class nsIPrintSettings;
@@ -46,16 +45,17 @@ class nsIWebProgressListener;
namespace mozilla {
class OriginAttributes;
namespace dom {
class ChromeMessageSender;
class ContentParent;
+class InProcessTabChildMessageManager;
class MessageSender;
class PBrowserParent;
class ProcessMessageManager;
class Promise;
class TabParent;
class MutableTabContext;
namespace ipc {
@@ -101,17 +101,17 @@ public:
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
nsresult CheckForRecursiveLoad(nsIURI* aURI);
nsresult ReallyStartLoading();
void StartDestroy();
void DestroyDocShell();
void DestroyComplete();
nsIDocShell* GetExistingDocShell() { return mDocShell; }
- nsInProcessTabChildGlobal* GetTabChildGlobal() const
+ mozilla::dom::InProcessTabChildMessageManager* GetTabChildMessageManager() const
{
return mChildMessageManager;
}
nsresult CreateStaticClone(nsFrameLoader* aDest);
nsresult UpdatePositionAndSize(nsSubDocumentFrame *aIFrame);
// WebIDL methods
@@ -336,17 +336,17 @@ public:
// Properly retrieves documentSize of any subdocument type.
nsresult GetWindowDimensions(nsIntRect& aRect);
virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager() const override;
// public because a callback needs these.
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
- RefPtr<nsInProcessTabChildGlobal> mChildMessageManager;
+ RefPtr<mozilla::dom::InProcessTabChildMessageManager> mChildMessageManager;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
private:
nsFrameLoader(mozilla::dom::Element* aOwner,
nsPIDOMWindowOuter* aOpener,
bool aNetworkCreated,
int32_t aJSPluginID);
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -12,21 +12,21 @@
#include "js/Id.h" // must come before js/RootingAPI.h
#include "js/Value.h" // must come before js/RootingAPI.h
#include "js/RootingAPI.h"
#include "js/TracingAPI.h"
namespace mozilla {
namespace dom {
class ContentProcessMessageManager;
+class InProcessTabChildMessageManager;
class TabChildGlobal;
} // namespace dom
} // namespace mozilla
class SandboxPrivate;
-class nsInProcessTabChildGlobal;
class nsWindowRoot;
#define NS_WRAPPERCACHE_IID \
{ 0x6f3179a1, 0x36f7, 0x4a5c, \
{ 0x8c, 0xf1, 0xad, 0xc8, 0x7c, 0xde, 0x3e, 0x87 } }
// There are two sets of flags used by DOM nodes. One comes from reusing the
// remaining bits of the inherited nsWrapperCache flags (mFlags), and another is
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -198,19 +198,17 @@ CallbackObject::CallSetup::CallSetup(Cal
globalObject = win;
} else {
// No DOM Window. Store the global.
globalObject = xpc::NativeGlobal(realCallback);
MOZ_ASSERT(globalObject);
}
}
- // Bail out if there's no useful global. This seems to happen intermittently
- // on gaia-ui tests, probably because nsInProcessTabChildGlobal is returning
- // null in some kind of teardown state.
+ // Bail out if there's no useful global.
if (!globalObject->GetGlobalJSObject()) {
aRv.ThrowDOMException(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
NS_LITERAL_CSTRING("Refusing to execute function from global which is "
"being torn down."));
return;
}
mAutoEntryScript.emplace(globalObject, aExecutionReason, mIsMainThread);