Bug 1045100 - This is 1 of 2 patches. This patch replaces the custom "PluginCrashed" event with "PluginCrashedEvent." The "PluginCrashedEvent" is a a WebIDL binding. r=smaug r=gfritzsche
authorConnor <cojojennings@gmail.com>
Tue, 21 Oct 2014 23:40:12 -0400
changeset 240809 b7acf8f21edc6f4336348648cf05bdccb728ff25
parent 240808 c3f8e00d646e7ba160b9d26ddb1e2c5695370ee1
child 240810 f46bc389856da1d7ecbc09b3406d9e1c0bd735f2
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, gfritzsche
bugs1045100
milestone36.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 1045100 - This is 1 of 2 patches. This patch replaces the custom "PluginCrashed" event with "PluginCrashedEvent." The "PluginCrashedEvent" is a a WebIDL binding. r=smaug r=gfritzsche
dom/base/nsObjectLoadingContent.cpp
dom/webidl/PluginCrashedEvent.webidl
dom/webidl/moz.build
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -73,16 +73,17 @@
 
 #include "nsWidgetsCID.h"
 #include "nsContentCID.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/dom/PluginCrashedEvent.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 
 #ifdef XP_WIN
 // Thanks so much, Microsoft! :(
 #ifdef CreateEvent
@@ -321,65 +322,31 @@ nsPluginCrashedEvent::Run()
        mContent.get()));
 
   nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
   if (!doc) {
     NS_WARNING("Couldn't get document for PluginCrashed event!");
     return NS_OK;
   }
 
-  ErrorResult rv;
-  nsRefPtr<Event> event =
-    doc->CreateEvent(NS_LITERAL_STRING("customevent"), rv);
-  nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryObject(event));
-  if (!customEvent) {
-    NS_WARNING("Couldn't QI event for PluginCrashed event!");
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIWritableVariant> variant;
-  variant = do_CreateInstance("@mozilla.org/variant;1");
-  if (!variant) {
-    NS_WARNING("Couldn't create detail variant for PluginCrashed event!");
-    return NS_OK;
-  }
-  customEvent->InitCustomEvent(NS_LITERAL_STRING("PluginCrashed"),
-                               true, true, variant);
+  PluginCrashedEventInit init;
+  init.mPluginDumpID = mPluginDumpID;
+  init.mBrowserDumpID = mBrowserDumpID;
+  init.mPluginName = mPluginName;
+  init.mPluginFilename = mPluginFilename;
+  init.mSubmittedCrashReport = mSubmittedCrashReport;
+  init.mBubbles = true;
+  init.mCancelable = true;
+
+  nsRefPtr<PluginCrashedEvent> event =
+    PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init);
+
   event->SetTrusted(true);
   event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
 
-  nsCOMPtr<nsIWritablePropertyBag2> propBag;
-  propBag = do_CreateInstance("@mozilla.org/hash-property-bag;1");
-  if (!propBag) {
-    NS_WARNING("Couldn't create a property bag for PluginCrashed event!");
-    return NS_OK;
-  }
-
-  // add a "pluginDumpID" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginDumpID"),
-                                mPluginDumpID);
-
-  // add a "browserDumpID" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("browserDumpID"),
-                                mBrowserDumpID);
-
-  // add a "pluginName" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginName"),
-                                mPluginName);
-
-  // add a "pluginFilename" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginFilename"),
-                                mPluginFilename);
-
-  // add a "submittedCrashReport" property to this event
-  propBag->SetPropertyAsBool(NS_LITERAL_STRING("submittedCrashReport"),
-                             mSubmittedCrashReport);
-
-  variant->SetAsISupports(propBag);
-
   EventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr);
   return NS_OK;
 }
 
 class nsStopPluginRunnable : public nsRunnable, public nsITimerCallback
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PluginCrashedEvent.webidl
@@ -0,0 +1,26 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/.
+ */
+
+[Constructor(DOMString type, optional PluginCrashedEventInit eventInitDict), ChromeOnly]
+interface PluginCrashedEvent : Event
+{
+  readonly attribute DOMString pluginDumpID;
+  readonly attribute DOMString pluginName;
+  readonly attribute DOMString? browserDumpID;
+  readonly attribute DOMString? pluginFilename;
+  readonly attribute boolean submittedCrashReport;
+  readonly attribute boolean gmpPlugin;
+};
+
+dictionary PluginCrashedEventInit : EventInit
+{
+  DOMString pluginDumpID = "";
+  DOMString pluginName = "";
+  DOMString? browserDumpID = null;
+  DOMString? pluginFilename = null;
+  boolean submittedCrashReport = false;
+  boolean gmpPlugin = false;
+};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -709,16 +709,17 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'MozMmsEvent.webidl',
     'MozOtaStatusEvent.webidl',
     'MozSettingsEvent.webidl',
     'MozSettingsTransactionEvent.webidl',
     'MozSmsEvent.webidl',
     'MozStkCommandEvent.webidl',
     'MozVoicemailEvent.webidl',
     'PageTransitionEvent.webidl',
