Bug 780142 - Rewrite MozWifiConnectionInfoEvent. r=smaug
authorChuck Lee <chulee@mozilla.com>
Mon, 22 Oct 2012 18:18:26 +0800
changeset 111137 051bc70ec007d3824e4e70c015ccb3ee43a324e9
parent 111136 76836f462a5b33ada63b7d7c2c07ed48de1d9be1
child 111138 e2e34182037317be0897425d288bea304b7a63eb
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs780142
milestone19.0a1
Bug 780142 - Rewrite MozWifiConnectionInfoEvent. r=smaug
content/events/src/Makefile.in
content/events/src/nsDOMWifiEvent.cpp
content/events/src/nsDOMWifiEvent.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/interfaces/events/Makefile.in
dom/interfaces/events/nsIDOMEvent.idl
dom/interfaces/events/nsIWifiEventInits.idl
dom/wifi/Makefile.in
dom/wifi/nsIDOMMozWifiConnectionInfoEvent.idl
dom/wifi/nsIWifi.idl
js/xpconnect/src/dictionary_helper_gen.conf
js/xpconnect/src/event_impl_gen.conf.in
--- a/content/events/src/Makefile.in
+++ b/content/events/src/Makefile.in
@@ -59,22 +59,16 @@ CPPSRCS		= \
 		nsDOMTransitionEvent.cpp \
 		nsDOMAnimationEvent.cpp \
 		nsDOMTouchEvent.cpp \
 		nsDOMCompositionEvent.cpp \
 		DOMWheelEvent.cpp \
 		TextComposition.cpp \
 		$(NULL)
 
-ifdef MOZ_B2G_RIL
-CPPSRCS += \
-    nsDOMWifiEvent.cpp \
-    $(NULL)
-endif
-
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	+= \
deleted file mode 100644
--- a/content/events/src/nsDOMWifiEvent.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C++; 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/. */
-
-#include "nsDOMWifiEvent.h"
-#include "nsContentUtils.h"
-#include "DictionaryHelpers.h"
-#include "nsDOMClassInfoID.h"
-
-// 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
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetwork)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_INTERFACE_MAP_BEGIN(nsDOMMozWifiConnectionInfoEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozWifiConnectionInfoEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozWifiConnectionInfoEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMPL_ADDREF_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::GetNetwork(nsIVariant** aNetwork)
-{
-  NS_IF_ADDREF(*aNetwork = mNetwork);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::GetSignalStrength(int16_t* aSignalStrength)
-{
-  *aSignalStrength = mSignalStrength;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::GetRelSignalStrength(int16_t* aRelSignalStrength)
-{
-  *aRelSignalStrength = mRelSignalStrength;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::GetLinkSpeed(int32_t* aLinkSpeed)
-{
-  *aLinkSpeed = mLinkSpeed;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::GetIpAddress(nsAString& aIpAddress)
-{
-    aIpAddress = mIpAddress;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMMozWifiConnectionInfoEvent::InitMozWifiConnectionInfoEvent(const nsAString& aType,
-                                                                bool aCanBubble,
-                                                                bool aCancelable,
-                                                                nsIVariant *aNetwork,
-                                                                int16_t aSignalStrength,
-                                                                int16_t aRelSignalStrength,
-                                                                int32_t aLinkSpeed,
-                                                                const nsAString &aIpAddress)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mNetwork = aNetwork;
-  mSignalStrength = aSignalStrength;
-  mRelSignalStrength = aRelSignalStrength;
-  mLinkSpeed = aLinkSpeed;
-  mIpAddress = aIpAddress;
-
-  return NS_OK;
-}
-
-nsresult
-nsDOMMozWifiConnectionInfoEvent::InitFromCtor(const nsAString& aType,
-                                              JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::MozWifiConnectionInfoEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitMozWifiConnectionInfoEvent(aType, d.bubbles, d.cancelable, d.network,
-                                        d.signalStrength, d.relSignalStrength, d.linkSpeed,
-                                        d.ipAddress);
-}
-
-nsresult
-NS_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult,
-                                    nsPresContext* aPresContext,
-                                    nsEvent* aEvent) 
-{
-  nsDOMMozWifiConnectionInfoEvent* e = new nsDOMMozWifiConnectionInfoEvent(aPresContext, aEvent);
-  return CallQueryInterface(e, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMWifiEvent.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; 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/. */
-
-#ifndef nsDOMWifiEvent_h__
-#define nsDOMWifiEvent_h__
-
-#include "nsIWifi.h"
-#include "nsIWifiEventInits.h"
-#include "nsDOMEvent.h"
-
-class nsDOMMozWifiConnectionInfoEvent : public nsDOMEvent,
-                                        public nsIDOMMozWifiConnectionInfoEvent
-{
-public:
-  nsDOMMozWifiConnectionInfoEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent) {}
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  NS_DECL_NSIDOMMOZWIFICONNECTIONINFOEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-private:
-  nsCOMPtr<nsIVariant> mNetwork;
-  int16_t mSignalStrength;
-  int16_t mRelSignalStrength;
-  int32_t mLinkSpeed;
-  nsString mIpAddress;
-};
-
-#endif // nsDOMWifiEvent_h__
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -174,17 +174,16 @@
 #include "nsEventSource.h"
 #include "nsIDOMSettingsManager.h"
 #include "nsIDOMContactManager.h"
 #include "nsIDOMPermissionSettings.h"
 #include "nsIDOMApplicationRegistry.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIWifi.h"
-#include "nsIWifiEventInits.h"
 #endif
 
 // includes needed for the prototype chain interfaces
 #include "nsIDOMNavigator.h"
 #include "nsIDOMBarProp.h"
 #include "nsIDOMScreen.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIDOMDocumentFragment.h"
@@ -1614,18 +1613,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(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)
   NS_DEFINE_CLASSINFO_DATA(MozVoicemail, nsEventTargetSH,
                            EVENTTARGET_SCRIPTABLE_FLAGS)
@@ -1726,19 +1723,16 @@ NS_DEFINE_CONTRACT_CTOR(MozActivity, NS_
     *aInstancePtrResult = e;                                \
     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(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
 
 nsresult
--- 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(MozWifiConnectionInfoEvent)
 DOMCI_CLASS(Telephony)
 DOMCI_CLASS(TelephonyCall)
 DOMCI_CLASS(CallEvent)
 DOMCI_CLASS(MozVoicemail)
 DOMCI_CLASS(MozVoicemailEvent)
 DOMCI_CLASS(MozIccManager)
 DOMCI_CLASS(MozStkCommandEvent)
 #endif
--- a/dom/interfaces/events/Makefile.in
+++ b/dom/interfaces/events/Makefile.in
@@ -52,16 +52,15 @@ XPIDLSRCS =					\
 	nsIDOMAnimationEvent.idl		\
 	nsIDOMPopStateEvent.idl			\
 	nsIDOMCloseEvent.idl			\
 	nsIDOMTouchEvent.idl			\
 	nsIDOMHashChangeEvent.idl		\
 	nsIDOMCustomEvent.idl			\
 	nsIDOMCompositionEvent.idl		\
 	nsIDOMWheelEvent.idl			\
-	nsIWifiEventInits.idl \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 XPIDL_FLAGS += \
   -I$(topsrcdir)/dom/interfaces/base \
   $(NULL)
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -324,12 +324,10 @@ 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_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
-nsresult
 NS_NewDOMMozApplicationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 %}
deleted file mode 100644
--- a/dom/interfaces/events/nsIWifiEventInits.idl
+++ /dev/null
@@ -1,18 +0,0 @@
-/* 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 "nsISupports.idl"
-#include "nsIDOMEventTarget.idl"
-#include "nsIDOMEvent.idl"
-
-interface nsIVariant;
-
-dictionary MozWifiConnectionInfoEventInit : EventInit
-{
-  nsIVariant network;
-  short signalStrength;
-  short relSignalStrength;
-  long linkSpeed;
-  DOMString ipAddress;
-};
--- a/dom/wifi/Makefile.in
+++ b/dom/wifi/Makefile.in
@@ -15,16 +15,17 @@ XPIDL_MODULE     = dom_wifi
 LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/dom/dom-config.mk
 
 XPIDLSRCS = \
   nsIWifi.idl \
   nsIDOMMozWifiStatusChangeEvent.idl \
+  nsIDOMMozWifiConnectionInfoEvent.idl \
   $(NULL)
 
 EXTRA_COMPONENTS = \
   WifiWorker.js \
   WifiWorker.manifest \
   DOMWifiManager.js \
   DOMWifiManager.manifest \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/dom/wifi/nsIDOMMozWifiConnectionInfoEvent.idl
@@ -0,0 +1,55 @@
+/* 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(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
+interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
+{
+    /**
+     * Network object with an SSID field.
+     */
+    readonly attribute nsIVariant network;
+
+    /**
+     * Strength of the signal to network, in dBm between -55 and -100 dBm.
+     */
+    readonly attribute short signalStrength;
+
+    /**
+     * Relative signal strength between 0 and 100.
+     */
+    readonly attribute short relSignalStrength;
+
+    /**
+     * Link speed in Mb/s.
+     */
+    readonly attribute long linkSpeed;
+
+    /**
+     * IP address in the dotted quad format.
+     */
+    readonly attribute DOMString ipAddress;
+
+    [noscript] void initMozWifiConnectionInfoEvent(in DOMString aType,
+                                                   in boolean aCanBubble,
+                                                   in boolean aCancelable,
+                                                   in nsIVariant aNetwork,
+                                                   in short signalStrength,
+                                                   in short relSignalStrength,
+                                                   in long linkSpeed,
+                                                   in DOMString ipAddress);
+};
+
+dictionary MozWifiConnectionInfoEventInit : EventInit
+{
+  nsIVariant network;
+  short signalStrength;
+  short relSignalStrength;
+  long linkSpeed;
+  DOMString ipAddress;
+};
+
--- a/dom/wifi/nsIWifi.idl
+++ b/dom/wifi/nsIWifi.idl
@@ -181,46 +181,8 @@ 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(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
-interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
-{
-    /**
-     * Network object with an SSID field.
-     */
-    readonly attribute nsIVariant network;
-
-    /**
-     * Strength of the signal to network, in dBm between -55 and -100 dBm.
-     */
-    readonly attribute short signalStrength;
-
-    /**
-     * Relative signal strength between 0 and 100.
-     */
-    readonly attribute short relSignalStrength;
-
-    /**
-     * Link speed in Mb/s.
-     */
-    readonly attribute long linkSpeed;
-
-    /**
-     * IP address in the dotted quad format.
-     */
-    readonly attribute DOMString ipAddress;
-
-    [noscript] void initMozWifiConnectionInfoEvent(in DOMString aType,
-                                                   in boolean aCanBubble,
-                                                   in boolean aCancelable,
-                                                   in nsIVariant aNetwork,
-                                                   in short signalStrength,
-                                                   in short relSignalStrength,
-                                                   in long linkSpeed,
-                                                   in DOMString ipAddress);
-};
--- a/js/xpconnect/src/dictionary_helper_gen.conf
+++ b/js/xpconnect/src/dictionary_helper_gen.conf
@@ -6,17 +6,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' ],
      [ '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
@@ -24,16 +24,17 @@ simple_events = [
     'MozApplicationEvent',
 #ifdef MOZ_B2G_BT
     'BluetoothDeviceEvent',
     'BluetoothDeviceAddressEvent',
 #endif
 #ifdef MOZ_B2G_RIL
     'ICCCardLockErrorEvent',
     'MozWifiStatusChangeEvent',
+    'MozWifiConnectionInfoEvent',
 #endif
     'DeviceStorageChangeEvent',
     'PopupBlockedEvent'
   ]
 
 """ include file names """
 special_includes = [
     'DictionaryHelpers.h',