зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1633379) for windows build bustages on ContentChild.obj. CLOSED TREE
Backed out changeset a26037f3225b (bug 1633379) Backed out changeset efef0b59bcd8 (bug 1633379)
This commit is contained in:
Родитель
fa0431285c
Коммит
4d79f57fed
|
@ -26,7 +26,6 @@
|
|||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/IdleDeadline.h"
|
||||
#include "mozilla/dom/InProcessChild.h"
|
||||
#include "mozilla/dom/JSActorService.h"
|
||||
#include "mozilla/dom/MediaControlUtils.h"
|
||||
#include "mozilla/dom/MediaControlService.h"
|
||||
|
@ -1304,10 +1303,7 @@ void ChromeUtils::GenerateMediaControlKey(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
/* static */
|
||||
nsIDOMProcessChild* ChromeUtils::GetDomProcessChild(const GlobalObject&) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
return InProcessChild::Singleton();
|
||||
}
|
||||
nsIContentChild* ChromeUtils::GetContentChild(const GlobalObject&) {
|
||||
return ContentChild::GetSingleton();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "mozilla/dom/ChromeUtilsBinding.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
|
||||
#include "nsIDOMProcessChild.h"
|
||||
#include "nsIContentChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -218,7 +218,7 @@ class ChromeUtils {
|
|||
static void GenerateMediaControlKey(const GlobalObject& aGlobal,
|
||||
MediaControlKey aKey);
|
||||
|
||||
static nsIDOMProcessChild* GetDomProcessChild(const GlobalObject&);
|
||||
static nsIContentChild* GetContentChild(const GlobalObject&);
|
||||
|
||||
// This function would only be used for testing.
|
||||
static void GetCurrentActiveMediaMetadata(const GlobalObject& aGlobal,
|
||||
|
|
|
@ -1875,8 +1875,8 @@ addExternalIface('nsITreeSelection', nativeType='nsITreeSelection',
|
|||
notflattened=True)
|
||||
addExternalIface('nsISupports', nativeType='nsISupports')
|
||||
addExternalIface('nsIDocShell', nativeType='nsIDocShell', notflattened=True)
|
||||
addExternalIface('nsIDOMProcessChild', nativeType='nsIDOMProcessChild', notflattened=True)
|
||||
addExternalIface('nsIDOMProcessParent', nativeType='nsIDOMProcessParent', notflattened=True)
|
||||
addExternalIface('nsIContentChild', nativeType='nsIContentChild', notflattened=True)
|
||||
addExternalIface('nsIContentParent', nativeType='nsIContentParent', notflattened=True)
|
||||
addExternalIface('nsIReferrerInfo', nativeType='nsIReferrerInfo', notflattened=True)
|
||||
addExternalIface('nsISecureBrowserUI', nativeType='nsISecureBrowserUI', notflattened=True)
|
||||
addExternalIface('nsIWebProgress', nativeType='nsIWebProgress', notflattened=True)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
interface nsIDOMProcessChild;
|
||||
interface nsIContentChild;
|
||||
|
||||
/**
|
||||
* An optimized QueryInterface method, generated by generateQI.
|
||||
|
@ -477,10 +477,10 @@ partial namespace ChromeUtils {
|
|||
void generateMediaControlKey(MediaControlKey aKey);
|
||||
|
||||
/**
|
||||
* nsIDOMProcessChild for the current process.
|
||||
* ContentChild of the current process.
|
||||
*/
|
||||
[ChromeOnly]
|
||||
readonly attribute nsIDOMProcessChild? domProcessChild;
|
||||
readonly attribute nsIContentChild? contentChild;
|
||||
|
||||
// This is used to get the media metadata from the current main controller in
|
||||
// testing.
|
||||
|
|
|
@ -20,7 +20,7 @@ interface JSProcessActorParent {
|
|||
[ChromeOnly]
|
||||
constructor();
|
||||
|
||||
readonly attribute nsIDOMProcessParent manager;
|
||||
readonly attribute nsIContentParent manager;
|
||||
};
|
||||
JSProcessActorParent includes JSActor;
|
||||
|
||||
|
@ -29,7 +29,7 @@ interface JSProcessActorChild {
|
|||
[ChromeOnly]
|
||||
constructor();
|
||||
|
||||
readonly attribute nsIDOMProcessChild manager;
|
||||
readonly attribute nsIContentChild manager;
|
||||
};
|
||||
JSProcessActorChild includes JSActor;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ interface URI;
|
|||
interface nsIDocShell;
|
||||
interface RemoteTab;
|
||||
interface nsITransportSecurityInfo;
|
||||
interface nsIDOMProcessParent;
|
||||
interface nsIContentParent;
|
||||
|
||||
[Exposed=Window, ChromeOnly]
|
||||
interface WindowContext {
|
||||
|
@ -62,10 +62,9 @@ interface WindowGlobalParent : WindowContext {
|
|||
// String containing serialized content blocking log.
|
||||
readonly attribute DOMString contentBlockingLog;
|
||||
|
||||
// DOM Process which this window was loaded in. Will be either InProcessParent
|
||||
// for windows loaded in the parent process, or ContentParent for windows
|
||||
// loaded in the content process.
|
||||
readonly attribute nsIDOMProcessParent? domProcess;
|
||||
// ContentParent of the process this window is loaded in.
|
||||
// Will be `null` for windows loaded in the parent process.
|
||||
readonly attribute nsIContentParent? contentParent;
|
||||
|
||||
static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId);
|
||||
|
||||
|
|
|
@ -583,11 +583,11 @@ Get a JSProcessActor
|
|||
let parentActor = this.browser
|
||||
.browsingContext
|
||||
.currentWindowGlobal
|
||||
.domProcess
|
||||
.contentParent
|
||||
.getActor("TestProcess");
|
||||
|
||||
// get child side actor
|
||||
let childActor = ChromeUtils.domProcessChild
|
||||
let childActor = ChromeUtils.contentChild
|
||||
.getActor("TestProcess");
|
||||
|
||||
And more
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/ExternalHelperAppChild.h"
|
||||
#include "mozilla/dom/GetFilesHelper.h"
|
||||
#include "mozilla/dom/InProcessChild.h"
|
||||
#include "mozilla/dom/IPCBlobInputStreamChild.h"
|
||||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/JSActorService.h"
|
||||
|
@ -79,6 +78,7 @@
|
|||
#include "mozilla/ipc/FileDescriptorSetChild.h"
|
||||
#include "mozilla/ipc/FileDescriptorUtils.h"
|
||||
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
#include "mozilla/ipc/LibrarySandboxPreload.h"
|
||||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "mozilla/ipc/PChildToParentStreamChild.h"
|
||||
|
@ -612,8 +612,8 @@ ContentChild::~ContentChild() {
|
|||
#endif
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(ContentChild)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMProcessChild)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMProcessChild)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentChild)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentChild)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
|
||||
|
@ -4195,24 +4195,58 @@ NS_IMETHODIMP ContentChild::GetActor(const nsACString& aName,
|
|||
IPCResult ContentChild::RecvRawMessage(const JSActorMessageMeta& aMeta,
|
||||
const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack) {
|
||||
RefPtr<JSProcessActorChild> actor;
|
||||
GetActor(aMeta.actorName(), getter_AddRefs(actor));
|
||||
if (actor) {
|
||||
StructuredCloneData data;
|
||||
data.BorrowFromClonedMessageDataForChild(aData);
|
||||
StructuredCloneData stack;
|
||||
stack.BorrowFromClonedMessageDataForChild(aStack);
|
||||
actor->ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||
}
|
||||
StructuredCloneData data;
|
||||
data.BorrowFromClonedMessageDataForChild(aData);
|
||||
StructuredCloneData stack;
|
||||
stack.BorrowFromClonedMessageDataForChild(aStack);
|
||||
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ContentChild::GetCanSend(bool* aCanSend) {
|
||||
*aCanSend = CanSend();
|
||||
return NS_OK;
|
||||
void ContentChild::ReceiveRawMessage(const JSActorMessageMeta& aMeta,
|
||||
StructuredCloneData&& aData,
|
||||
StructuredCloneData&& aStack) {
|
||||
RefPtr<JSProcessActorChild> actor =
|
||||
GetActor(aMeta.actorName(), IgnoreErrors());
|
||||
if (actor) {
|
||||
actor->ReceiveRawMessage(aMeta, std::move(aData), std::move(aStack));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ContentChild*) ContentChild::AsContentChild() { return this; }
|
||||
already_AddRefed<mozilla::dom::JSProcessActorChild> ContentChild::GetActor(
|
||||
const nsACString& aName, ErrorResult& aRv) {
|
||||
if (!CanSend()) {
|
||||
aRv.ThrowInvalidStateError(
|
||||
"Cannot get JSProcessActor, process is shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mProcessActors.Contains(aName)) {
|
||||
return mProcessActors.Get(aName);
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor.
|
||||
JS::RootedObject obj(RootingCx());
|
||||
ConstructActor(aName, &obj, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSProcessActorChild object.
|
||||
RefPtr<JSProcessActorChild> actor;
|
||||
if (NS_FAILED(UNWRAP_OBJECT(JSProcessActorChild, &obj, actor))) {
|
||||
aRv.ThrowTypeMismatchError(
|
||||
"Constructed actor does not inherit from JSProcessActorChild");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(aName, this);
|
||||
mProcessActors.Put(aName, RefPtr{actor});
|
||||
return actor.forget();
|
||||
}
|
||||
|
||||
IPCResult ContentChild::RecvFlushFOGData(FlushFOGDataResolver&& aResolver) {
|
||||
#ifdef MOZ_GLEAN
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/Shmem.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIDOMProcessChild.h"
|
||||
#include "nsIContentChild.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
@ -42,6 +42,7 @@ struct LookAndFeelInt;
|
|||
class nsDocShellLoadState;
|
||||
class nsFrameLoader;
|
||||
class nsIOpenWindowInfo;
|
||||
class JSProcessActorChild;
|
||||
|
||||
namespace mozilla {
|
||||
class RemoteSpellcheckEngineChild;
|
||||
|
@ -73,7 +74,7 @@ class GetFilesHelperChild;
|
|||
class TabContext;
|
||||
|
||||
class ContentChild final : public PContentChild,
|
||||
public nsIDOMProcessChild,
|
||||
public nsIContentChild,
|
||||
public mozilla::ipc::IShmemAllocator,
|
||||
public mozilla::ipc::ChildToParentStreamActorManager,
|
||||
public ProcessActor {
|
||||
|
@ -84,7 +85,7 @@ class ContentChild final : public PContentChild,
|
|||
friend class PContentChild;
|
||||
|
||||
public:
|
||||
NS_DECL_NSIDOMPROCESSCHILD
|
||||
NS_DECL_NSICONTENTCHILD
|
||||
|
||||
ContentChild();
|
||||
virtual ~ContentChild();
|
||||
|
@ -678,6 +679,10 @@ class ContentChild final : public PContentChild,
|
|||
PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
|
||||
const FileDescriptor& aFD) override;
|
||||
|
||||
// Get a JS actor object by name.
|
||||
already_AddRefed<mozilla::dom::JSProcessActorChild> GetActor(
|
||||
const nsACString& aName, ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
|
||||
void StartForceKillTimer();
|
||||
|
@ -777,6 +782,10 @@ class ContentChild final : public PContentChild,
|
|||
const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack);
|
||||
|
||||
void ReceiveRawMessage(const JSActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack);
|
||||
|
||||
JSActor::Type GetSide() override { return JSActor::Type::Child; }
|
||||
|
||||
mozilla::ipc::IPCResult RecvHistoryCommitLength(
|
||||
|
@ -883,7 +892,7 @@ class ContentChild final : public PContentChild,
|
|||
};
|
||||
|
||||
inline nsISupports* ToSupports(mozilla::dom::ContentChild* aContentChild) {
|
||||
return static_cast<nsIDOMProcessChild*>(aContentChild);
|
||||
return static_cast<nsIContentChild*>(aContentChild);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -3184,13 +3184,13 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(ContentParent)
|
|||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ContentParent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONCRETE(ContentParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMProcessParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionErrorCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAsyncShutdownBlocker)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMProcessParent)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentParent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// Async shutdown blocker
|
||||
|
@ -6819,18 +6819,60 @@ NS_IMETHODIMP ContentParent::GetChildID(uint64_t* aOut) {
|
|||
IPCResult ContentParent::RecvRawMessage(const JSActorMessageMeta& aMeta,
|
||||
const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack) {
|
||||
RefPtr<JSProcessActorParent> actor;
|
||||
GetActor(aMeta.actorName(), getter_AddRefs(actor));
|
||||
if (actor) {
|
||||
StructuredCloneData data;
|
||||
data.BorrowFromClonedMessageDataForParent(aData);
|
||||
StructuredCloneData stack;
|
||||
stack.BorrowFromClonedMessageDataForParent(aStack);
|
||||
actor->ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||
}
|
||||
StructuredCloneData data;
|
||||
data.BorrowFromClonedMessageDataForParent(aData);
|
||||
StructuredCloneData stack;
|
||||
stack.BorrowFromClonedMessageDataForParent(aStack);
|
||||
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void ContentParent::ReceiveRawMessage(const JSActorMessageMeta& aMeta,
|
||||
StructuredCloneData&& aData,
|
||||
StructuredCloneData&& aStack) {
|
||||
RefPtr<JSProcessActorParent> actor =
|
||||
GetActor(aMeta.actorName(), IgnoreErrors());
|
||||
if (actor) {
|
||||
actor->ReceiveRawMessage(aMeta, std::move(aData), std::move(aStack));
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<JSProcessActorParent> ContentParent::GetActor(
|
||||
const nsACString& aName, ErrorResult& aRv) {
|
||||
if (!CanSend()) {
|
||||
aRv.ThrowInvalidStateError(nsPrintfCString(
|
||||
"Cannot get actor '%s': content parent is ready to communicate.",
|
||||
PromiseFlatCString(aName).get()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mProcessActors.Contains(aName)) {
|
||||
return do_AddRef(mProcessActors.GetWeak(aName));
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor.
|
||||
JS::RootedObject obj(RootingCx());
|
||||
ConstructActor(aName, &obj, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSProcessActorParent object.
|
||||
RefPtr<JSProcessActorParent> actor;
|
||||
if (NS_FAILED(UNWRAP_OBJECT(JSProcessActorParent, &obj, actor))) {
|
||||
aRv.ThrowTypeMismatchError(
|
||||
"Constructed actor does not inherit from JSProcessActorParent");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(aName, this);
|
||||
mProcessActors.Put(aName, RefPtr{actor});
|
||||
return actor.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ContentParent::GetActor(const nsACString& aName,
|
||||
JSProcessActorParent** retval) {
|
||||
if (!CanSend()) {
|
||||
|
@ -6874,13 +6916,6 @@ IPCResult ContentParent::RecvFOGData(ByteBuf&& buf) {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ContentParent::GetCanSend(bool* aCanSend) {
|
||||
*aCanSend = CanSend();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ContentParent*) ContentParent::AsContentParent() { return this; }
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "nsFrameMessageManager.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIAsyncShutdown.h"
|
||||
#include "nsIDOMProcessParent.h"
|
||||
#include "nsIContentParent.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIRemoteTab.h"
|
||||
|
@ -128,7 +128,7 @@ struct CancelContentJSOptions;
|
|||
|
||||
class ContentParent final
|
||||
: public PContentParent,
|
||||
public nsIDOMProcessParent,
|
||||
public nsIContentParent,
|
||||
public nsIObserver,
|
||||
public nsIDOMGeoPositionCallback,
|
||||
public nsIDOMGeoPositionErrorCallback,
|
||||
|
@ -357,7 +357,7 @@ class ContentParent final
|
|||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ContentParent, nsIObserver)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_NSIDOMPROCESSPARENT
|
||||
NS_DECL_NSICONTENTPARENT
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIDOMGEOPOSITIONCALLBACK
|
||||
NS_DECL_NSIDOMGEOPOSITIONERRORCALLBACK
|
||||
|
@ -1358,6 +1358,13 @@ class ContentParent final
|
|||
nsTArray<ContentParent*>& aContentParents, uint32_t aMaxContentParents,
|
||||
bool aPreferUsed);
|
||||
|
||||
// Get a JS actor object by name.
|
||||
already_AddRefed<JSProcessActorParent> GetActor(const nsACString& aName,
|
||||
ErrorResult& aRv);
|
||||
void ReceiveRawMessage(const JSActorMessageMeta& aMeta,
|
||||
StructuredCloneData&& aData,
|
||||
StructuredCloneData&& aStack);
|
||||
|
||||
void AddToPool(nsTArray<ContentParent*>&);
|
||||
void RemoveFromPool(nsTArray<ContentParent*>&);
|
||||
void AssertNotInPool();
|
||||
|
@ -1540,7 +1547,7 @@ bool IsWebRemoteType(const nsAString& aContentProcessType);
|
|||
bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType);
|
||||
|
||||
inline nsISupports* ToSupports(mozilla::dom::ContentParent* aContentParent) {
|
||||
return static_cast<nsIDOMProcessParent*>(aContentParent);
|
||||
return static_cast<nsIContentParent*>(aContentParent);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/JSProcessActorBinding.h"
|
||||
#include "mozilla/dom/JSProcessActorChild.h"
|
||||
#include "mozilla/dom/InProcessChild.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -27,44 +27,14 @@ JSObject* JSProcessActorChild::WrapObject(JSContext* aCx,
|
|||
return JSProcessActorChild_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class AsyncMessageToProcessParent : public Runnable {
|
||||
public:
|
||||
AsyncMessageToProcessParent(const JSActorMessageMeta& aMetadata,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack)
|
||||
: mozilla::Runnable("InProcessParent::HandleAsyncMessage"),
|
||||
mMetadata(aMetadata),
|
||||
mData(std::move(aData)),
|
||||
mStack(std::move(aStack)) {}
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread.");
|
||||
if (auto* parent = InProcessParent::Singleton()) {
|
||||
RefPtr<JSProcessActorParent> actor;
|
||||
parent->GetActor(mMetadata.actorName(), getter_AddRefs(actor));
|
||||
if (actor) {
|
||||
actor->ReceiveRawMessage(mMetadata, std::move(mData),
|
||||
std::move(mStack));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
JSActorMessageMeta mMetadata;
|
||||
ipc::StructuredCloneData mData;
|
||||
ipc::StructuredCloneData mStack;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void JSProcessActorChild::SendRawMessage(const JSActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack,
|
||||
ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->GetCanSend())) {
|
||||
// We only ever have JSProcessActorChild in a multi-process scenario.
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->CanSend())) {
|
||||
aRv.ThrowInvalidStateError("JSProcessActorChild cannot send at the moment");
|
||||
return;
|
||||
}
|
||||
|
@ -78,29 +48,17 @@ void JSProcessActorChild::SendRawMessage(const JSActorMessageMeta& aMeta,
|
|||
return;
|
||||
}
|
||||
|
||||
// If the parent side is in the same process, we have a PInProcess manager,
|
||||
// and can dispatch the message directly to the event loop.
|
||||
ContentChild* contentChild = mManager->AsContentChild();
|
||||
if (!contentChild) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||
NS_DispatchToMainThread(MakeAndAddRef<AsyncMessageToProcessParent>(
|
||||
aMeta, std::move(aData), std::move(aStack)));
|
||||
return;
|
||||
}
|
||||
|
||||
ClonedMessageData msgData;
|
||||
ClonedMessageData stackData;
|
||||
if (NS_WARN_IF(
|
||||
!aData.BuildClonedMessageDataForChild(contentChild, msgData)) ||
|
||||
NS_WARN_IF(
|
||||
!aStack.BuildClonedMessageDataForChild(contentChild, stackData))) {
|
||||
if (NS_WARN_IF(!aData.BuildClonedMessageDataForChild(mManager, msgData)) ||
|
||||
NS_WARN_IF(!aStack.BuildClonedMessageDataForChild(mManager, stackData))) {
|
||||
aRv.ThrowDataCloneError(nsPrintfCString(
|
||||
"JSProcessActorChild serialization error: cannot clone, in actor '%s'",
|
||||
PromiseFlatCString(aMeta.actorName()).get()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!contentChild->SendRawMessage(aMeta, msgData, stackData))) {
|
||||
if (NS_WARN_IF(!mManager->SendRawMessage(aMeta, msgData, stackData))) {
|
||||
aRv.ThrowOperationError(
|
||||
nsPrintfCString("JSProcessActorChild send error in actor '%s'",
|
||||
PromiseFlatCString(aMeta.actorName()).get()));
|
||||
|
@ -109,7 +67,7 @@ void JSProcessActorChild::SendRawMessage(const JSActorMessageMeta& aMeta,
|
|||
}
|
||||
|
||||
void JSProcessActorChild::Init(const nsACString& aName,
|
||||
nsIDOMProcessChild* aManager) {
|
||||
ContentChild* aManager) {
|
||||
MOZ_ASSERT(!mManager, "Cannot Init() a JSProcessActorChild twice!");
|
||||
SetName(aName);
|
||||
mManager = aManager;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef mozilla_dom_JSProcessActorChild_h
|
||||
#define mozilla_dom_JSProcessActorChild_h
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/JSActor.h"
|
||||
#include "nsIDOMProcessChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -32,9 +32,9 @@ class JSProcessActorChild final : public JSActor {
|
|||
return MakeAndAddRef<JSProcessActorChild>();
|
||||
}
|
||||
|
||||
nsIDOMProcessChild* Manager() const { return mManager; }
|
||||
ContentChild* Manager() const { return mManager; }
|
||||
|
||||
void Init(const nsACString& aName, nsIDOMProcessChild* aManager);
|
||||
void Init(const nsACString& aName, ContentChild* aManager);
|
||||
void AfterDestroy();
|
||||
|
||||
protected:
|
||||
|
@ -50,7 +50,7 @@ class JSProcessActorChild final : public JSActor {
|
|||
~JSProcessActorChild() { MOZ_ASSERT(!mManager); }
|
||||
|
||||
bool mCanSend = true;
|
||||
nsCOMPtr<nsIDOMProcessChild> mManager;
|
||||
RefPtr<ContentChild> mManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -27,7 +27,7 @@ JSObject* JSProcessActorParent::WrapObject(JSContext* aCx,
|
|||
}
|
||||
|
||||
void JSProcessActorParent::Init(const nsACString& aName,
|
||||
nsIDOMProcessParent* aManager) {
|
||||
ContentParent* aManager) {
|
||||
MOZ_ASSERT(!mManager, "Cannot Init() a JSProcessActorParent twice!");
|
||||
SetName(aName);
|
||||
mManager = aManager;
|
||||
|
@ -37,44 +37,11 @@ void JSProcessActorParent::Init(const nsACString& aName,
|
|||
|
||||
JSProcessActorParent::~JSProcessActorParent() { MOZ_ASSERT(!mManager); }
|
||||
|
||||
namespace {
|
||||
|
||||
class AsyncMessageToProcessChild : public Runnable {
|
||||
public:
|
||||
AsyncMessageToProcessChild(const JSActorMessageMeta& aMetadata,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack)
|
||||
: mozilla::Runnable("InProcessChild::HandleAsyncMessage"),
|
||||
mMetadata(aMetadata),
|
||||
mData(std::move(aData)),
|
||||
mStack(std::move(aStack)) {}
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread.");
|
||||
if (auto* child = InProcessChild::Singleton()) {
|
||||
RefPtr<JSProcessActorChild> actor;
|
||||
child->GetActor(mMetadata.actorName(), getter_AddRefs(actor));
|
||||
if (actor) {
|
||||
actor->ReceiveRawMessage(mMetadata, std::move(mData),
|
||||
std::move(mStack));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
JSActorMessageMeta mMetadata;
|
||||
ipc::StructuredCloneData mData;
|
||||
ipc::StructuredCloneData mStack;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void JSProcessActorParent::SendRawMessage(const JSActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack,
|
||||
ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->GetCanSend())) {
|
||||
if (NS_WARN_IF(!mCanSend || !mManager || !mManager->CanSend())) {
|
||||
aRv.ThrowInvalidStateError(
|
||||
nsPrintfCString("Actor '%s' cannot send message '%s' during shutdown.",
|
||||
PromiseFlatCString(aMeta.actorName()).get(),
|
||||
|
@ -91,22 +58,12 @@ void JSProcessActorParent::SendRawMessage(const JSActorMessageMeta& aMeta,
|
|||
return;
|
||||
}
|
||||
|
||||
// If the parent side is in the same process, we have a PInProcess manager,
|
||||
// and can dispatch the message directly to the event loop.
|
||||
ContentParent* contentParent = mManager->AsContentParent();
|
||||
if (!contentParent) {
|
||||
NS_DispatchToMainThread(MakeAndAddRef<AsyncMessageToProcessChild>(
|
||||
aMeta, std::move(aData), std::move(aStack)));
|
||||
return;
|
||||
}
|
||||
|
||||
// Cross-process case - send data over ContentParent to other side.
|
||||
ClonedMessageData msgData;
|
||||
ClonedMessageData stackData;
|
||||
if (NS_WARN_IF(
|
||||
!aData.BuildClonedMessageDataForParent(contentParent, msgData)) ||
|
||||
if (NS_WARN_IF(!aData.BuildClonedMessageDataForParent(mManager, msgData)) ||
|
||||
NS_WARN_IF(
|
||||
!aStack.BuildClonedMessageDataForParent(contentParent, stackData))) {
|
||||
!aStack.BuildClonedMessageDataForParent(mManager, stackData))) {
|
||||
aRv.ThrowDataCloneError(
|
||||
nsPrintfCString("Actor '%s' cannot send message '%s': cannot clone.",
|
||||
PromiseFlatCString(aMeta.actorName()).get(),
|
||||
|
@ -114,7 +71,7 @@ void JSProcessActorParent::SendRawMessage(const JSActorMessageMeta& aMeta,
|
|||
return;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!contentParent->SendRawMessage(aMeta, msgData, stackData))) {
|
||||
if (NS_WARN_IF(!mManager->SendRawMessage(aMeta, msgData, stackData))) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "mozilla/dom/JSActor.h"
|
||||
#include "mozilla/extensions/WebExtensionContentScript.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIDOMProcessParent.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -39,9 +38,9 @@ class JSProcessActorParent final : public JSActor {
|
|||
return MakeAndAddRef<JSProcessActorParent>();
|
||||
}
|
||||
|
||||
nsIDOMProcessParent* Manager() const { return mManager; }
|
||||
ContentParent* Manager() const { return mManager; }
|
||||
|
||||
void Init(const nsACString& aName, nsIDOMProcessParent* aManager);
|
||||
void Init(const nsACString& aName, ContentParent* aManager);
|
||||
void AfterDestroy();
|
||||
|
||||
protected:
|
||||
|
@ -57,7 +56,7 @@ class JSProcessActorParent final : public JSActor {
|
|||
~JSProcessActorParent();
|
||||
|
||||
bool mCanSend = true;
|
||||
nsCOMPtr<nsIDOMProcessParent> mManager;
|
||||
RefPtr<ContentParent> mManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -78,18 +78,16 @@ NS_IMETHODIMP JSProcessActorProtocol::Observe(nsISupports* aSubject,
|
|||
const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
|
||||
MOZ_ASSERT(!XRE_IsParentProcess());
|
||||
|
||||
nsCOMPtr<nsIDOMProcessChild> manager;
|
||||
if (XRE_IsParentProcess()) {
|
||||
manager = InProcessChild::Singleton();
|
||||
} else {
|
||||
manager = ContentChild::GetSingleton();
|
||||
}
|
||||
ErrorResult error;
|
||||
RefPtr<JSProcessActorChild> actor =
|
||||
ContentChild::GetSingleton()->GetActor(mName, error);
|
||||
|
||||
// Don't raise an error if creation of our actor was vetoed.
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
nsresult rv = error.StealNSResult();
|
||||
|
||||
RefPtr<JSProcessActorChild> actor;
|
||||
nsresult rv = manager->GetActor(mName, getter_AddRefs(actor));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// Don't raise an error if creation of our actor was vetoed.
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -107,6 +105,12 @@ NS_IMETHODIMP JSProcessActorProtocol::Observe(nsISupports* aSubject,
|
|||
}
|
||||
|
||||
void JSProcessActorProtocol::AddObservers() {
|
||||
// Ignore adding observers for parent processes, but this will
|
||||
// need to change with bug 1633379.
|
||||
if (XRE_IsParentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
for (auto& topic : mChild.mObservers) {
|
||||
// This makes the observer service hold an owning reference to the
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "mozilla/dom/JSActor.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsIDOMProcessChild.h"
|
||||
#include "nsIContentChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsVariant.h"
|
||||
|
||||
using namespace IPC;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include "mozilla/dom/WindowGlobalActorsBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/dom/WindowContext.h"
|
||||
#include "mozilla/dom/InProcessChild.h"
|
||||
#include "mozilla/dom/InProcessParent.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
#include "mozilla/ipc/InProcessParent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/dom/InProcessParent.h"
|
||||
#include "mozilla/ipc/InProcessParent.h"
|
||||
#include "mozilla/dom/BrowserBridgeParent.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/ClientInfo.h"
|
||||
|
@ -213,13 +213,6 @@ already_AddRefed<BrowserParent> WindowGlobalParent::GetBrowserParent() {
|
|||
return do_AddRef(static_cast<BrowserParent*>(Manager()));
|
||||
}
|
||||
|
||||
ContentParent* WindowGlobalParent::GetContentParent() {
|
||||
if (IsInProcess() || !CanSend()) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<ContentParent*>(Manager()->Manager());
|
||||
}
|
||||
|
||||
already_AddRefed<nsFrameLoader> WindowGlobalParent::GetRootFrameLoader() {
|
||||
dom::BrowsingContext* top = BrowsingContext()->Top();
|
||||
|
||||
|
@ -830,11 +823,13 @@ nsIGlobalObject* WindowGlobalParent::GetParentObject() {
|
|||
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
nsIDOMProcessParent* WindowGlobalParent::GetDomProcess() {
|
||||
if (RefPtr<BrowserParent> browserParent = GetBrowserParent()) {
|
||||
return browserParent->Manager();
|
||||
nsIContentParent* WindowGlobalParent::GetContentParent() {
|
||||
RefPtr<BrowserParent> browserParent = GetBrowserParent();
|
||||
if (!browserParent) {
|
||||
return nullptr;
|
||||
}
|
||||
return InProcessParent::Singleton();
|
||||
|
||||
return browserParent->Manager();
|
||||
}
|
||||
|
||||
void WindowGlobalParent::DidBecomeCurrentWindowGlobal(bool aCurrent) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMProcessParent.h"
|
||||
#include "nsIContentParent.h"
|
||||
#include "mozilla/dom/WindowGlobalActor.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/net/CookieJarSettings.h"
|
||||
|
@ -93,8 +93,6 @@ class WindowGlobalParent final : public WindowContext,
|
|||
// |nullptr| if the actor has been torn down, or is in-process.
|
||||
already_AddRefed<BrowserParent> GetBrowserParent();
|
||||
|
||||
ContentParent* GetContentParent();
|
||||
|
||||
void ReceiveRawMessage(const JSActorMessageMeta& aMeta,
|
||||
ipc::StructuredCloneData&& aData,
|
||||
ipc::StructuredCloneData&& aStack);
|
||||
|
@ -175,7 +173,7 @@ class WindowGlobalParent final : public WindowContext,
|
|||
|
||||
ContentBlockingLog* GetContentBlockingLog() { return &mContentBlockingLog; }
|
||||
|
||||
nsIDOMProcessParent* GetDomProcess();
|
||||
nsIContentParent* GetContentParent();
|
||||
|
||||
nsICookieJarSettings* CookieJarSettings() { return mCookieJarSettings; }
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ with Files("**"):
|
|||
BUG_COMPONENT = ("Core", "DOM: Content Processes")
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMProcessChild.idl',
|
||||
'nsIDOMProcessParent.idl',
|
||||
'nsIContentChild.idl',
|
||||
'nsIContentParent.idl',
|
||||
'nsIHangReport.idl',
|
||||
]
|
||||
|
||||
|
@ -48,8 +48,6 @@ EXPORTS.mozilla.dom += [
|
|||
'DocShellMessageUtils.h',
|
||||
'EffectsInfo.h',
|
||||
'FilePickerParent.h',
|
||||
'InProcessChild.h',
|
||||
'InProcessParent.h',
|
||||
'JSActor.h',
|
||||
'JSActorService.h',
|
||||
'JSProcessActorChild.h',
|
||||
|
@ -107,7 +105,6 @@ UNIFIED_SOURCES += [
|
|||
'CSPMessageUtils.cpp',
|
||||
'DocShellMessageUtils.cpp',
|
||||
'FilePickerParent.cpp',
|
||||
'InProcessImpl.cpp',
|
||||
'JSActor.cpp',
|
||||
'JSActorService.cpp',
|
||||
'JSProcessActorChild.cpp',
|
||||
|
@ -161,7 +158,6 @@ IPDL_SOURCES += [
|
|||
'PContentPermissionRequest.ipdl',
|
||||
'PCycleCollectWithLogs.ipdl',
|
||||
'PFilePicker.ipdl',
|
||||
'PInProcess.ipdl',
|
||||
'PLoginReputation.ipdl',
|
||||
'PPluginWidget.ipdl',
|
||||
'PProcessHangMonitor.ipdl',
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
webidl JSProcessActorChild;
|
||||
|
||||
[scriptable, builtinclass, uuid(b0c6e5f3-02f1-4f11-a0af-336fc231f3bf)]
|
||||
interface nsIContentChild: nsISupports {
|
||||
// Internal ID of the process.
|
||||
readonly attribute unsigned long long childID;
|
||||
|
||||
JSProcessActorChild getActor(in ACString name);
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
webidl JSProcessActorParent;
|
||||
|
||||
[scriptable, builtinclass, uuid(81fc08b9-c901-471f-ab0d-876362eba770)]
|
||||
interface nsIContentParent: nsISupports {
|
||||
// Internal ID of the process.
|
||||
readonly attribute unsigned long long childID;
|
||||
|
||||
JSProcessActorParent getActor(in ACString name);
|
||||
};
|
|
@ -1,42 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ContentChild;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
%}
|
||||
[ptr] native ContentChildPtr(mozilla::dom::ContentChild);
|
||||
|
||||
webidl JSProcessActorChild;
|
||||
|
||||
/**
|
||||
* Child actor interface for a process which can host DOM content.
|
||||
*
|
||||
* Implemented by either `InProcessChild` for the parent process, or
|
||||
* `ContentChild` for a content process.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(b0c6e5f3-02f1-4f11-a0af-336fc231f3bf)]
|
||||
interface nsIDOMProcessChild: nsISupports {
|
||||
/**
|
||||
* Internal child process ID. `0` is reserved for the parent process.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long long childID;
|
||||
|
||||
/**
|
||||
* Lookup a JSProcessActorChild managed by this interface by name.
|
||||
*/
|
||||
JSProcessActorChild getActor(in ACString name);
|
||||
|
||||
/** Can the actor still send messages? */
|
||||
[infallible] readonly attribute boolean canSend;
|
||||
|
||||
[notxpcom, nostdcall] ContentChildPtr AsContentChild();
|
||||
};
|
|
@ -1,42 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ContentParent;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
%}
|
||||
[ptr] native ContentParentPtr(mozilla::dom::ContentParent);
|
||||
|
||||
webidl JSProcessActorParent;
|
||||
|
||||
/**
|
||||
* Parent actor interface for a process which can host DOM content.
|
||||
*
|
||||
* Implemented by either `InProcessParent` for the parent process, or
|
||||
* `ContentParent` for a content process.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(81fc08b9-c901-471f-ab0d-876362eba770)]
|
||||
interface nsIDOMProcessParent: nsISupports {
|
||||
/**
|
||||
* Internal child process ID. `0` is reserved for the parent process.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long long childID;
|
||||
|
||||
/**
|
||||
* Lookup a JSProcessActorParent managed by this interface by name.
|
||||
*/
|
||||
JSProcessActorParent getActor(in ACString name);
|
||||
|
||||
/** Can the actor still send messages? */
|
||||
[infallible] readonly attribute boolean canSend;
|
||||
|
||||
[notxpcom, nostdcall] ContentParentPtr AsContentParent();
|
||||
};
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
declTest("getActor on both sides", {
|
||||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let parent = browser.browsingContext.currentWindowGlobal.contentParent;
|
||||
ok(parent, "WindowGlobalParent should have value.");
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
is(
|
||||
|
@ -15,7 +15,7 @@ declTest("getActor on both sides", {
|
|||
is(
|
||||
actorParent.manager,
|
||||
parent,
|
||||
"manager should match WindowGlobalParent.domProcess"
|
||||
"manager should match WindowGlobalParent.contentParent"
|
||||
);
|
||||
|
||||
ok(
|
||||
|
@ -24,7 +24,7 @@ declTest("getActor on both sides", {
|
|||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], async function() {
|
||||
let child = ChromeUtils.domProcessChild;
|
||||
let child = ChromeUtils.contentChild;
|
||||
ok(child, "WindowGlobalChild should have value.");
|
||||
let actorChild = child.getActor("TestProcessActor");
|
||||
is(
|
||||
|
@ -35,7 +35,7 @@ declTest("getActor on both sides", {
|
|||
is(
|
||||
actorChild.manager,
|
||||
child,
|
||||
"manager should match ChromeUtils.domProcessChild."
|
||||
"manager should match ChromeUtils.contentChild."
|
||||
);
|
||||
|
||||
ok(
|
||||
|
|
|
@ -9,7 +9,7 @@ declTest("test observer triggering actor creation", {
|
|||
const TOPIC = "test-js-content-actor-child-observer";
|
||||
Services.obs.notifyObservers(content.window, TOPIC, "dataString");
|
||||
|
||||
let child = ChromeUtils.domProcessChild;
|
||||
let child = ChromeUtils.contentChild;
|
||||
let actorChild = child.getActor("TestProcessActor");
|
||||
ok(actorChild, "JSProcessActorChild should have value.");
|
||||
ok(
|
||||
|
@ -29,7 +29,7 @@ declTest("test observers with null data", {
|
|||
const TOPIC = "test-js-content-actor-child-observer";
|
||||
Services.obs.notifyObservers(content.window, TOPIC);
|
||||
|
||||
let child = ChromeUtils.domProcessChild;
|
||||
let child = ChromeUtils.contentChild;
|
||||
let actorChild = child.getActor("TestProcessActor");
|
||||
ok(actorChild, "JSProcessActorChild should have value.");
|
||||
let { subject, topic, data } = actorChild.lastObserved;
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
declTest("asyncMessage testing", {
|
||||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let parent = browser.browsingContext.currentWindowGlobal.contentParent;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
ok(actorParent, "JSProcessActorParent should have value.");
|
||||
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
let child = ChromeUtils.domProcessChild;
|
||||
let child = ChromeUtils.contentChild;
|
||||
let actorChild = child.getActor("TestProcessActor");
|
||||
ok(actorChild, "JSProcessActorChild should have value.");
|
||||
|
||||
|
@ -32,7 +32,7 @@ declTest("asyncMessage without both sides", {
|
|||
// If we don't create a parent actor, make sure the parent actor
|
||||
// gets created by having sent the message.
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
let child = ChromeUtils.domProcessChild;
|
||||
let child = ChromeUtils.contentChild;
|
||||
let actorChild = child.getActor("TestProcessActor");
|
||||
ok(actorChild, "JSProcessActorChild should have value.");
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ function maybeAsyncStack(offset, column) {
|
|||
|
||||
declTest("sendQuery Error", {
|
||||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let parent = browser.browsingContext.currentWindowGlobal.contentParent;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
|
||||
let asyncStack = maybeAsyncStack(2, 8);
|
||||
|
@ -44,7 +44,7 @@ declTest("sendQuery Error", {
|
|||
|
||||
declTest("sendQuery Exception", {
|
||||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let parent = browser.browsingContext.currentWindowGlobal.contentParent;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
|
||||
let asyncStack = maybeAsyncStack(2, 8);
|
||||
|
@ -72,7 +72,7 @@ declTest("sendQuery Exception", {
|
|||
|
||||
declTest("sendQuery testing", {
|
||||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let parent = browser.browsingContext.currentWindowGlobal.contentParent;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
ok(actorParent, "JSWindowActorParent should have value.");
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@ declTest("test childid", {
|
|||
async test(browser) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal;
|
||||
ok(
|
||||
parent.domProcess.childID,
|
||||
"parent domProcess.childID should have a value."
|
||||
parent.contentParent.childID,
|
||||
"parent contentParent.childID should have a value."
|
||||
);
|
||||
await SpecialPowers.spawn(
|
||||
browser,
|
||||
[parent.domProcess.childID],
|
||||
[parent.contentParent.childID],
|
||||
async function(parentChildID) {
|
||||
ok(
|
||||
ChromeUtils.domProcessChild.childID,
|
||||
ChromeUtils.contentChild.childID,
|
||||
"child process.childID should have a value."
|
||||
);
|
||||
let childID = ChromeUtils.domProcessChild.childID;
|
||||
let childID = ChromeUtils.contentChild.childID;
|
||||
is(parentChildID, childID);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "mozilla/Tuple.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
|
|
@ -4,19 +4,20 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InProcessChild_h
|
||||
#define mozilla_dom_InProcessChild_h
|
||||
#ifndef mozilla_ipc_InProcessChild_h
|
||||
#define mozilla_ipc_InProcessChild_h
|
||||
|
||||
#include "mozilla/dom/PInProcessChild.h"
|
||||
#include "mozilla/dom/JSProcessActorChild.h"
|
||||
#include "mozilla/dom/ProcessActor.h"
|
||||
#include "mozilla/ipc/PInProcessChild.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsIDOMProcessChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class PWindowGlobalParent;
|
||||
class PWindowGlobalChild;
|
||||
} // namespace dom
|
||||
|
||||
namespace ipc {
|
||||
|
||||
class InProcessParent;
|
||||
|
||||
/**
|
||||
|
@ -27,15 +28,12 @@ class InProcessParent;
|
|||
* for async actors which want to communicate uniformly between Content->Chrome
|
||||
* and Chrome->Chrome situations.
|
||||
*/
|
||||
class InProcessChild final : public nsIDOMProcessChild,
|
||||
public PInProcessChild,
|
||||
public ProcessActor {
|
||||
class InProcessChild final : public PInProcessChild {
|
||||
public:
|
||||
friend class InProcessParent;
|
||||
friend class PInProcessChild;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMPROCESSCHILD
|
||||
NS_INLINE_DECL_REFCOUNTING(InProcessChild, final)
|
||||
|
||||
// Get the singleton instance of this actor.
|
||||
static InProcessChild* Singleton();
|
||||
|
@ -45,9 +43,6 @@ class InProcessChild final : public nsIDOMProcessChild,
|
|||
// |nullptr|.
|
||||
static IProtocol* ParentActorFor(IProtocol* aActor);
|
||||
|
||||
const nsAString& GetRemoteType() const override { return VoidString(); }
|
||||
JSActor::Type GetSide() override { return JSActor::Type::Child; }
|
||||
|
||||
private:
|
||||
// NOTE: PInProcess lifecycle management is declared as staic methods and
|
||||
// state on InProcessParent, and implemented in InProcessImpl.cpp.
|
||||
|
@ -55,11 +50,9 @@ class InProcessChild final : public nsIDOMProcessChild,
|
|||
~InProcessChild() = default;
|
||||
|
||||
static StaticRefPtr<InProcessChild> sSingleton;
|
||||
|
||||
nsRefPtrHashtable<nsCStringHashKey, JSProcessActorChild> mProcessActors;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // defined(mozilla_dom_InProcessChild_h)
|
||||
#endif // defined(mozilla_ipc_InProcessChild_h)
|
|
@ -4,19 +4,16 @@
|
|||
* 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/InProcessParent.h"
|
||||
#include "mozilla/dom/InProcessChild.h"
|
||||
#include "mozilla/dom/JSProcessActorBinding.h"
|
||||
#include "mozilla/ipc/InProcessParent.h"
|
||||
#include "mozilla/ipc/InProcessChild.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
// This file contains the implementation of core InProcess lifecycle management
|
||||
// facilities.
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace ipc {
|
||||
|
||||
StaticRefPtr<InProcessParent> InProcessParent::sSingleton;
|
||||
StaticRefPtr<InProcessChild> InProcessChild::sSingleton;
|
||||
|
@ -118,118 +115,6 @@ void InProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
|
|||
InProcessParent::Shutdown();
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// nsIDOMProcessParent //
|
||||
/////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessParent::GetChildID(uint64_t* aChildID) {
|
||||
*aChildID = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessParent::GetActor(const nsACString& aName,
|
||||
JSProcessActorParent** aActor) {
|
||||
if (!CanSend()) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mProcessActors.Contains(aName)) {
|
||||
RefPtr<JSProcessActorParent> actor(mProcessActors.Get(aName));
|
||||
actor.forget(aActor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor.
|
||||
JS::RootedObject obj(RootingCx());
|
||||
ErrorResult result;
|
||||
ConstructActor(aName, &obj, result);
|
||||
if (result.Failed()) {
|
||||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSProcessActorParent object.
|
||||
RefPtr<JSProcessActorParent> actor;
|
||||
nsresult rv = UNWRAP_OBJECT(JSProcessActorParent, &obj, actor);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(aName, this);
|
||||
mProcessActors.Put(aName, RefPtr{actor});
|
||||
actor.forget(aActor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessParent::GetCanSend(bool* aCanSend) {
|
||||
*aCanSend = CanSend();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ContentParent*)
|
||||
InProcessParent::AsContentParent() { return nullptr; }
|
||||
|
||||
////////////////////////
|
||||
// nsIDOMProcessChild //
|
||||
////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessChild::GetChildID(uint64_t* aChildID) {
|
||||
*aChildID = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessChild::GetActor(const nsACString& aName,
|
||||
JSProcessActorChild** aActor) {
|
||||
if (!CanSend()) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mProcessActors.Contains(aName)) {
|
||||
RefPtr<JSProcessActorChild> actor(mProcessActors.Get(aName));
|
||||
actor.forget(aActor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor.
|
||||
JS::RootedObject obj(RootingCx());
|
||||
ErrorResult result;
|
||||
ConstructActor(aName, &obj, result);
|
||||
if (result.Failed()) {
|
||||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSProcessActorChild object.
|
||||
RefPtr<JSProcessActorChild> actor;
|
||||
nsresult rv = UNWRAP_OBJECT(JSProcessActorChild, &obj, actor);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(aName, this);
|
||||
mProcessActors.Put(aName, RefPtr{actor});
|
||||
actor.forget(aActor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InProcessChild::GetCanSend(bool* aCanSend) {
|
||||
*aCanSend = CanSend();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ContentChild*)
|
||||
InProcessChild::AsContentChild() { return nullptr; }
|
||||
|
||||
////////////////////////////////
|
||||
// In-Process Actor Utilities //
|
||||
////////////////////////////////
|
||||
|
@ -292,8 +177,7 @@ IProtocol* InProcessChild::ParentActorFor(IProtocol* aActor) {
|
|||
return GetOtherInProcessActor(aActor);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(InProcessParent, nsIDOMProcessParent, nsIObserver)
|
||||
NS_IMPL_ISUPPORTS(InProcessChild, nsIDOMProcessChild)
|
||||
NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
|
@ -4,19 +4,20 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InProcessParent_h
|
||||
#define mozilla_dom_InProcessParent_h
|
||||
#ifndef mozilla_ipc_InProcessParent_h
|
||||
#define mozilla_ipc_InProcessParent_h
|
||||
|
||||
#include "mozilla/dom/PInProcessParent.h"
|
||||
#include "mozilla/dom/JSProcessActorParent.h"
|
||||
#include "mozilla/dom/ProcessActor.h"
|
||||
#include "mozilla/ipc/PInProcessParent.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsIDOMProcessParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class PWindowGlobalParent;
|
||||
class PWindowGlobalChild;
|
||||
} // namespace dom
|
||||
|
||||
namespace ipc {
|
||||
|
||||
class InProcessChild;
|
||||
|
||||
/**
|
||||
|
@ -27,16 +28,12 @@ class InProcessChild;
|
|||
* for async actors which want to communicate uniformly between Content->Chrome
|
||||
* and Chrome->Chrome situations.
|
||||
*/
|
||||
class InProcessParent final : public nsIDOMProcessParent,
|
||||
public nsIObserver,
|
||||
public PInProcessParent,
|
||||
public ProcessActor {
|
||||
class InProcessParent final : public nsIObserver, public PInProcessParent {
|
||||
public:
|
||||
friend class InProcessChild;
|
||||
friend class PInProcessParent;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMPROCESSPARENT
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// Get the singleton instance of this actor.
|
||||
|
@ -47,9 +44,6 @@ class InProcessParent final : public nsIDOMProcessParent,
|
|||
// |nullptr|.
|
||||
static IProtocol* ChildActorFor(IProtocol* aActor);
|
||||
|
||||
const nsAString& GetRemoteType() const override { return VoidString(); };
|
||||
JSActor::Type GetSide() override { return JSActor::Type::Parent; }
|
||||
|
||||
private:
|
||||
// Lifecycle management is implemented in InProcessImpl.cpp
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
@ -60,11 +54,9 @@ class InProcessParent final : public nsIDOMProcessParent,
|
|||
|
||||
static StaticRefPtr<InProcessParent> sSingleton;
|
||||
static bool sShutdown;
|
||||
|
||||
nsRefPtrHashtable<nsCStringHashKey, JSProcessActorParent> mProcessActors;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // defined(mozilla_dom_InProcessParent_h)
|
||||
#endif // defined(mozilla_ipc_InProcessParent_h)
|
|
@ -9,14 +9,14 @@ include protocol PWindowGlobal;
|
|||
include DOMTypes;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace ipc {
|
||||
|
||||
/**
|
||||
* PInProcess is intended for use as an alternative actor manager to PContent
|
||||
* for async actors which want to be used uniformly in both Content->Chrome and
|
||||
* Chrome->Chrome circumstances.
|
||||
*
|
||||
* `mozilla::dom::InProcess{Parent, Child}::Singleton()` should be used to get
|
||||
* `mozilla::ipc::InProcess{Parent, Child}::Singleton()` should be used to get
|
||||
* an instance of this actor.
|
||||
*/
|
||||
async refcounted protocol PInProcess
|
||||
|
@ -24,5 +24,5 @@ async refcounted protocol PInProcess
|
|||
manages PWindowGlobal;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
|
@ -29,6 +29,8 @@ EXPORTS.mozilla.ipc += [
|
|||
'GeckoChildProcessHost.h',
|
||||
'IdleSchedulerChild.h',
|
||||
'IdleSchedulerParent.h',
|
||||
'InProcessChild.h',
|
||||
'InProcessParent.h',
|
||||
'InputStreamUtils.h',
|
||||
'IOThreadChild.h',
|
||||
'IPCStreamAlloc.h',
|
||||
|
@ -153,6 +155,7 @@ UNIFIED_SOURCES += [
|
|||
'FileDescriptorUtils.cpp',
|
||||
'IdleSchedulerChild.cpp',
|
||||
'IdleSchedulerParent.cpp',
|
||||
'InProcessImpl.cpp',
|
||||
'InputStreamUtils.cpp',
|
||||
'IPCMessageUtils.cpp',
|
||||
'IPCStreamChild.cpp',
|
||||
|
@ -213,6 +216,7 @@ IPDL_SOURCES = [
|
|||
'PChildToParentStream.ipdl',
|
||||
'PFileDescriptorSet.ipdl',
|
||||
'PIdleScheduler.ipdl',
|
||||
'PInProcess.ipdl',
|
||||
'PParentToChildStream.ipdl',
|
||||
'ProtocolTypes.ipdlh',
|
||||
'URIParams.ipdlh',
|
||||
|
|
Загрузка…
Ссылка в новой задаче