forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1487249 - Part 3: Add the WindowGlobal actor representing a singl…
…e window global, r=bzbarsky This actor can be used for communicating with individual frames, without depending on walking the tree in the content process. This is not yet complete. No tests have been written for it, the WindowGlobalParent objects need to be exposed to chrome JS, and a form of JS actors should be installed under them. In addition, BrowsingContextChrome objects should be updated to allow access to the current WindowGlobalParent in that context. Differential Revision: https://phabricator.services.mozilla.com/D4623
- Loading branch information
Showing
22 changed files
with
573 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ | ||
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ | ||
/* 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 protocol PBrowser; | ||
include protocol PInProcess; | ||
|
||
include DOMTypes; | ||
|
||
using refcounted class nsIURI from "mozilla/ipc/URIUtils.h"; | ||
|
||
namespace mozilla { | ||
namespace dom { | ||
|
||
/** | ||
* A PWindowGlobal actor has a lifetime matching that of a single Window Global, | ||
* specifically a |nsGlobalWindowInner|. These actors will form a parent/child | ||
* link either between the chrome/content process, or will be in-process, for | ||
* documents which are loaded in the chrome process. | ||
*/ | ||
async protocol PWindowGlobal | ||
{ | ||
manager PBrowser or PInProcess; | ||
|
||
parent: | ||
/// Update the URI of the document in this WindowGlobal. | ||
async UpdateDocumentURI(nsIURI aUri); | ||
|
||
async __delete__(); | ||
}; | ||
|
||
} // namespace dom | ||
} // namespace mozilla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ | ||
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ | ||
/* 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 "mozilla/dom/WindowGlobalChild.h" | ||
#include "mozilla/ipc/InProcessChild.h" | ||
#include "mozilla/dom/BrowsingContext.h" | ||
|
||
namespace mozilla { | ||
namespace dom { | ||
|
||
WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBrowsingContext) | ||
: mWindowGlobal(aWindow) | ||
, mBrowsingContext(aBrowsingContext) | ||
, mIPCClosed(false) | ||
{ | ||
} | ||
|
||
already_AddRefed<WindowGlobalChild> | ||
WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) | ||
{ | ||
nsCOMPtr<nsIPrincipal> principal = aWindow->GetPrincipal(); | ||
MOZ_ASSERT(principal); | ||
|
||
RefPtr<nsDocShell> docshell = nsDocShell::Cast(aWindow->GetDocShell()); | ||
MOZ_ASSERT(docshell); | ||
|
||
// Initalize our WindowGlobalChild object. | ||
RefPtr<dom::BrowsingContext> bc = docshell->GetBrowsingContext(); | ||
RefPtr<WindowGlobalChild> wgc = new WindowGlobalChild(aWindow, bc); | ||
|
||
WindowGlobalInit init(principal, BrowsingContextId(wgc->BrowsingContext()->Id())); | ||
|
||
// Send the link constructor over PInProcessChild or PBrowser. | ||
if (XRE_IsParentProcess()) { | ||
InProcessChild* ipc = InProcessChild::Singleton(); | ||
if (!ipc) { | ||
return nullptr; | ||
} | ||
|
||
// Note: ref is released in DeallocPWindowGlobalChild | ||
ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); | ||
} else { | ||
RefPtr<TabChild> tabChild = TabChild::GetFrom(static_cast<mozIDOMWindow*>(aWindow)); | ||
MOZ_ASSERT(tabChild); | ||
|
||
// Note: ref is released in DeallocPWindowGlobalChild | ||
tabChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); | ||
} | ||
|
||
return wgc.forget(); | ||
} | ||
|
||
already_AddRefed<WindowGlobalParent> | ||
WindowGlobalChild::GetOtherSide() | ||
{ | ||
if (mIPCClosed) { | ||
return nullptr; | ||
} | ||
IProtocol* otherSide = InProcessChild::ParentActorFor(this); | ||
return do_AddRef(static_cast<WindowGlobalParent*>(otherSide)); | ||
} | ||
|
||
void | ||
WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) | ||
{ | ||
mIPCClosed = true; | ||
} | ||
|
||
WindowGlobalChild::~WindowGlobalChild() | ||
{ | ||
} | ||
|
||
NS_IMPL_CYCLE_COLLECTION(WindowGlobalChild, mWindowGlobal, mBrowsingContext) | ||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef) | ||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release) | ||
|
||
} // namespace dom | ||
} // namespace mozilla |
Oops, something went wrong.