Bug 1527625 - Fill required arguments for ReceiveMessageArgument, r=nika
authorJohn Dai <jdai@mozilla.com>
Tue, 05 Mar 2019 17:12:40 +0000
changeset 520286 c0b27a35fb4cd2607f5e82883c625c0168e40d55
parent 520285 7a6be593b0be702b6a404ce9c54341f351e8e953
child 520287 2b3c223c6e3ed5235501f8c0eb4636396f74eb92
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1527625
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527625 - Fill required arguments for ReceiveMessageArgument, r=nika Differential Revision: https://phabricator.services.mozilla.com/D21987
dom/ipc/JSWindowActorChild.cpp
dom/ipc/JSWindowActorChild.h
dom/ipc/JSWindowActorParent.cpp
dom/ipc/JSWindowActorParent.h
dom/ipc/JSWindowActorService.cpp
dom/ipc/JSWindowActorService.h
dom/ipc/WindowGlobalChild.cpp
dom/ipc/WindowGlobalParent.cpp
--- a/dom/ipc/JSWindowActorChild.cpp
+++ b/dom/ipc/JSWindowActorChild.cpp
@@ -103,15 +103,20 @@ void JSWindowActorChild::SendAsyncMessag
 
   if (!mManager->SendAsyncMessage(mName, PromiseFlatString(aMessageName),
                                   msgData)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 }
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorChild, mManager)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JSWindowActorChild)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(JSWindowActorChild, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(JSWindowActorChild, Release)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(JSWindowActorChild)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(JSWindowActorChild)
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorChild, mManager)
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/JSWindowActorChild.h
+++ b/dom/ipc/JSWindowActorChild.h
@@ -20,20 +20,20 @@ namespace dom {
 class WindowGlobalChild;
 
 }  // namespace dom
 }  // namespace mozilla
 
 namespace mozilla {
 namespace dom {
 
-class JSWindowActorChild final : public nsWrapperCache {
+class JSWindowActorChild final : public nsISupports, public nsWrapperCache {
  public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(JSWindowActorChild)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(JSWindowActorChild)
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(JSWindowActorChild)
 
  protected:
   ~JSWindowActorChild() = default;
 
  public:
   nsISupports* GetParentObject() const;
 
   JSObject* WrapObject(JSContext* aCx,
--- a/dom/ipc/JSWindowActorParent.cpp
+++ b/dom/ipc/JSWindowActorParent.cpp
@@ -102,15 +102,20 @@ void JSWindowActorParent::SendAsyncMessa
 
   if (!mManager->SendAsyncMessage(mName, PromiseFlatString(aMessageName),
                                   msgData)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 }
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorParent, mManager)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JSWindowActorParent)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(JSWindowActorParent, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(JSWindowActorParent, Release)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(JSWindowActorParent)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(JSWindowActorParent)
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(JSWindowActorParent, mManager)
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/JSWindowActorParent.h
+++ b/dom/ipc/JSWindowActorParent.h
@@ -20,20 +20,20 @@ namespace dom {
 class WindowGlobalParent;
 
 }  // namespace dom
 }  // namespace mozilla
 
 namespace mozilla {
 namespace dom {
 
-class JSWindowActorParent final : public nsWrapperCache {
+class JSWindowActorParent final : public nsISupports, public nsWrapperCache {
  public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(JSWindowActorParent)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(JSWindowActorParent)
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(JSWindowActorParent)
 
  protected:
   ~JSWindowActorParent() = default;
 
  public:
   nsISupports* GetParentObject() const;
 
   JSObject* WrapObject(JSContext* aCx,
--- a/dom/ipc/JSWindowActorService.cpp
+++ b/dom/ipc/JSWindowActorService.cpp
@@ -552,17 +552,18 @@ void JSWindowActorService::ConstructActo
 
   // Invoke the constructor loaded from the module.
   if (!JS::Construct(cx, ctor, JS::HandleValueArray::empty(), aActor)) {
     aRv.NoteJSContextException(cx);
     return;
   }
 }
 
-void JSWindowActorService::ReceiveMessage(JS::RootedObject& aObj,
+void JSWindowActorService::ReceiveMessage(nsISupports* aTarget,
+                                          JS::RootedObject& aObj,
                                           const nsString& aMessageName,
                                           ipc::StructuredCloneData& aData) {
   IgnoredErrorResult error;
   AutoEntryScript aes(aObj, "WindowGlobalChild Message Handler");
   JSContext* cx = aes.cx();
 
   // We passed the unwrapped object to AutoEntryScript so we now need to
   // enter the realm of the global object that represents the realm of our
@@ -574,19 +575,22 @@ void JSWindowActorService::ReceiveMessag
   aData.Read(aes.cx(), &json, error);
   if (NS_WARN_IF(error.Failed())) {
     JS_ClearPendingException(cx);
     return;
   }
 
   RootedDictionary<ReceiveMessageArgument> argument(cx);
   argument.mObjects = JS_NewPlainObject(cx);
+  argument.mTarget = aTarget;
   argument.mName = aMessageName;
   argument.mData = json;
   argument.mJson = json;
+  argument.mSync = false;
+
   JS::RootedValue argv(cx);
   if (NS_WARN_IF(!ToJSValue(cx, argument, &argv))) {
     return;
   }
 
   // Now that we have finished, call the recvAsyncMessage callback.
   JS::RootedValue dummy(cx);
   if (NS_WARN_IF(!JS_CallFunctionName(cx, aObj, "recvAsyncMessage",
--- a/dom/ipc/JSWindowActorService.h
+++ b/dom/ipc/JSWindowActorService.h
@@ -38,17 +38,18 @@ class JSWindowActorService final {
 
   // 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,
                       BrowsingContext* aBrowsingContext,
                       JS::MutableHandleObject aActor, ErrorResult& aRv);
 
-  void ReceiveMessage(JS::RootedObject& aObj, const nsString& aMessageName,
+  void ReceiveMessage(nsISupports* aActor, JS::RootedObject& aObj,
+                      const nsString& aMessageName,
                       ipc::StructuredCloneData& aData);
 
   // Register or unregister a WindowRoot object from this JSWindowActorService.
   void RegisterWindowRoot(EventTarget* aRoot);
 
   // NOTE: This method is static, as it may be called during shutdown.
   static void UnregisterWindowRoot(EventTarget* aRoot);
 
--- a/dom/ipc/WindowGlobalChild.cpp
+++ b/dom/ipc/WindowGlobalChild.cpp
@@ -143,17 +143,17 @@ void WindowGlobalChild::HandleAsyncMessa
     return;
   }
 
   RefPtr<JSWindowActorService> actorSvc = JSWindowActorService::GetSingleton();
   if (NS_WARN_IF(!actorSvc)) {
     return;
   }
 
-  actorSvc->ReceiveMessage(obj, aMessageName, aData);
+  actorSvc->ReceiveMessage(actor, obj, aMessageName, aData);
 }
 
 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));
   }
--- a/dom/ipc/WindowGlobalParent.cpp
+++ b/dom/ipc/WindowGlobalParent.cpp
@@ -186,17 +186,17 @@ void WindowGlobalParent::HandleAsyncMess
     return;
   }
 
   RefPtr<JSWindowActorService> actorSvc = JSWindowActorService::GetSingleton();
   if (NS_WARN_IF(!actorSvc)) {
     return;
   }
 
-  actorSvc->ReceiveMessage(obj, aMessageName, aData);
+  actorSvc->ReceiveMessage(actor, obj, aMessageName, aData);
 }
 
 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));
   }