+    'PluginCrashedEvent.webidl',
     'PopStateEvent.webidl',
     'PopupBlockedEvent.webidl',
     'ProgressEvent.webidl',
     'RecordErrorEvent.webidl',
     'RTCDataChannelEvent.webidl',
     'RTCPeerConnectionIceEvent.webidl',
     'RTCPeerConnectionIdentityErrorEvent.webidl',
     'RTCPeerConnectionIdentityEvent.webidl',
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -73,16 +73,17 @@
 #include "nsIDOMLocation.h"
 #include "nsNullPrincipal.h"
 #include "mozilla/PeerIdentity.h"
 #include "mozilla/dom/RTCConfigurationBinding.h"
 #include "mozilla/dom/RTCStatsReportBinding.h"
 #include "mozilla/dom/RTCPeerConnectionBinding.h"
 #include "mozilla/dom/PeerConnectionImplBinding.h"
 #include "mozilla/dom/DataChannelBinding.h"
+#include "mozilla/dom/PluginCrashedEvent.h"
 #include "MediaStreamList.h"
 #include "MediaStreamTrack.h"
 #include "AudioStreamTrack.h"
 #include "VideoStreamTrack.h"
 #include "nsIScriptGlobalObject.h"
 #include "DOMMediaStream.h"
 #include "rlogringbuffer.h"
 #include "WebrtcGlobalInformation.h"
@@ -1784,63 +1785,30 @@ PeerConnectionImpl::PluginCrash(uint64_t
 
 #ifdef MOZILLA_INTERNAL_API
   nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
   if (!doc) {
     NS_WARNING("Couldn't get document for PluginCrashed event!");
     return true;
   }
 
-  ErrorResult rv;
-  nsRefPtr<Event> event =
-    doc->CreateEvent(NS_LITERAL_STRING("customevent"), rv);
-  nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryObject(event));
-  if (!customEvent) {
-    NS_WARNING("Couldn't QI event for PluginCrashed event!");
-    return true;
-  }
-
-  nsCOMPtr<nsIWritableVariant> variant;
-  variant = do_CreateInstance("@mozilla.org/variant;1");
-  if (!variant) {
-    NS_WARNING("Couldn't create detail variant for PluginCrashed event!");
-    return true;
-  }
-
-  customEvent->InitCustomEvent(NS_LITERAL_STRING("PluginCrashed"),
-                               true, true, variant);
+  PluginCrashedEventInit init;
+  init.mPluginDumpID = aPluginDumpID;
+  init.mPluginName = aPluginName;
+  init.mSubmittedCrashReport = false;
+  init.mGmpPlugin = true;
+  init.mBubbles = true;
+  init.mCancelable = true;
+
+  nsRefPtr<PluginCrashedEvent> event =
+    PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init);
+
   event->SetTrusted(true);
   event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
 
-  nsCOMPtr<nsIWritablePropertyBag2> propBag;
-  propBag = do_CreateInstance("@mozilla.org/hash-property-bag;1");
-  if (!propBag) {
-    NS_WARNING("Couldn't create a property bag for PluginCrashed event!");
-    return true;
-  }
-
-  // add a "pluginDumpID" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginDumpID"),
-                                aPluginDumpID);
-
-
-  // add a "pluginName" property to this event
-  propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginName"),
-                                aPluginName);
-
-  // add a "pluginName" property to this event
-  propBag->SetPropertyAsBool(NS_LITERAL_STRING("gmpPlugin"),
-                             true);
-
-  // add a "submittedCrashReport" property to this event
-  propBag->SetPropertyAsBool(NS_LITERAL_STRING("submittedCrashReport"),
-                             false);
-
-  variant->SetAsISupports(propBag);
-
   EventDispatcher::DispatchDOMEvent(mWindow, nullptr, event, nullptr, nullptr);
 #endif
 
   return true;
 }
 
 nsresult
 PeerConnectionImpl::CloseInt()