Bug 780142 - Rewrite WifiStatusChangeEvent. r=smaug
authorChuck Lee <chulee@mozilla.com>
Mon, 22 Oct 2012 17:17:18 +0800
changeset 111136 76836f462a5b33ada63b7d7c2c07ed48de1d9be1
parent 111135 97474744374cc0fd21ba479abaa05acf1342668d
child 111137 051bc70ec007d3824e4e70c015ccb3ee43a324e9
push id23730
push userryanvm@gmail.com
push dateWed, 24 Oct 2012 02:28:59 +0000
treeherdermozilla-central@93cc1ee94291 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs780142
milestone19.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 780142 - Rewrite WifiStatusChangeEvent. r=smaug
content/events/src/nsDOMWifiEvent.cpp
content/events/src/nsDOMWifiEvent.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/interfaces/events/nsIDOMEvent.idl
dom/interfaces/events/nsIWifiEventInits.idl
dom/wifi/Makefile.in
dom/wifi/nsIDOMMozWifiStatusChangeEvent.idl
dom/wifi/nsIWifi.idl
js/xpconnect/src/dictionary_helper_gen.conf
js/xpconnect/src/event_impl_gen.conf.in
--- a/content/events/src/nsDOMWifiEvent.cpp
+++ b/content/events/src/nsDOMWifiEvent.cpp
@@ -3,87 +3,16 @@
  * 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 "nsDOMWifiEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
 #include "nsDOMClassInfoID.h"
 
