Backed out changeset 7e0b33c685c8 (bug 920551)
authorEd Morley <emorley@mozilla.com>
Fri, 25 Oct 2013 10:52:14 +0100
changeset 165998 71f7ca5ba7f85ee1e5cef7b9d03f0740aa2e4543
parent 165997 4e1be75c88fed99c78a2cb277f1b2e65fb18f898
child 165999 5bebff43ffbdc595d0ef5d93053c6c0e8e58a7c2
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs920551
milestone27.0a1
backs out7e0b33c685c83a5cd7cca61e2d236924c1f50227
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
Backed out changeset 7e0b33c685c8 (bug 920551)
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/GonkGPSGeolocationProvider.h
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -13,53 +13,46 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include <pthread.h>
 #include <hardware/gps.h>
 
 #include "GonkGPSGeolocationProvider.h"
+#include "SystemWorkerManager.h"
 #include "mozilla/Preferences.h"
 #include "nsGeoPosition.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINetworkManager.h"
+#include "nsIRadioInterfaceLayer.h"
+#include "nsIDOMIccInfo.h"
+#include "nsIDOMMobileConnection.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
 
-#ifdef MOZ_B2G_RIL
-#include "nsIDOMIccInfo.h"
-#include "nsIDOMMobileConnection.h"
-#include "nsIRadioInterfaceLayer.h"
-#endif
-
 #ifdef AGPS_TYPE_INVALID
 #define AGPS_HAVE_DUAL_APN
 #endif
 
 #define DEBUG_GPS 0
 
 using namespace mozilla;
 
 static const int kDefaultPeriod = 1000; // ms
 
 // While most methods of GonkGPSGeolocationProvider should only be
 // called from main thread, we deliberately put the Init and ShutdownGPS
 // methods off main thread to avoid blocking.
-#ifdef MOZ_B2G_RIL
 NS_IMPL_ISUPPORTS3(GonkGPSGeolocationProvider,
                    nsIGeolocationProvider,
                    nsIRILDataCallback,
                    nsISettingsServiceCallback)
-#else
-NS_IMPL_ISUPPORTS1(GonkGPSGeolocationProvider,
-                   nsIGeolocationProvider)
-#endif
 
 /* static */ GonkGPSGeolocationProvider* GonkGPSGeolocationProvider::sSingleton = nullptr;
 GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = {
   sizeof(GpsCallbacks),
   LocationCallback,
   StatusCallback,
   SvStatusCallback,
   NmeaCallback,
@@ -67,30 +60,28 @@ GpsCallbacks GonkGPSGeolocationProvider:
   AcquireWakelockCallback,
   ReleaseWakelockCallback,
   CreateThreadCallback,
 #ifdef GPS_CAPABILITY_ON_DEMAND_TIME
   RequestUtcTimeCallback,
 #endif
 };
 
-#ifdef MOZ_B2G_RIL
 AGpsCallbacks
 GonkGPSGeolocationProvider::mAGPSCallbacks = {
   AGPSStatusCallback,
   CreateThreadCallback,
 };
 
 AGpsRilCallbacks
 GonkGPSGeolocationProvider::mAGPSRILCallbacks = {
   AGPSRILSetIDCallback,
   AGPSRILRefLocCallback,
   CreateThreadCallback,
 };
-#endif // MOZ_B2G_RIL
 
 void
 GonkGPSGeolocationProvider::LocationCallback(GpsLocation* location)
 {
   class UpdateLocationEvent : public nsRunnable {
   public:
     UpdateLocationEvent(nsGeoPosition* aPosition)
       : mPosition(aPosition)
@@ -150,20 +141,18 @@ GonkGPSGeolocationProvider::SetCapabilit
     UpdateCapabilitiesEvent(uint32_t aCapabilities)
       : mCapabilities(aCapabilities)
     {}
     NS_IMETHOD Run() {
       nsRefPtr<GonkGPSGeolocationProvider> provider =
         GonkGPSGeolocationProvider::GetSingleton();
 
       provider->mSupportsScheduling = mCapabilities & GPS_CAPABILITY_SCHEDULING;
-#ifdef MOZ_B2G_RIL
       provider->mSupportsMSB = mCapabilities & GPS_CAPABILITY_MSB;
       provider->mSupportsMSA = mCapabilities & GPS_CAPABILITY_MSA;
-#endif
       provider->mSupportsSingleShot = mCapabilities & GPS_CAPABILITY_SINGLE_SHOT;
 #ifdef GPS_CAPABILITY_ON_DEMAND_TIME
       provider->mSupportsTimeInjection = mCapabilities & GPS_CAPABILITY_ON_DEMAND_TIME;
 #endif
       return NS_OK;
     }
   private:
     uint32_t mCapabilities;
@@ -202,17 +191,16 @@ GonkGPSGeolocationProvider::CreateThread
   return thread;
 }
 
 void
 GonkGPSGeolocationProvider::RequestUtcTimeCallback()
 {
 }
 
-#ifdef MOZ_B2G_RIL
 void
 GonkGPSGeolocationProvider::AGPSStatusCallback(AGpsStatus* status)
 {
   MOZ_ASSERT(status);
 
   class AGPSStatusEvent : public nsRunnable {
   public:
     AGPSStatusEvent(AGpsStatusValue aStatus)
@@ -274,25 +262,22 @@ GonkGPSGeolocationProvider::AGPSRILRefLo
       return NS_OK;
     }
   };
 
   if (flags & AGPS_RIL_REQUEST_REFLOC_CELLID) {
     NS_DispatchToMainThread(new RequestRefLocEvent());
   }
 }
