mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1513878 - Part 2: Implement a getter method to WindowGlobalParent/WindowGlobalChild. r=nika
Depends on D16844 Differential Revision: https://phabricator.services.mozilla.com/D16845 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a58878536c
commit
7b1dd6aef8
@ -538,7 +538,7 @@ dictionary WindowActorOptions {
|
||||
|
||||
dictionary WindowActorSidedOptions {
|
||||
/** The module path which should be loaded for the actor on this side. */
|
||||
required DOMString moduleURI;
|
||||
required ByteString moduleURI;
|
||||
};
|
||||
|
||||
enum Base64URLDecodePadding {
|
||||
|
16
dom/chrome-webidl/JSWindowActor.webidl
Normal file
16
dom/chrome-webidl/JSWindowActor.webidl
Normal file
@ -0,0 +1,16 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
[ChromeOnly, ChromeConstructor]
|
||||
interface JSWindowActorParent {
|
||||
readonly attribute WindowGlobalParent manager;
|
||||
};
|
||||
|
||||
|
||||
[ChromeOnly, ChromeConstructor]
|
||||
interface JSWindowActorChild {
|
||||
readonly attribute WindowGlobalChild manager;
|
||||
};
|
@ -27,6 +27,9 @@ interface WindowGlobalParent {
|
||||
readonly attribute URI? documentURI;
|
||||
|
||||
static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId);
|
||||
|
||||
[Throws]
|
||||
JSWindowActorParent getActor(DOMString name);
|
||||
};
|
||||
|
||||
[Exposed=Window, ChromeOnly]
|
||||
@ -43,4 +46,7 @@ interface WindowGlobalChild {
|
||||
readonly attribute WindowGlobalParent? parentActor; // in-process only
|
||||
|
||||
static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId);
|
||||
|
||||
[Throws]
|
||||
JSWindowActorChild getActor(DOMString name);
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ WEBIDL_FILES = [
|
||||
'HeapSnapshot.webidl',
|
||||
'InspectorUtils.webidl',
|
||||
'IteratorResult.webidl',
|
||||
'JSWindowActor.webidl',
|
||||
'MatchGlob.webidl',
|
||||
'MatchPattern.webidl',
|
||||
'MessageManager.webidl',
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "mozilla/dom/FileCreatorHelper.h"
|
||||
#include "mozilla/dom/GetFilesHelper.h"
|
||||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
#include "mozilla/dom/LSObject.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/dom/PLoginReputationChild.h"
|
||||
@ -2567,6 +2568,13 @@ mozilla::ipc::IPCResult ContentChild::RecvInitBlobURLs(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvInitJSWindowActorInfos(
|
||||
nsTArray<JSWindowActorInfo>&& aInfos) {
|
||||
RefPtr<JSWindowActorService> actSvc = JSWindowActorService::GetSingleton();
|
||||
actSvc->LoadJSWindowActorInfos(aInfos);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvLastPrivateDocShellDestroyed() {
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
||||
|
@ -441,6 +441,9 @@ class ContentChild final : public PContentChild,
|
||||
virtual mozilla::ipc::IPCResult RecvInitBlobURLs(
|
||||
nsTArray<BlobURLRegistrationData>&& aRegistations) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvInitJSWindowActorInfos(
|
||||
nsTArray<JSWindowActorInfo>&& aInfos) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvLastPrivateDocShellDestroyed() override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvNotifyProcessPriorityChanged(
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "mozilla/dom/ExternalHelperAppParent.h"
|
||||
#include "mozilla/dom/GetFilesHelper.h"
|
||||
#include "mozilla/dom/GeolocationBinding.h"
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
#include "mozilla/dom/LocalStorageCommon.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/dom/Notification.h"
|
||||
@ -2718,6 +2719,14 @@ void ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
||||
}
|
||||
}
|
||||
|
||||
// Send down WindowActorOptions at startup to content process.
|
||||
RefPtr<JSWindowActorService> actorSvc = JSWindowActorService::GetSingleton();
|
||||
if (actorSvc) {
|
||||
nsTArray<JSWindowActorInfo> infos;
|
||||
actorSvc->GetJSWindowActorInfos(infos);
|
||||
Unused << SendInitJSWindowActorInfos(infos);
|
||||
}
|
||||
|
||||
// Start up nsPluginHost and run FindPlugins to cache the plugin list.
|
||||
// If this isn't our first content process, just send over cached list.
|
||||
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
||||
|
36
dom/ipc/JSWindowActorChild.cpp
Normal file
36
dom/ipc/JSWindowActorChild.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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 "mozilla/dom/JSWindowActorBinding.h"
|
||||
#include "mozilla/dom/JSWindowActorChild.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject* JSWindowActorChild::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) {
|
||||
return JSWindowActorChild_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
WindowGlobalChild* JSWindowActorChild::Manager() const { return mManager; }
|
||||
|
||||
void JSWindowActorChild::Init(WindowGlobalChild* aManager) {
|
||||
MOZ_ASSERT(!mManager, "Cannot Init() a JSWindowActorChild twice!");
|
||||
mManager = aManager;
|
||||
}
|
||||
|
||||
nsISupports* JSWindowActorChild::GetParentObject() const {
|
||||
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorChild, mManager)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(JSWindowActorChild, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(JSWindowActorChild, Release)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
57
dom/ipc/JSWindowActorChild.h
Normal file
57
dom/ipc/JSWindowActorChild.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_JSWindowActorChild_h
|
||||
#define mozilla_dom_JSWindowActorChild_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class WindowGlobalChild;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class JSWindowActorChild final : public nsWrapperCache {
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(JSWindowActorChild)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(JSWindowActorChild)
|
||||
|
||||
protected:
|
||||
~JSWindowActorChild() = default;
|
||||
|
||||
public:
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<JSWindowActorChild> Constructor(GlobalObject& aGlobal,
|
||||
ErrorResult& aRv) {
|
||||
return MakeAndAddRef<JSWindowActorChild>();
|
||||
}
|
||||
|
||||
WindowGlobalChild* Manager() const;
|
||||
void Init(WindowGlobalChild* aManager);
|
||||
|
||||
private:
|
||||
RefPtr<WindowGlobalChild> mManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_JSWindowActorChild_h
|
36
dom/ipc/JSWindowActorParent.cpp
Normal file
36
dom/ipc/JSWindowActorParent.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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 "mozilla/dom/JSWindowActorBinding.h"
|
||||
#include "mozilla/dom/JSWindowActorParent.h"
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSObject* JSWindowActorParent::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) {
|
||||
return JSWindowActorParent_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
WindowGlobalParent* JSWindowActorParent::Manager() const { return mManager; }
|
||||
|
||||
void JSWindowActorParent::Init(WindowGlobalParent* aManager) {
|
||||
MOZ_ASSERT(!mManager, "Cannot Init() a JSWindowActorParent twice!");
|
||||
mManager = aManager;
|
||||
}
|
||||
|
||||
nsISupports* JSWindowActorParent::GetParentObject() const {
|
||||
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorParent, mManager)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(JSWindowActorParent, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(JSWindowActorParent, Release)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
57
dom/ipc/JSWindowActorParent.h
Normal file
57
dom/ipc/JSWindowActorParent.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_JSWindowActorParent_h
|
||||
#define mozilla_dom_JSWindowActorParent_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class WindowGlobalParent;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class JSWindowActorParent final : public nsWrapperCache {
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(JSWindowActorParent)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(JSWindowActorParent)
|
||||
|
||||
protected:
|
||||
~JSWindowActorParent() = default;
|
||||
|
||||
public:
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<JSWindowActorParent> Constructor(
|
||||
GlobalObject& aGlobal, ErrorResult& aRv) {
|
||||
return MakeAndAddRef<JSWindowActorParent>();
|
||||
}
|
||||
|
||||
WindowGlobalParent* Manager() const;
|
||||
void Init(WindowGlobalParent* aManager);
|
||||
|
||||
private:
|
||||
RefPtr<WindowGlobalParent> mManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_JSWindowActorParent_h
|
@ -6,26 +6,24 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
|
||||
#include "mozilla/dom/ChromeUtilsBinding.h"
|
||||
#include "mozilla/dom/PContent.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
struct WindowActorOptions;
|
||||
namespace {
|
||||
StaticRefPtr<JSWindowActorService> gJSWindowActorService;
|
||||
}
|
||||
|
||||
JSWindowActorService::JSWindowActorService() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
}
|
||||
JSWindowActorService::JSWindowActorService() { MOZ_ASSERT(NS_IsMainThread()); }
|
||||
|
||||
JSWindowActorService::~JSWindowActorService() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
}
|
||||
JSWindowActorService::~JSWindowActorService() { MOZ_ASSERT(NS_IsMainThread()); }
|
||||
|
||||
/* static */ already_AddRefed<JSWindowActorService>
|
||||
JSWindowActorService::GetSingleton() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!gJSWindowActorService) {
|
||||
gJSWindowActorService = new JSWindowActorService();
|
||||
ClearOnShutdown(&gJSWindowActorService);
|
||||
@ -38,6 +36,7 @@ JSWindowActorService::GetSingleton() {
|
||||
void JSWindowActorService::RegisterWindowActor(
|
||||
const nsAString& aName, const WindowActorOptions& aOptions,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
auto entry = mDescriptors.LookupForAdd(aName);
|
||||
@ -46,7 +45,95 @@ void JSWindowActorService::RegisterWindowActor(
|
||||
return;
|
||||
}
|
||||
|
||||
entry.OrInsert([&] { return &aOptions; });
|
||||
entry.OrInsert([&] { return new WindowActorOptions(aOptions); });
|
||||
|
||||
// Send child's WindowActorOptions to any existing content processes,
|
||||
// because parent's WindowActorOptions can never be accessed in content.
|
||||
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
|
||||
nsTArray<JSWindowActorInfo> infos;
|
||||
infos.AppendElement(
|
||||
JSWindowActorInfo(nsString(aName), aOptions.mChild.mModuleURI));
|
||||
Unused << cp->SendInitJSWindowActorInfos(infos);
|
||||
}
|
||||
}
|
||||
|
||||
void JSWindowActorService::LoadJSWindowActorInfos(
|
||||
nsTArray<JSWindowActorInfo>& aInfos) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
|
||||
for (uint32_t i = 0, len = aInfos.Length(); i < len; i++) {
|
||||
auto entry = mDescriptors.LookupForAdd(aInfos[i].name());
|
||||
|
||||
entry.OrInsert([&] {
|
||||
WindowActorOptions* option = new WindowActorOptions();
|
||||
option->mChild.mModuleURI.Assign(aInfos[i].url());
|
||||
return option;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void JSWindowActorService::GetJSWindowActorInfos(
|
||||
nsTArray<JSWindowActorInfo>& aInfos) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
for (auto iter = mDescriptors.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
aInfos.AppendElement(JSWindowActorInfo(nsString(iter.Key()),
|
||||
iter.Data()->mChild.mModuleURI));
|
||||
}
|
||||
}
|
||||
|
||||
void JSWindowActorService::ConstructActor(const nsAString& aName,
|
||||
bool aParentSide,
|
||||
JS::MutableHandleObject aActor,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT_IF(aParentSide, XRE_IsParentProcess());
|
||||
|
||||
// Constructing an actor requires a running script, so push an AutoEntryScript
|
||||
// onto the stack.
|
||||
AutoEntryScript aes(xpc::PrivilegedJunkScope(), "JSWindowActor construction");
|
||||
JSContext* cx = aes.cx();
|
||||
|
||||
// Load our descriptor
|
||||
const WindowActorOptions* descriptor = mDescriptors.Get(aName);
|
||||
if (!descriptor) {
|
||||
MOZ_ASSERT(false, "WindowActorOptions must be found in mDescriptors");
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
const WindowActorSidedOptions& side =
|
||||
aParentSide ? descriptor->mParent : descriptor->mChild;
|
||||
|
||||
// Load the module using mozJSComponentLoader.
|
||||
RefPtr<mozJSComponentLoader> loader = mozJSComponentLoader::Get();
|
||||
MOZ_ASSERT(loader);
|
||||
|
||||
JS::RootedObject global(cx);
|
||||
JS::RootedObject exports(cx);
|
||||
aRv = loader->Import(cx, side.mModuleURI, &global, &exports);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(exports, "null exports!");
|
||||
|
||||
// Load the specific property from our module.
|
||||
JS::RootedValue ctor(cx);
|
||||
nsAutoString ctorName(aName);
|
||||
ctorName.Append(aParentSide ? NS_LITERAL_STRING("Parent")
|
||||
: NS_LITERAL_STRING("Child"));
|
||||
if (!JS_GetUCProperty(cx, exports, ctorName.get(), ctorName.Length(),
|
||||
&ctor)) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoke the constructor loaded from the module.
|
||||
if (!JS::Construct(cx, ctor, JS::HandleValueArray::empty(), aActor)) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -7,11 +7,13 @@
|
||||
#ifndef mozilla_dom_JSWindowActorService_h
|
||||
#define mozilla_dom_JSWindowActorService_h
|
||||
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
struct WindowActorOptions;
|
||||
class JSWindowActorInfo;
|
||||
|
||||
class JSWindowActorService final {
|
||||
public:
|
||||
@ -23,11 +25,24 @@ class JSWindowActorService final {
|
||||
const WindowActorOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Register child's Window Actor from JSWindowActorInfos for content process.
|
||||
void LoadJSWindowActorInfos(nsTArray<JSWindowActorInfo>& aInfos);
|
||||
|
||||
// Get the named of Window Actor and the child's WindowActorOptions
|
||||
// from mDescriptors to JSWindowActorInfos.
|
||||
void GetJSWindowActorInfos(nsTArray<JSWindowActorInfo>& aInfos);
|
||||
|
||||
// Load the module for the named Window Actor and contruct it.
|
||||
// This method will not initialize the actor or set its manager,
|
||||
// which is handled by callers.
|
||||
void ConstructActor(const nsAString& aName, bool aParentSide,
|
||||
JS::MutableHandleObject aActor, ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
JSWindowActorService();
|
||||
~JSWindowActorService();
|
||||
|
||||
nsDataHashtable<nsStringHashKey, const WindowActorOptions*> mDescriptors;
|
||||
nsClassHashtable<nsStringHashKey, WindowActorOptions> mDescriptors;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -227,6 +227,12 @@ struct BlobURLRegistrationData
|
||||
bool revoked;
|
||||
};
|
||||
|
||||
struct JSWindowActorInfo
|
||||
{
|
||||
nsString name;
|
||||
nsCString url;
|
||||
};
|
||||
|
||||
struct GMPAPITags
|
||||
{
|
||||
nsCString api;
|
||||
@ -528,6 +534,11 @@ child:
|
||||
*/
|
||||
async InitBlobURLs(BlobURLRegistrationData[] registrations);
|
||||
|
||||
/**
|
||||
* Send JSWindowActorInfos to child process.
|
||||
*/
|
||||
async InitJSWindowActorInfos(JSWindowActorInfo[] aInfos);
|
||||
|
||||
async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit,
|
||||
StructuredCloneData initialData,
|
||||
LookAndFeelInt[] lookAndFeelIntCache,
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include "nsIPropertyBag2.h"
|
||||
#include "ProcessPriorityManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
|
||||
// This number is fairly arbitrary ... the intention is to put off
|
||||
// launching another app process until the last one has finished
|
||||
// loading its content, to reduce CPU/memory/IO contention.
|
||||
#define DEFAULT_ALLOCATE_DELAY 1000
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::hal;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/WindowGlobalActorsBinding.h"
|
||||
|
||||
#include "mozilla/dom/JSWindowActorBinding.h"
|
||||
#include "mozilla/dom/JSWindowActorChild.h"
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -108,6 +112,39 @@ void WindowGlobalChild::Destroy() {
|
||||
mIPCClosed = true;
|
||||
}
|
||||
|
||||
already_AddRefed<JSWindowActorChild> WindowGlobalChild::GetActor(
|
||||
const nsAString& aName, ErrorResult& aRv) {
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mWindowActors.Contains(aName)) {
|
||||
return do_AddRef(mWindowActors.GetWeak(aName));
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor. Call into the
|
||||
// JSWindowActorService to trigger construction.
|
||||
RefPtr<JSWindowActorService> actorSvc = JSWindowActorService::GetSingleton();
|
||||
if (!actorSvc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::RootedObject obj(RootingCx());
|
||||
actorSvc->ConstructActor(aName, /* aChildSide */ false, &obj, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSWindowActorChild object.
|
||||
RefPtr<JSWindowActorChild> actor;
|
||||
if (NS_FAILED(UNWRAP_OBJECT(JSWindowActorChild, &obj, actor))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(this);
|
||||
mWindowActors.Put(aName, actor);
|
||||
return actor.forget();
|
||||
}
|
||||
|
||||
void WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
mIPCClosed = true;
|
||||
gWindowGlobalChildById->Remove(mInnerWindowId);
|
||||
@ -128,7 +165,7 @@ nsISupports* WindowGlobalChild::GetParentObject() {
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalChild, mWindowGlobal,
|
||||
mBrowsingContext)
|
||||
mBrowsingContext, mWindowActors)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release)
|
||||
|
@ -19,6 +19,7 @@ namespace dom {
|
||||
|
||||
class BrowsingContext;
|
||||
class WindowGlobalParent;
|
||||
class JSWindowActorChild;
|
||||
|
||||
/**
|
||||
* Actor for a single nsGlobalWindowInner. This actor is used to communicate
|
||||
@ -62,6 +63,10 @@ class WindowGlobalChild : public nsWrapperCache, public PWindowGlobalChild {
|
||||
// |nullptr| if the actor has been torn down, or is in-process.
|
||||
already_AddRefed<TabChild> GetTabChild();
|
||||
|
||||
// Get a JS actor object by name.
|
||||
already_AddRefed<JSWindowActorChild> GetActor(const nsAString& aName,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Create and initialize the WindowGlobalChild object.
|
||||
static already_AddRefed<WindowGlobalChild> Create(
|
||||
nsGlobalWindowInner* aWindow);
|
||||
@ -79,6 +84,7 @@ class WindowGlobalChild : public nsWrapperCache, public PWindowGlobalChild {
|
||||
|
||||
RefPtr<nsGlobalWindowInner> mWindowGlobal;
|
||||
RefPtr<dom::BrowsingContext> mBrowsingContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorChild> mWindowActors;
|
||||
uint64_t mInnerWindowId;
|
||||
uint64_t mOuterWindowId;
|
||||
bool mIPCClosed;
|
||||
|
@ -8,6 +8,14 @@
|
||||
#include "mozilla/ipc/InProcessParent.h"
|
||||
#include "mozilla/dom/ChromeBrowsingContext.h"
|
||||
#include "mozilla/dom/WindowGlobalActorsBinding.h"
|
||||
#include "mozilla/dom/ChromeUtils.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsError.h"
|
||||
|
||||
#include "mozilla/dom/JSWindowActorBinding.h"
|
||||
#include "mozilla/dom/JSWindowActorParent.h"
|
||||
#include "mozilla/dom/JSWindowActorService.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -160,6 +168,39 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<JSWindowActorParent> WindowGlobalParent::GetActor(
|
||||
const nsAString& aName, ErrorResult& aRv) {
|
||||
// Check if this actor has already been created, and return it if it has.
|
||||
if (mWindowActors.Contains(aName)) {
|
||||
return do_AddRef(mWindowActors.GetWeak(aName));
|
||||
}
|
||||
|
||||
// Otherwise, we want to create a new instance of this actor. Call into the
|
||||
// JSWindowActorService to trigger construction
|
||||
RefPtr<JSWindowActorService> actorSvc = JSWindowActorService::GetSingleton();
|
||||
if (!actorSvc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::RootedObject obj(RootingCx());
|
||||
actorSvc->ConstructActor(aName, /* aParentSide */ true, &obj, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Unwrap our actor to a JSWindowActorParent object.
|
||||
RefPtr<JSWindowActorParent> actor;
|
||||
if (NS_FAILED(UNWRAP_OBJECT(JSWindowActorParent, &obj, actor))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!actor->Manager(),
|
||||
"mManager was already initialized once!");
|
||||
actor->Init(this);
|
||||
mWindowActors.Put(aName, actor);
|
||||
return actor.forget();
|
||||
}
|
||||
|
||||
WindowGlobalParent::~WindowGlobalParent() {
|
||||
MOZ_ASSERT(!gWindowGlobalParentsById ||
|
||||
!gWindowGlobalParentsById->Contains(mInnerWindowId));
|
||||
@ -180,7 +221,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WindowGlobalParent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalParent, mFrameLoader,
|
||||
mBrowsingContext)
|
||||
mBrowsingContext, mWindowActors)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WindowGlobalParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WindowGlobalParent)
|
||||
|
@ -21,6 +21,7 @@ namespace dom {
|
||||
|
||||
class ChromeBrowsingContext;
|
||||
class WindowGlobalChild;
|
||||
class JSWindowActorParent;
|
||||
|
||||
/**
|
||||
* A handle in the parent process to a specific nsGlobalWindowInner object.
|
||||
@ -51,6 +52,10 @@ class WindowGlobalParent final : public nsISupports,
|
||||
// |nullptr| if the actor has been torn down, or is not in-process.
|
||||
already_AddRefed<WindowGlobalChild> GetChildActor();
|
||||
|
||||
// Get a JS actor object by name.
|
||||
already_AddRefed<JSWindowActorParent> GetActor(const nsAString& aName,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Get this actor's manager if it is not an in-process actor. Returns
|
||||
// |nullptr| if the actor has been torn down, or is in-process.
|
||||
already_AddRefed<TabParent> GetTabParent();
|
||||
@ -107,6 +112,7 @@ class WindowGlobalParent final : public nsISupports,
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
RefPtr<nsFrameLoader> mFrameLoader;
|
||||
RefPtr<ChromeBrowsingContext> mBrowsingContext;
|
||||
nsRefPtrHashtable<nsStringHashKey, JSWindowActorParent> mWindowActors;
|
||||
uint64_t mInnerWindowId;
|
||||
uint64_t mOuterWindowId;
|
||||
bool mInProcess;
|
||||
|
@ -40,6 +40,8 @@ EXPORTS.mozilla.dom += [
|
||||
'CPOWManagerGetter.h',
|
||||
'DocShellMessageUtils.h',
|
||||
'FilePickerParent.h',
|
||||
'JSWindowActorChild.h',
|
||||
'JSWindowActorParent.h',
|
||||
'JSWindowActorService.h',
|
||||
'MemoryReportRequest.h',
|
||||
'nsIContentChild.h',
|
||||
@ -73,6 +75,8 @@ UNIFIED_SOURCES += [
|
||||
'ContentProcessManager.cpp',
|
||||
'DocShellMessageUtils.cpp',
|
||||
'FilePickerParent.cpp',
|
||||
'JSWindowActorChild.cpp',
|
||||
'JSWindowActorParent.cpp',
|
||||
'JSWindowActorService.cpp',
|
||||
'MemMapSnapshot.cpp',
|
||||
'MemoryReportRequest.cpp',
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/PaymentMethodChangeEventBinding.h"
|
||||
#include "mozilla/dom/PaymentRequestUpdateEvent.h"
|
||||
#include "mozilla/dom/PaymentRequest.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
Loading…
Reference in New Issue
Block a user