-// nsDOMMozWifiStatusChangeEvent
-
-DOMCI_DATA(MozWifiStatusChangeEvent, nsDOMMozWifiStatusChangeEvent)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozWifiStatusChangeEvent)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetwork)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetwork)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_INTERFACE_MAP_BEGIN(nsDOMMozWifiStatusChangeEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozWifiStatusChangeEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozWifiStatusChangeEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMPL_ADDREF_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMMozWifiStatusChangeEvent::GetNetwork(nsIVariant** aNetwork)
-{
-  NS_IF_ADDREF(*aNetwork = mNetwork);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiStatusChangeEvent::GetStatus(nsAString& aStatus)
-{
-  aStatus = mStatus;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiStatusChangeEvent::InitMozWifiStatusChangeEvent(const nsAString& aType,
-                                                            bool aCanBubble,
-                                                            bool aCancelable,
-                                                            nsIVariant* aNetwork,
-                                                            const nsAString& aStatus)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mNetwork = aNetwork;
-  mStatus = aStatus;
-
-  return NS_OK;
-}
-
-nsresult
-nsDOMMozWifiStatusChangeEvent::InitFromCtor(const nsAString& aType,
-                                            JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::MozWifiStatusChangeEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitMozWifiStatusChangeEvent(aType, d.bubbles, d.cancelable, d.network, d.status);
-}
-
-nsresult
-NS_NewDOMMozWifiStatusChangeEvent(nsIDOMEvent** aInstancePtrResult,
-                                  nsPresContext* aPresContext,
-                                  nsEvent* aEvent) 
-{
-  nsDOMMozWifiStatusChangeEvent* e = new nsDOMMozWifiStatusChangeEvent(aPresContext, aEvent);
-  return CallQueryInterface(e, aInstancePtrResult);
-}
-
 // nsDOMMozWifiConnectionInfoEvent
 DOMCI_DATA(MozWifiConnectionInfoEvent, nsDOMMozWifiConnectionInfoEvent)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozWifiConnectionInfoEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetwork)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
--- a/content/events/src/nsDOMWifiEvent.h
+++ b/content/events/src/nsDOMWifiEvent.h
@@ -5,37 +5,16 @@
 
 #ifndef nsDOMWifiEvent_h__
 #define nsDOMWifiEvent_h__
 
 #include "nsIWifi.h"
 #include "nsIWifiEventInits.h"
 #include "nsDOMEvent.h"
 
-class nsDOMMozWifiStatusChangeEvent : public nsDOMEvent,
-                                   public nsIDOMMozWifiStatusChangeEvent
-{
-public:
-  nsDOMMozWifiStatusChangeEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent) {}
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  NS_DECL_NSIDOMMOZWIFISTATUSCHANGEEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-private:
-  nsCOMPtr<nsIVariant> mNetwork;
-  nsString mStatus;
-};
-
 class nsDOMMozWifiConnectionInfoEvent : public nsDOMEvent,
                                         public nsIDOMMozWifiConnectionInfoEvent
 {
 public:
   nsDOMMozWifiConnectionInfoEvent(nsPresContext* aPresContext, nsEvent* aEvent)
     : nsDOMEvent(aPresContext, aEvent) {}
 
   NS_DECL_ISUPPORTS_INHERITED
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1614,18 +1614,16 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MutationObserver, nsDOMMutationObserverSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS |
                            nsIXPCScriptable::WANT_ADDPROPERTY)
   NS_DEFINE_CLASSINFO_DATA(MutationRecord, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #ifdef MOZ_B2G_RIL
-  NS_DEFINE_CLASSINFO_DATA(MozWifiStatusChangeEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozWifiConnectionInfoEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1729,17 +1727,16 @@ NS_DEFINE_CONTRACT_CTOR(MozActivity, NS_
     return rv;                                              \
   }
 
 NS_DEFINE_EVENT_CTOR(Event)
 NS_DEFINE_EVENT_CTOR(UIEvent)
 NS_DEFINE_EVENT_CTOR(MouseEvent)
 NS_DEFINE_EVENT_CTOR(WheelEvent)
 #ifdef MOZ_B2G_RIL
-NS_DEFINE_EVENT_CTOR(MozWifiStatusChangeEvent)
 NS_DEFINE_EVENT_CTOR(MozWifiConnectionInfoEvent)
 #endif
 
 #define MOZ_GENERATED_EVENT_LIST
 #define MOZ_GENERATED_EVENT(_event_interface) \
   NS_DEFINE_EVENT_CTOR(_event_interface)
 #include "GeneratedEvents.h"
 #undef MOZ_GENERATED_EVENT_LIST
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -483,17 +483,16 @@ DOMCI_CLASS(MozCSSKeyframeRule)
 DOMCI_CLASS(MozCSSKeyframesRule)
 
 DOMCI_CLASS(MediaQueryList)
 
 DOMCI_CLASS(MutationObserver)
 DOMCI_CLASS(MutationRecord)
 
 #ifdef MOZ_B2G_RIL
-DOMCI_CLASS(MozWifiStatusChangeEvent)
 DOMCI_CLASS(MozWifiConnectionInfoEvent)
 DOMCI_CLASS(Telephony)
 DOMCI_CLASS(TelephonyCall)
 DOMCI_CLASS(CallEvent)
 DOMCI_CLASS(MozVoicemail)
 DOMCI_CLASS(MozVoicemailEvent)
 DOMCI_CLASS(MozIccManager)
 DOMCI_CLASS(MozStkCommandEvent)
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -324,14 +324,12 @@ nsresult
 NS_NewDOMAnimationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsAnimationEvent* aEvent);
 nsresult
 NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsTouchEvent *aEvent);
 nsresult
 NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMMozSettingsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
-NS_NewDOMMozWifiStatusChangeEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
-nsresult
 NS_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMMozApplicationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 %}
--- a/dom/interfaces/events/nsIWifiEventInits.idl
+++ b/dom/interfaces/events/nsIWifiEventInits.idl
@@ -3,22 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIDOMEventTarget.idl"
 #include "nsIDOMEvent.idl"
 
 interface nsIVariant;
 
-dictionary MozWifiStatusChangeEventInit : EventInit
-{
-  nsIVariant network;
-  DOMString status;
-};
-
 dictionary MozWifiConnectionInfoEventInit : EventInit
 {
   nsIVariant network;
   short signalStrength;
   short relSignalStrength;
   long linkSpeed;
   DOMString ipAddress;
 };
--- a/dom/wifi/Makefile.in
+++ b/dom/wifi/Makefile.in
@@ -14,16 +14,17 @@ LIBRARY_NAME     = domwifi_s
 XPIDL_MODULE     = dom_wifi
 LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/dom/dom-config.mk
 
 XPIDLSRCS = \
   nsIWifi.idl \
+  nsIDOMMozWifiStatusChangeEvent.idl \
   $(NULL)
 
 EXTRA_COMPONENTS = \
   WifiWorker.js \
   WifiWorker.manifest \
   DOMWifiManager.js \
   DOMWifiManager.manifest \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/dom/wifi/nsIDOMMozWifiStatusChangeEvent.idl
