Bug 1250922: Use gpsd for Geolocation, r=jdm,glandium
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 22 Jul 2016 11:52:09 +0200
changeset 348451 a1a42e8d66e905fcd99042d878b2cb56f6b137ad
parent 348450 76b04196acceb86e55d7a2cdc2fa62f53a756f14
child 348452 457be633b6cc5b3a11ef8e5814a04024d57b59d3
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, glandium
bugs1250922
milestone50.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 1250922: Use gpsd for Geolocation, r=jdm,glandium This patch adds the gpsd location provider to |nsGeolocationService|. On release builds, the new provider is *not* used by default, as GPS is slow to start and unreliable indoors. To enable gpsd, users with a supported GPS receiver must set the preference 'geo.location.use_gpsd' to 'true'. On non-release builds, the gpsd location provider is enabled by default to give it some testing. MozReview-Commit-ID: I0tj1GmmFNP
browser/app/moz.build
browser/app/profile/firefox.js
dom/geolocation/moz.build
dom/geolocation/nsGeolocation.cpp
--- a/browser/app/moz.build
+++ b/browser/app/moz.build
@@ -75,11 +75,14 @@ if CONFIG['OS_ARCH'] == 'WINNT' and not 
 DISABLE_STL_WRAPPING = True
 
 if CONFIG['MOZ_LINKER']:
     OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
 
 if CONFIG['HAVE_CLOCK_MONOTONIC']:
     OS_LIBS += CONFIG['REALTIME_LIBS']
 
+if CONFIG['MOZ_GPSD']:
+    DEFINES['MOZ_GPSD'] = True
+
 for icon in ('firefox', 'document', 'newwindow', 'newtab', 'pbmode'):
     DEFINES[icon.upper() + '_ICO'] = '"%s/dist/branding/%s.ico"' % (
         TOPOBJDIR, icon)
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1235,16 +1235,26 @@ pref("geo.provider.use_corelocation", fa
 pref("geo.provider.use_corelocation", true);
 #endif
 #endif
 
 #ifdef XP_WIN
 pref("geo.provider.ms-windows-location", false);
 #endif
 
+#ifdef MOZ_WIDGET_GTK
+#ifdef MOZ_GPSD
+#ifdef RELEASE_BUILD
+pref("geo.provider.use_gpsd", false);
+#else
+pref("geo.provider.use_gpsd", true);
+#endif
+#endif
+#endif
+
 // Necko IPC security checks only needed for app isolation for cookies/cache/etc:
 // currently irrelevant for desktop e10s
 pref("network.disable.ipc.security", true);
 
 // CustomizableUI debug logging.
 pref("browser.uiCustomization.debug", false);
 
 // CustomizableUI state of the browser's user interface
--- a/dom/geolocation/moz.build
+++ b/dom/geolocation/moz.build
@@ -37,8 +37,14 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'go
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '/dom/system/mac',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     LOCAL_INCLUDES += [
         '/dom/system/windows',
     ]
+elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
+    if CONFIG['MOZ_GPSD']:
+        LOCAL_INCLUDES += [
+            '/dom/system/linux',
+        ]
+        DEFINES['MOZ_GPSD'] = True
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -40,16 +40,20 @@ class nsIPrincipal;
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidLocationProvider.h"
 #endif
 
 #ifdef MOZ_WIDGET_GONK
 #include "GonkGPSGeolocationProvider.h"
 #endif
 
+#ifdef MOZ_GPSD
+#include "GpsdLocationProvider.h"
+#endif
+
 #ifdef MOZ_WIDGET_COCOA
 #include "CoreLocationLocationProvider.h"
 #endif
 
 #ifdef XP_WIN
 #include "WindowsLocationProvider.h"
 #include "mozilla/WindowsVersion.h"
 #endif
@@ -761,16 +765,24 @@ nsresult nsGeolocationService::Init()
   // GonkGPSGeolocationProvider can be started at boot up time for initialization reasons.
   // do_getService gets hold of the already initialized component and starts
   // processing location requests immediately.
   // do_Createinstance will create multiple instances of the provider which is not right.
   // bug 993041
   mProvider = do_GetService(GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID);
 #endif
 
+#ifdef MOZ_WIDGET_GTK
+#ifdef MOZ_GPSD
+  if (Preferences::GetBool("geo.provider.use_gpsd", false)) {
+    mProvider = new GpsdLocationProvider();
+  }
+#endif
+#endif
+
 #ifdef MOZ_WIDGET_COCOA
   if (Preferences::GetBool("geo.provider.use_corelocation", true)) {
     mProvider = new CoreLocationLocationProvider();
   }
 #endif
 
 #ifdef XP_WIN
   if (Preferences::GetBool("geo.provider.ms-windows-location", false) &&