Bug 744700 - B2G 3G: Notify connection errors in the WebMobileConnection API, r=bent
☠☠ backed out by b5289c1f03c0 ☠ ☠
authorFernando Rodríguez Sela <frsela@tid.es>
Fri, 07 Sep 2012 12:48:16 -0700
changeset 106695 1566e8499cb8f15b5c477142223a87c3455b3904
parent 106694 f0f098ac43867c3abe2811c48ac2a8e3ad0e1721
child 106696 fcc61274ec4398bad33c7c2d1cc8e96fbe656725
push id74
push usershu@rfrn.org
push dateTue, 18 Sep 2012 19:23:47 +0000
reviewersbent
bugs744700
milestone18.0a1
Bug 744700 - B2G 3G: Notify connection errors in the WebMobileConnection API, r=bent
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/network/interfaces/Makefile.in
dom/network/interfaces/nsIDOMDataErrorEvent.idl
dom/network/src/DataErrorEvent.cpp
dom/network/src/DataErrorEvent.h
dom/network/src/Makefile.in
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -500,16 +500,17 @@ using mozilla::dom::indexedDB::IDBWrappe
 #include "nsIDOMSmsRequest.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsCursor.h"
 #include "nsIDOMConnection.h"
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMMobileConnection.h"
 #endif
 #include "USSDReceivedEvent.h"
+#include "DataErrorEvent.h"
 #include "mozilla/dom/network/Utils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "CallEvent.h"
 #include "nsIDOMVoicemail.h"
 #include "nsIDOMVoicemailEvent.h"
@@ -1499,16 +1500,19 @@ static nsDOMClassInfoData sClassInfoData
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
+  NS_DEFINE_CLASSINFO_DATA(DataErrorEvent, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
                            ARRAY_SCRIPTABLE_FLAGS)
 
 #if defined(MOZ_MEDIA)
   NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
@@ -4151,16 +4155,21 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 #endif
 
   DOM_CLASSINFO_MAP_BEGIN(USSDReceivedEvent, nsIDOMUSSDReceivedEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMUSSDReceivedEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
   DOM_CLASSINFO_MAP_END
  
+  DOM_CLASSINFO_MAP_BEGIN(DataErrorEvent, nsIDOMDataErrorEvent)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataErrorEvent)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
+  DOM_CLASSINFO_MAP_END
+
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
                                       nsIDOMCSSStyleDeclaration)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
   DOM_CLASSINFO_MAP_END
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -409,16 +409,18 @@ DOMCI_CLASS(MozSmsCursor)
 
 DOMCI_CLASS(MozConnection)
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(MozMobileConnection)
 #endif
 
 DOMCI_CLASS(USSDReceivedEvent)
 
+DOMCI_CLASS(DataErrorEvent)
+
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
 DOMCI_CLASS(CSSFontFaceStyleDecl)
 
 #if defined(MOZ_MEDIA)
 // WhatWG Video Element
 DOMCI_CLASS(HTMLVideoElement)
 DOMCI_CLASS(HTMLSourceElement)
--- a/dom/network/interfaces/Makefile.in
+++ b/dom/network/interfaces/Makefile.in
@@ -13,16 +13,17 @@ XPIDL_MODULE = dom_network
 
 include $(topsrcdir)/dom/dom-config.mk
 
 XPIDLSRCS = \
   nsIDOMNavigatorNetwork.idl \
   nsIDOMConnection.idl \
   nsIDOMUSSDReceivedEvent.idl \
   nsIDOMTCPSocket.idl \
+  nsIDOMDataErrorEvent.idl \
   $(NULL)
 
 ifdef MOZ_B2G_RIL
 XPIDLSRCS += \
   nsIDOMMobileConnection.idl \
   nsIMobileConnectionProvider.idl \
   nsINavigatorMobileConnection.idl \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/dom/network/interfaces/nsIDOMDataErrorEvent.idl
@@ -0,0 +1,11 @@
+/* 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 "nsIDOMEvent.idl"
+
+[scriptable, builtinclass, uuid(1cfc45ba-c5d4-11e1-b4c3-00265511db39)]
+interface nsIDOMDataErrorEvent : nsIDOMEvent
+{
+  readonly attribute DOMString message;
+};
new file mode 100644
--- /dev/null
+++ b/dom/network/src/DataErrorEvent.cpp
@@ -0,0 +1,43 @@
+/* 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 "DataErrorEvent.h"
+#include "nsIDOMClassInfo.h"
+
+DOMCI_DATA(DataErrorEvent, mozilla::dom::network::DataErrorEvent)
+
+namespace mozilla {
+namespace dom {
+namespace network {
+
+already_AddRefed<DataErrorEvent>
+DataErrorEvent::Create(nsAString& aMessage)
+{
+  NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
+
+  nsRefPtr<DataErrorEvent> event = new DataErrorEvent();
+
+  event->mMessage = aMessage;
+
+  return event.forget();
+}
+
+NS_IMPL_ADDREF_INHERITED(DataErrorEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(DataErrorEvent, nsDOMEvent)
+
+NS_INTERFACE_MAP_BEGIN(DataErrorEvent)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMDataErrorEvent)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataErrorEvent)
+NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
+
+NS_IMETHODIMP
+DataErrorEvent::GetMessage(nsAString& aMessage)
+{
+  aMessage.Assign(mMessage);
+  return NS_OK;
+}
+
+}
+}
+}
new file mode 100644
--- /dev/null
+++ b/dom/network/src/DataErrorEvent.h
@@ -0,0 +1,63 @@
+/* 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_network_dataerrorevent_h
+#define mozilla_dom_network_dataerrorevent_h
+
+#include "nsIDOMDataErrorEvent.h"
+#include "nsDOMEvent.h"
+
+namespace mozilla {
+namespace dom {
+namespace network {
+
+class DataErrorEvent : public nsDOMEvent,
+                       public nsIDOMDataErrorEvent
+{
+  nsString mMessage;
+
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_FORWARD_TO_NSDOMEVENT
+  NS_DECL_NSIDOMDATAERROREVENT
+
+  static already_AddRefed<DataErrorEvent>
+  Create(nsAString& aMessage);
+
+  nsresult
+  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
+  {
+    NS_ASSERTION(aTarget, "Null pointer!");
+    NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
+
+    nsresult rv = InitEvent(aEventType, false, false);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    rv = SetTrusted(true);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsIDOMEvent* thisEvent =
+      static_cast<nsDOMEvent*>(const_cast<DataErrorEvent*>(this));
+
+    bool dummy;
+    rv = aTarget->DispatchEvent(thisEvent, &dummy);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    return NS_OK;
+  }
+
+private:
+  DataErrorEvent()
+  : nsDOMEvent(nullptr, nullptr)
+  { }
+
+  ~DataErrorEvent()
+  { }
+};
+
+}
+}
+}
+
+#endif // mozilla_dom_network_dataerrorevent_h
--- a/dom/network/src/Makefile.in
+++ b/dom/network/src/Makefile.in
@@ -27,16 +27,17 @@ EXPORTS_mozilla/dom/network = \
   Types.h \
   Constants.h \
   $(NULL)
 
 CPPSRCS = \
   Connection.cpp \
   Utils.cpp \
   USSDReceivedEvent.cpp \
+  DataErrorEvent.cpp \
   $(NULL)
 
 ifdef MOZ_B2G_RIL
 CPPSRCS += \
   MobileConnection.cpp \
   $(NULL)
 endif