@@ -0,0 +1,35 @@
+/* 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"
+
+interface nsIVariant;
+
+[scriptable, builtinclass, uuid(f3ef70b0-b2d3-4eb5-8ea4-008f8d330cd6)]
+interface nsIDOMMozWifiStatusChangeEvent : nsIDOMEvent
+{
+    /**
+     * Network object with a SSID field describing the network affected by
+     * this change. This might be null.
+     */
+    readonly attribute nsIVariant network;
+
+    /**
+     * String describing the current status of the wifi manager. See above for
+     * the possible values.
+     */
+    readonly attribute DOMString status;
+
+    [noscript] void initMozWifiStatusChangeEvent(in DOMString aType,
+                                                 in boolean aCanBubble,
+                                                 in boolean aCancelable,
+                                                 in nsIVariant aNetwork,
+                                                 in DOMString aStatus);
+};
+
+dictionary MozWifiStatusChangeEventInit : EventInit
+{
+  nsIVariant network;
+  DOMString  status;
+};
--- a/dom/wifi/nsIWifi.idl
+++ b/dom/wifi/nsIWifi.idl
@@ -182,38 +182,16 @@ interface nsIDOMWifiManager : nsISupport
     /**
      * These two events fire when the wifi system is brought online or taken
      * offline.
      */
     attribute nsIDOMEventListener onenabled;
     attribute nsIDOMEventListener ondisabled;
 };
 
-[scriptable, builtinclass, uuid(f3ef70b0-b2d3-4eb5-8ea4-008f8d330cd6)]
-interface nsIDOMMozWifiStatusChangeEvent : nsIDOMEvent
-{
-    /**
-     * Network object with a SSID field describing the network affected by
-     * this change. This might be null.
-     */
-    readonly attribute nsIVariant network;
-
-    /**
-     * String describing the current status of the wifi manager. See above for
-     * the possible values.
-     */
-    readonly attribute DOMString status;
-
-    [noscript] void initMozWifiStatusChangeEvent(in DOMString aType,
-                                                 in boolean aCanBubble,
-                                                 in boolean aCancelable,
-                                                 in nsIVariant aNetwork,
-                                                 in DOMString status);
-};
-
 [scriptable, builtinclass, uuid(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
 interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
 {
     /**
      * Network object with an SSID field.
      */
     readonly attribute nsIVariant network;
 
--- a/js/xpconnect/src/dictionary_helper_gen.conf
+++ b/js/xpconnect/src/dictionary_helper_gen.conf
@@ -7,17 +7,16 @@ dictionaries = [
      [ 'EventInit', 'nsIDOMEvent.idl' ],
      [ 'UIEventInit', 'nsIDOMUIEvent.idl' ],
      [ 'MouseEventInit', 'nsIDOMMouseEvent.idl' ],
      [ 'WheelEventInit', 'nsIDOMWheelEvent.idl' ],
      [ 'IDBObjectStoreParameters', 'nsIIDBDatabase.idl' ],
      [ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ],
      [ 'MutationObserverInit', 'nsIDOMMutationObserver.idl' ],
      [ 'WifiConnectionInfoEventInit', 'nsIWifiEventInits.idl' ],
-     [ 'WifiStatusChangeEventInit', 'nsIWifiEventInits.idl' ],
      [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ],
      [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
      [ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],
      [ 'DeviceStorageEnumerationParameters', 'nsIDOMDeviceStorage.idl' ],
      [ 'CameraSize', 'nsIDOMCameraManager.idl' ],
      [ 'CameraRegion', 'nsIDOMCameraManager.idl' ],
      [ 'CameraPosition', 'nsIDOMCameraManager.idl' ],
      [ 'CameraSelector', 'nsIDOMCameraManager.idl' ],
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -23,16 +23,17 @@ simple_events = [
     'DeviceLightEvent',
     'MozApplicationEvent',
 #ifdef MOZ_B2G_BT
     'BluetoothDeviceEvent',
     'BluetoothDeviceAddressEvent',
 #endif
 #ifdef MOZ_B2G_RIL
     'ICCCardLockErrorEvent',
+    'MozWifiStatusChangeEvent',
 #endif
     'DeviceStorageChangeEvent',
     'PopupBlockedEvent'
   ]
 
 """ include file names """
 special_includes = [
     'DictionaryHelpers.h',