-#endif // MOZ_B2G_RIL
 
 GonkGPSGeolocationProvider::GonkGPSGeolocationProvider()
   : mStarted(false)
   , mSupportsScheduling(false)
-#ifdef MOZ_B2G_RIL
   , mSupportsMSB(false) 
   , mSupportsMSA(false) 
-#endif
   , mSupportsSingleShot(false)
   , mSupportsTimeInjection(false)
   , mGpsInterface(nullptr)
 {
 }
 
 GonkGPSGeolocationProvider::~GonkGPSGeolocationProvider()
 {
@@ -330,17 +315,16 @@ GonkGPSGeolocationProvider::GetGPSInterf
   const GpsInterface* result = gps_device->get_gps_interface(gps_device);
 
   if (result->size != sizeof(GpsInterface)) {
     return nullptr;
   }
   return result;
 }
 
-#ifdef MOZ_B2G_RIL
 int32_t
 GonkGPSGeolocationProvider::GetDataConnectionState()
 {
   if (!mRadioInterface) {
     return nsINetworkInterface::NETWORK_STATE_UNKNOWN;
   }
 
   int32_t state;
@@ -518,91 +502,83 @@ GonkGPSGeolocationProvider::SetReference
         }
       }
     }
     if (mAGpsRilInterface) {
       mAGpsRilInterface->set_ref_location(&location, sizeof(location));
     }
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 GonkGPSGeolocationProvider::Init()
 {
   // Must not be main thread. Some GPS driver's first init takes very long.
   MOZ_ASSERT(!NS_IsMainThread());
 
   mGpsInterface = GetGPSInterface();
   if (!mGpsInterface) {
     return;
   }
 
   if (mGpsInterface->init(&mCallbacks) != 0) {
     return;
   }
 
-#ifdef MOZ_B2G_RIL
   mAGpsInterface =
     static_cast<const AGpsInterface*>(mGpsInterface->get_extension(AGPS_INTERFACE));
   if (mAGpsInterface) {
     mAGpsInterface->init(&mAGPSCallbacks);
   }
 
   mAGpsRilInterface =
     static_cast<const AGpsRilInterface*>(mGpsInterface->get_extension(AGPS_RIL_INTERFACE));
   if (mAGpsRilInterface) {
     mAGpsRilInterface->init(&mAGPSRILCallbacks);
   }
-#endif
 
   NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS));
 }
 
 void
 GonkGPSGeolocationProvider::StartGPS()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGpsInterface);
 
   int32_t update = Preferences::GetInt("geo.default.update", kDefaultPeriod);
 
-#ifdef MOZ_B2G_RIL
   if (mSupportsMSA || mSupportsMSB) {
     SetupAGPS();
   }
-#endif
 
   int positionMode = GPS_POSITION_MODE_STANDALONE;
   bool singleShot = false;
 
-#ifdef MOZ_B2G_RIL
   // XXX: If we know this is a single shot request, use MSA can be faster.
   if (singleShot && mSupportsMSA) {
     positionMode = GPS_POSITION_MODE_MS_ASSISTED;
   } else if (mSupportsMSB) {
     positionMode = GPS_POSITION_MODE_MS_BASED;
   }
-#endif
   if (!mSupportsScheduling) {
     update = kDefaultPeriod;
   }
 
   mGpsInterface->set_position_mode(positionMode,
                                    GPS_POSITION_RECURRENCE_PERIODIC,
                                    update, 0, 0);
 #if DEBUG_GPS
   // Delete cached data
   mGpsInterface->delete_aiding_data(GPS_DELETE_ALL);
 #endif
 
   mGpsInterface->start();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 GonkGPSGeolocationProvider::SetupAGPS()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mAGpsInterface);
 
   const nsAdoptingCString& suplServer = Preferences::GetCString("geo.gps.supl_server");
   int32_t suplPort = Preferences::GetInt("geo.gps.supl_port", -1);
@@ -618,18 +594,19 @@ GonkGPSGeolocationProvider::SetupAGPS()
   if (ril) {
     // TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
     // MultiSIM configuration
     ril->GetRadioInterface(0 /* clientId */, getter_AddRefs(mRadioInterface));
     if (mRadioInterface) {
       mRadioInterface->RegisterDataCallCallback(this);
     }
   }
+
+  return;
 }
-#endif // MOZ_B2G_RIL
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Startup()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mStarted) {
     return NS_OK;
@@ -661,21 +638,19 @@ GonkGPSGeolocationProvider::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mStarted) {
     return NS_OK;
   }
   mStarted = false;
 
-#ifdef MOZ_B2G_RIL
   if (mRadioInterface) {
     mRadioInterface->UnregisterDataCallCallback(this);
   }
-#endif
 
   mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),
                         NS_DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
 void
@@ -690,17 +665,16 @@ GonkGPSGeolocationProvider::ShutdownGPS(
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::SetHighAccuracy(bool)
 {
   return NS_OK;
 }
 
-#ifdef MOZ_B2G_RIL
 /** nsIRILDataCallback interface **/
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::DataCallStateChanged(nsIRILDataCallInfo* aDataCall)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aDataCall);
 
@@ -742,9 +716,8 @@ GonkGPSGeolocationProvider::Handle(const
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage)
 {
   return NS_OK;
 }
-#endif // MOZ_B2G_RIL
--- a/dom/system/gonk/GonkGPSGeolocationProvider.h
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.h
@@ -15,42 +15,37 @@
  */
 
 #ifndef GonkGPSGeolocationProvider_h
 #define GonkGPSGeolocationProvider_h
 
 #include <hardware/gps.h> // for GpsInterface
 #include "nsCOMPtr.h"
 #include "nsIGeolocationProvider.h"
-#ifdef MOZ_B2G_RIL
 #include "nsIRadioInterfaceLayer.h"
+#include "nsString.h"
 #include "nsISettingsService.h"
-#endif
 
 class nsIThread;
 
 #define GONK_GPS_GEOLOCATION_PROVIDER_CID \
 { 0x48525ec5, 0x5a7f, 0x490a, { 0x92, 0x77, 0xba, 0x66, 0xe0, 0xd2, 0x2c, 0x8b } }
 
 #define GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID \
 "@mozilla.org/gonk-gps-geolocation-provider;1"
 
 class GonkGPSGeolocationProvider : public nsIGeolocationProvider
-#ifdef MOZ_B2G_RIL
                                  , public nsIRILDataCallback
                                  , public nsISettingsServiceCallback
-#endif
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIGEOLOCATIONPROVIDER
-#ifdef MOZ_B2G_RIL
   NS_DECL_NSIRILDATACALLBACK
   NS_DECL_NSISETTINGSSERVICECALLBACK
-#endif
 
   static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
 
 private:
 
   /* Client should use GetSingleton() to get the provider instance. */
   GonkGPSGeolocationProvider();
   GonkGPSGeolocationProvider(const GonkGPSGeolocationProvider &);
@@ -61,59 +56,49 @@ private:
   static void StatusCallback(GpsStatus* status);
   static void SvStatusCallback(GpsSvStatus* sv_info);
   static void NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length);
   static void SetCapabilitiesCallback(uint32_t capabilities);
   static void AcquireWakelockCallback();
   static void ReleaseWakelockCallback();
   static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
   static void RequestUtcTimeCallback();
-#ifdef MOZ_B2G_RIL
   static void AGPSStatusCallback(AGpsStatus* status);
   static void AGPSRILSetIDCallback(uint32_t flags);
   static void AGPSRILRefLocCallback(uint32_t flags);
-#endif
 
   static GpsCallbacks mCallbacks;
-#ifdef MOZ_B2G_RIL
   static AGpsCallbacks mAGPSCallbacks;
   static AGpsRilCallbacks mAGPSRILCallbacks;
-#endif
 
+  int32_t GetDataConnectionState();
+  void SetAGpsDataConn(nsAString& aApn);
+  void RequestSettingValue(char* aKey);
   void Init();
+  void SetupAGPS();
   void StartGPS();
   void ShutdownGPS();
-#ifdef MOZ_B2G_RIL
-  void SetupAGPS();
-  int32_t GetDataConnectionState();
-  void SetAGpsDataConn(nsAString& aApn);
   void RequestDataConnection();
   void ReleaseDataConnection();
-  void RequestSettingValue(char* aKey);
   void RequestSetID(uint32_t flags);
   void SetReferenceLocation();
-#endif
 
   const GpsInterface* GetGPSInterface();
 
   static GonkGPSGeolocationProvider* sSingleton;
 
   bool mStarted;
 
   bool mSupportsScheduling;
-#ifdef MOZ_B2G_RIL
   bool mSupportsMSB;
   bool mSupportsMSA;
-#endif
   bool mSupportsSingleShot;
   bool mSupportsTimeInjection;
 
   const GpsInterface* mGpsInterface;
-#ifdef MOZ_B2G_RIL
   const AGpsInterface* mAGpsInterface;
   const AGpsRilInterface* mAGpsRilInterface;
-  nsCOMPtr<nsIRadioInterface> mRadioInterface;
-#endif
   nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
   nsCOMPtr<nsIThread> mInitThread;
+  nsCOMPtr<nsIRadioInterface> mRadioInterface;
 };
 
 #endif /* GonkGPSGeolocationProvider_h */