Skip to content

Commit

Permalink
Bug 1045100 - This is 1 of 2 patches. This patch replaces the custom …
Browse files Browse the repository at this point in the history
…"PluginCrashed" event with "PluginCrashedEvent." The "PluginCrashedEvent" is a a WebIDL binding. r=smaug r=gfritzsche
  • Loading branch information
cojennin2 committed Oct 22, 2014
1 parent 4685611 commit 2d96083
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 87 deletions.
57 changes: 12 additions & 45 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#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"
Expand Down Expand Up @@ -326,55 +327,21 @@ nsPluginCrashedEvent::Run()
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;
}
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);

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);
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;
}
Expand Down
26 changes: 26 additions & 0 deletions dom/webidl/PluginCrashedEvent.webidl
Original file line number Diff line number Diff line change
@@ -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;
};
1 change: 1 addition & 0 deletions dom/webidl/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'MozStkCommandEvent.webidl',
'MozVoicemailEvent.webidl',
'PageTransitionEvent.webidl',
'PluginCrashedEvent.webidl',
'PopStateEvent.webidl',
'PopupBlockedEvent.webidl',
'ProgressEvent.webidl',
Expand Down
52 changes: 10 additions & 42 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#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"
Expand Down Expand Up @@ -1789,53 +1790,20 @@ PeerConnectionImpl::PluginCrash(uint64_t aPluginID,
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;
}
PluginCrashedEventInit init;
init.mPluginDumpID = aPluginDumpID;
init.mPluginName = aPluginName;
init.mSubmittedCrashReport = false;
init.mGmpPlugin = true;
init.mBubbles = true;
init.mCancelable = 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;
}
nsRefPtr<PluginCrashedEvent> event =
PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init);

customEvent->InitCustomEvent(NS_LITERAL_STRING("PluginCrashed"),
true, true, variant);
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

Expand Down

0 comments on commit 2d96083

Please sign in to comment.