Bug 1318506 - Label PluginInstance IPC messages with plugin's DocGroup (r?aklotz) draft
authorBill McCloskey <billm@mozilla.com>
Tue, 15 Nov 2016 15:35:54 -0800
changeset 440693 f23356f3f18a4f703ba8b83cb1a2d0d3b66fe8c7
parent 440692 491b40571d4cb0220bfb96230c6ebe15ead85e44
child 440694 c43128ccf21b0e70874b076c91de27c5e7abba17
push id36297
push userbmo:wmccloskey@mozilla.com
push dateFri, 18 Nov 2016 00:53:48 +0000
reviewersaklotz
bugs1318506
milestone53.0a1
Bug 1318506 - Label PluginInstance IPC messages with plugin's DocGroup (r?aklotz) The goal here is to assign a DocGroup to every runnable. This patch labels all IPC message handlers for PPluginInstance with the DocGroup of the plugin instance's document. MozReview-Commit-ID: 6OIard9n2GB
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -2751,16 +2751,27 @@ PluginModuleParent::NPP_NewInternal(NPMI
     }
 
     // Release the surrogate reference that was in pdata
     RefPtr<PluginAsyncSurrogate> surrogate(
         dont_AddRef(PluginAsyncSurrogate::Cast(instance)));
     // Now replace it with the instance
     instance->pdata = static_cast<PluginDataResolver*>(parentInstance);
 
+    RefPtr<nsPluginInstanceOwner> owner = parentInstance->GetOwner();
+    nsCOMPtr<nsIDOMElement> elt;
+    owner->GetDOMElement(getter_AddRefs(elt));
+    if (nsCOMPtr<nsINode> node = do_QueryInterface(elt)) {
+        nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
+        if (doc) {
+            nsCOMPtr<nsIEventTarget> eventTarget = doc->CreateEventTarget("Plugin", dom::TaskCategory::Other);
+            SetEventTargetForActor(parentInstance, eventTarget);
+        }
+    }
+
     if (!SendPPluginInstanceConstructor(parentInstance,
                                         nsDependentCString(pluginType), mode,
                                         names, values)) {
         // |parentInstance| is automatically deleted.
         instance->pdata = nullptr;
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }