Bug 910568 - WebTelephony: move DOM classes to namespace mozilla::dom. r=khuey
authorVicamo Yang <vyang@mozilla.com>
Thu, 12 Sep 2013 05:47:14 +0200
changeset 146650 2d38a1453c3d7e3ee6cb4dc54b5220fa5049356b
parent 146649 db0a833aee39db7c72f266a193d1583a388a08b3
child 146651 10275ce5c76e4e6e1991a7d3978058ce04b7d976
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskhuey
bugs910568
milestone26.0a1
Bug 910568 - WebTelephony: move DOM classes to namespace mozilla::dom. r=khuey
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/bindings/Bindings.conf
dom/telephony/CallEvent.cpp
dom/telephony/CallEvent.h
dom/telephony/CallsList.cpp
dom/telephony/CallsList.h
dom/telephony/Telephony.cpp
dom/telephony/Telephony.h
dom/telephony/TelephonyCall.cpp
dom/telephony/TelephonyCall.h
dom/telephony/TelephonyCallGroup.cpp
dom/telephony/TelephonyCallGroup.h
dom/telephony/TelephonyCommon.h
dom/telephony/moz.build
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -49,17 +49,17 @@
 #include "TimeManager.h"
 #include "DeviceStorage.h"
 #include "nsIDOMNavigatorSystemMessages.h"
 
 #ifdef MOZ_MEDIA_NAVIGATOR
 #include "MediaManager.h"
 #endif
 #ifdef MOZ_B2G_RIL
-#include "mozilla/dom/telephony/Telephony.h"
+#include "mozilla/dom/Telephony.h"
 #endif
 #ifdef MOZ_B2G_BT
 #include "BluetoothManager.h"
 #endif
 #include "DOMCameraManager.h"
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 #include "AudioChannelManager.h"
@@ -1163,25 +1163,25 @@ Navigator::GetMozCellBroadcast(ErrorResu
       return nullptr;
     }
     mCellBroadcast = CellBroadcast::Create(mWindow, aRv);
   }
 
   return mCellBroadcast;
 }
 
-telephony::Telephony*
+Telephony*
 Navigator::GetMozTelephony(ErrorResult& aRv)
 {
   if (!mTelephony) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
-    mTelephony = telephony::Telephony::Create(mWindow, aRv);
+    mTelephony = Telephony::Create(mWindow, aRv);
   }
 
   return mTelephony;
 }
 
 Voicemail*
 Navigator::GetMozVoicemail(ErrorResult& aRv)
 {
@@ -1693,17 +1693,17 @@ Navigator::HasCameraSupport(JSContext* /
 }
 
 #ifdef MOZ_B2G_RIL
 /* static */
 bool
 Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && telephony::Telephony::CheckPermission(win);
+  return win && Telephony::CheckPermission(win);
 }
 
 /* static */
 bool
 Navigator::HasMobileConnectionSupport(JSContext* /* unused */,
                                       JSObject* aGlobal)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -75,30 +75,25 @@ class IccManager;
 
 namespace network {
 class Connection;
 #ifdef MOZ_B2G_RIL
 class MobileConnection;
 #endif
 } // namespace Connection;
 
-#ifdef MOZ_B2G_RIL
-namespace telephony {
-class Telephony;
-} // namespace Telephony;
-class CellBroadcast;
-#endif
-
 #ifdef MOZ_B2G_BT
 namespace bluetooth {
 class BluetoothManager;
 } // namespace bluetooth
 #endif // MOZ_B2G_BT
 
 #ifdef MOZ_B2G_RIL
+class CellBroadcast;
+class Telephony;
 class Voicemail;
 #endif
 
 namespace power {
 class PowerManager;
 } // namespace power
 
 namespace time {
@@ -220,17 +215,17 @@ public:
   nsIDOMMozMobileMessageManager* GetMozMobileMessage();
   nsIDOMMozConnection* GetMozConnection();
   nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   void MozSetMessageHandler(const nsAString& aType,
                             systemMessageCallback* aCallback,
                             ErrorResult& aRv);
   bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
 #ifdef MOZ_B2G_RIL
-  telephony::Telephony* GetMozTelephony(ErrorResult& aRv);
+  Telephony* GetMozTelephony(ErrorResult& aRv);
   nsIDOMMozMobileConnection* GetMozMobileConnection(ErrorResult& aRv);
   CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
   Voicemail* GetMozVoicemail(ErrorResult& aRv);
   nsIDOMMozIccManager* GetMozIccManager(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
 #endif // MOZ_GAMEPAD
@@ -325,17 +320,17 @@ private:
   nsRefPtr<DesktopNotificationCenter> mNotification;
   nsRefPtr<battery::BatteryManager> mBatteryManager;
 #ifdef MOZ_B2G_FM
   nsRefPtr<FMRadio> mFMRadio;
 #endif
   nsRefPtr<power::PowerManager> mPowerManager;
   nsRefPtr<MobileMessageManager> mMobileMessageManager;
 #ifdef MOZ_B2G_RIL
-  nsRefPtr<telephony::Telephony> mTelephony;
+  nsRefPtr<Telephony> mTelephony;
   nsRefPtr<Voicemail> mVoicemail;
 #endif
   nsRefPtr<network::Connection> mConnection;
 #ifdef MOZ_B2G_RIL
   nsRefPtr<network::MobileConnection> mMobileConnection;
   nsRefPtr<CellBroadcast> mCellBroadcast;
   nsRefPtr<icc::IccManager> mIccManager;
 #endif
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -159,25 +159,19 @@ DOMInterfaces = {
     'headerFile': 'BluetoothDevice.h'
 },
 
 'BluetoothManager': {
     'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
     'headerFile': 'BluetoothManager.h'
 },
 
-'CallEvent': {
-    'nativeType': 'mozilla::dom::telephony::CallEvent',
-    'headerFile': 'mozilla/dom/telephony/CallEvent.h',
-},
+'CallEvent': {},
 
-'CallsList': {
-    'nativeType': 'mozilla::dom::telephony::CallsList',
-    'headerFile': 'mozilla/dom/telephony/CallsList.h',
-},
+'CallsList': {},
 
 'CameraControl': {
     'nativeType': 'mozilla::nsDOMCameraControl',
     'headerFile': 'DOMCameraControl.h',
     'binaryNames': {
         "release": "ReleaseHardware"
     }
 },
@@ -1172,30 +1166,21 @@ DOMInterfaces = {
 'SVGUnitTypes' : {
     'concrete': False,
 },
 
 'SVGZoomAndPan' : {
     'concrete': False,
 },
 
-'Telephony' : {
-    'nativeType': 'mozilla::dom::telephony::Telephony',
-    'headerFile': 'mozilla/dom/telephony/Telephony.h',
-},
+'Telephony' : {},
 
-'TelephonyCall' : {
-    'nativeType': 'mozilla::dom::telephony::TelephonyCall',
-    'headerFile': 'mozilla/dom/telephony/TelephonyCall.h',
-},
+'TelephonyCall' : {},
 
-'TelephonyCallGroup' : {
-    'nativeType': 'mozilla::dom::telephony::TelephonyCallGroup',
-    'headerFile': 'mozilla/dom/telephony/TelephonyCallGroup.h',
-},
+'TelephonyCallGroup' : {},
 
 'Text': {
     # Total hack to allow binding code to realize that nsTextNode can
     # in fact be cast to Text.
     'headerFile': 'nsTextNode.h',
 },
 
 'TextDecoder': {
--- a/dom/telephony/CallEvent.cpp
+++ b/dom/telephony/CallEvent.cpp
@@ -4,17 +4,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 "CallEvent.h"
 #include "mozilla/dom/CallEventBinding.h"
 
 #include "TelephonyCall.h"
 
-USING_TELEPHONY_NAMESPACE
 using namespace mozilla::dom;
 using mozilla::ErrorResult;
 
 /* static */
 already_AddRefed<CallEvent>
 CallEvent::Create(EventTarget* aOwner, const nsAString& aType,
                   TelephonyCall* aCall, bool aCanBubble,
                   bool aCancelable)
--- a/dom/telephony/CallEvent.h
+++ b/dom/telephony/CallEvent.h
@@ -2,27 +2,24 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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_telephony_callevent_h
 #define mozilla_dom_telephony_callevent_h
 
-#include "TelephonyCommon.h"
+#include "mozilla/dom/telephony/TelephonyCommon.h"
 
 #include "nsDOMEvent.h"
 
 namespace mozilla {
 namespace dom {
+
 struct CallEventInit;
-}
-}
-
-BEGIN_TELEPHONY_NAMESPACE
 
 class CallEvent MOZ_FINAL : public nsDOMEvent
 {
   nsRefPtr<TelephonyCall> mCall;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CallEvent, nsDOMEvent)
@@ -51,11 +48,12 @@ private:
   {
     SetIsDOMBinding();
   }
 
   virtual ~CallEvent()
   { }
 };
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_callevent_h
--- a/dom/telephony/CallsList.cpp
+++ b/dom/telephony/CallsList.cpp
@@ -6,17 +6,16 @@
 
 #include "CallsList.h"
 #include "mozilla/dom/CallsListBinding.h"
 
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "TelephonyCallGroup.h"
 
-USING_TELEPHONY_NAMESPACE
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(CallsList,
                                         mTelephony,
                                         mGroup)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(CallsList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(CallsList)
--- a/dom/telephony/CallsList.h
+++ b/dom/telephony/CallsList.h
@@ -2,21 +2,22 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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_telephony_CallsList_h__
 #define mozilla_dom_telephony_CallsList_h__
 
-#include "TelephonyCommon.h"
+#include "mozilla/dom/telephony/TelephonyCommon.h"
 
 #include "nsWrapperCache.h"
 
-BEGIN_TELEPHONY_NAMESPACE
+namespace mozilla {
+namespace dom {
 
 class CallsList MOZ_FINAL : public nsISupports,
                             public nsWrapperCache
 {
   nsRefPtr<Telephony> mTelephony;
   nsRefPtr<TelephonyCallGroup> mGroup;
 
 public:
@@ -41,11 +42,12 @@ public:
 
   already_AddRefed<TelephonyCall>
   IndexedGetter(uint32_t aIndex, bool& aFound) const;
 
 private:
   ~CallsList();
 };
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_CallsList_h__
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -19,19 +19,19 @@
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 
 #include "CallEvent.h"
 #include "CallsList.h"
 #include "TelephonyCall.h"
 #include "TelephonyCallGroup.h"
 
-USING_TELEPHONY_NAMESPACE
 using namespace mozilla::dom;
 using mozilla::ErrorResult;
+using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex;
 
 namespace {
 
 typedef nsAutoTArray<Telephony*, 2> TelephonyList;
 
 TelephonyList* gTelephonyList;
 
 } // anonymous namespace
--- a/dom/telephony/Telephony.h
+++ b/dom/telephony/Telephony.h
@@ -2,33 +2,30 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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_telephony_telephony_h__
 #define mozilla_dom_telephony_telephony_h__
 
-#include "TelephonyCommon.h"
+#include "mozilla/dom/telephony/TelephonyCommon.h"
 
 #include "nsITelephonyProvider.h"
 
 // Need to include TelephonyCall.h because we have inline methods that
 // assume they see the definition of TelephonyCall.
 #include "TelephonyCall.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
+
 class TelephonyCallOrTelephonyCallGroupReturnValue;
-}
-}
-
-BEGIN_TELEPHONY_NAMESPACE
 
 class Telephony MOZ_FINAL : public nsDOMEventTargetHelper
 {
   /**
    * Class Telephony doesn't actually inherit nsITelephonyListener.
    * Instead, it owns an nsITelephonyListener derived instance mListener
    * and passes it to nsITelephonyProvider. The onreceived events are first
    * delivered to mListener and then forwarded to its owner, Telephony. See
@@ -176,11 +173,12 @@ private:
 
   bool
   MoveCall(uint32_t aCallIndex, bool aIsConference);
 
   void
   Shutdown();
 };
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_telephony_h__
--- a/dom/telephony/TelephonyCall.cpp
+++ b/dom/telephony/TelephonyCall.cpp
@@ -8,19 +8,19 @@
 #include "mozilla/dom/TelephonyCallBinding.h"
 
 #include "mozilla/dom/DOMError.h"
 
 #include "CallEvent.h"
 #include "Telephony.h"
 #include "TelephonyCallGroup.h"
 
-USING_TELEPHONY_NAMESPACE
 using namespace mozilla::dom;
 using mozilla::ErrorResult;
+using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex;
 
 // static
 already_AddRefed<TelephonyCall>
 TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber,
                       uint16_t aCallState, uint32_t aCallIndex,
                       bool aEmergency, bool aIsConference)
 {
   NS_ASSERTION(aTelephony, "Null pointer!");
@@ -156,17 +156,17 @@ TelephonyCall::DispatchCallEvent(const n
 }
 
 void
 TelephonyCall::NotifyError(const nsAString& aError)
 {
   // Set the error string
   NS_ASSERTION(!mError, "Already have an error?");
 
-  mError = new mozilla::dom::DOMError(GetOwner(), aError);
+  mError = new DOMError(GetOwner(), aError);
 
   // Do the state transitions
   ChangeStateInternal(nsITelephonyProvider::CALL_STATE_DISCONNECTED, true);
 
   nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("error"), this);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch error event!");
   }
--- a/dom/telephony/TelephonyCall.h
+++ b/dom/telephony/TelephonyCall.h
@@ -2,34 +2,35 @@
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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_telephony_telephonycall_h__
 #define mozilla_dom_telephony_telephonycall_h__
 
-#include "TelephonyCommon.h"
+#include "mozilla/dom/telephony/TelephonyCommon.h"
 
 #include "mozilla/dom/DOMError.h"
 
 class nsPIDOMWindow;
 
-BEGIN_TELEPHONY_NAMESPACE
+namespace mozilla {
+namespace dom {
 
 class TelephonyCall MOZ_FINAL : public nsDOMEventTargetHelper
 {
   nsRefPtr<Telephony> mTelephony;
   nsRefPtr<TelephonyCallGroup> mGroup;
 
   nsString mNumber;
   nsString mSecondNumber;
   nsString mState;
   bool mEmergency;
-  nsRefPtr<mozilla::dom::DOMError> mError;
+  nsRefPtr<DOMError> mError;
 
   uint32_t mCallIndex;
   uint16_t mCallState;
   bool mLive;
   bool mOutgoing;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
@@ -102,17 +103,17 @@ public:
   IMPL_EVENT_HANDLER(holding)
   IMPL_EVENT_HANDLER(held)
   IMPL_EVENT_HANDLER(resuming)
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(groupchange)
 
   static already_AddRefed<TelephonyCall>
   Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState,
-         uint32_t aCallIndex = kOutgoingPlaceholderCallIndex,
+         uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex,
          bool aEmergency = false, bool aIsConference = false);
 
   void
   ChangeState(uint16_t aCallState)
   {
     ChangeStateInternal(aCallState, true);
   }
 
@@ -120,17 +121,17 @@ public:
   CallIndex() const
   {
     return mCallIndex;
   }
 
   void
   UpdateCallIndex(uint32_t aCallIndex)
   {
-    NS_ASSERTION(mCallIndex == kOutgoingPlaceholderCallIndex,
+    NS_ASSERTION(mCallIndex == telephony::kOutgoingPlaceholderCallIndex,
                  "Call index should not be set!");
     mCallIndex = aCallIndex;
   }
 
   uint16_t
   CallState() const
   {
     return mCallState;
@@ -168,11 +169,12 @@ private:
   void
   ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
 
   nsresult
   DispatchCallEvent(const nsAString& aType,
                     TelephonyCall* aCall);
 };
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_telephonycall_h__
--- a/dom/telephony/TelephonyCallGroup.cpp
+++ b/dom/telephony/TelephonyCallGroup.cpp
@@ -6,17 +6,16 @@
 
 #include "TelephonyCallGroup.h"
 #include "mozilla/dom/TelephonyCallGroupBinding.h"
 
 #include "CallEvent.h"
 #include "CallsList.h"
 #include "Telephony.h"
 
-USING_TELEPHONY_NAMESPACE
 using namespace mozilla::dom;
 using mozilla::ErrorResult;
 
 TelephonyCallGroup::TelephonyCallGroup()
 : mCallState(nsITelephonyProvider::CALL_STATE_UNKNOWN)
 {
   SetIsDOMBinding();
 }
--- a/dom/telephony/TelephonyCallGroup.h
+++ b/dom/telephony/TelephonyCallGroup.h
@@ -2,19 +2,20 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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_telephony_telephonycallgroup_h__
 #define mozilla_dom_telephony_telephonycallgroup_h__
 
-#include "TelephonyCommon.h"
+#include "mozilla/dom/telephony/TelephonyCommon.h"
 
-BEGIN_TELEPHONY_NAMESPACE
+namespace mozilla {
+namespace dom {
 
 class TelephonyCallGroup MOZ_FINAL : public nsDOMEventTargetHelper
 {
   nsRefPtr<Telephony> mTelephony;
 
   nsTArray<nsRefPtr<TelephonyCall> > mCalls;
 
   nsRefPtr<CallsList> mCallsList;
@@ -106,11 +107,12 @@ private:
 
   nsresult
   DispatchCallEvent(const nsAString& aType,
                     TelephonyCall* aCall);
 
   bool CanConference(const TelephonyCall& aCall, TelephonyCall* aSecondCall);
 };
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_telephonycallgroup_h__
--- a/dom/telephony/TelephonyCommon.h
+++ b/dom/telephony/TelephonyCommon.h
@@ -19,22 +19,28 @@
 
 #define BEGIN_TELEPHONY_NAMESPACE \
   namespace mozilla { namespace dom { namespace telephony {
 #define END_TELEPHONY_NAMESPACE \
   } /* namespace telephony */ } /* namespace dom */ } /* namespace mozilla */
 #define USING_TELEPHONY_NAMESPACE \
   using namespace mozilla::dom::telephony;
 
-BEGIN_TELEPHONY_NAMESPACE
+namespace mozilla {
+namespace dom {
+
+namespace telephony {
 
 enum {
   kOutgoingPlaceholderCallIndex = UINT32_MAX
 };
 
+} // namespace telephony
+
 class CallsList;
 class Telephony;
 class TelephonyCall;
 class TelephonyCallGroup;
 
-END_TELEPHONY_NAMESPACE
+} // namespace dom
+} // namespace mozilla
 
 #endif // mozilla_dom_telephony_telephonycommon_h__
--- a/dom/telephony/moz.build
+++ b/dom/telephony/moz.build
@@ -7,22 +7,25 @@
 XPIDL_SOURCES += [
     'nsITelephonyProvider.idl',
 ]
 
 XPIDL_MODULE = 'dom_telephony'
 
 MODULE = 'dom'
 
-EXPORTS.mozilla.dom.telephony += [
+EXPORTS.mozilla.dom += [
     'CallEvent.h',
     'CallsList.h',
     'Telephony.h',
     'TelephonyCall.h',
     'TelephonyCallGroup.h',
+]
+
+EXPORTS.mozilla.dom.telephony += [
     'TelephonyCommon.h',
     'TelephonyFactory.h',
     'ipc/TelephonyChild.h',
     'ipc/TelephonyParent.h',
 ]
 
 CPP_SOURCES += [
     'CallEvent.cpp',