From 107bcf1f66caf3a176de8e0093bc68584823c604 Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Fri, 6 Sep 2013 16:44:26 -0400 Subject: [PATCH] Bug 909768 - Replace idl::GeoPositionOptions with dom::PositionOptions. r=jdm --- .../geolocation/nsIDOMGeoGeolocation.idl | 19 +++---- dom/ipc/ContentParent.cpp | 6 +-- dom/src/geolocation/nsGeolocation.cpp | 49 +++++++++---------- dom/src/geolocation/nsGeolocation.h | 4 +- js/xpconnect/src/dictionary_helper_gen.conf | 1 - 5 files changed, 36 insertions(+), 43 deletions(-) diff --git a/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl b/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl index 9f4114b5edc0..ad4e57e7131b 100644 --- a/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl +++ b/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl @@ -8,26 +8,23 @@ interface nsIDOMGeoPositionCallback; interface nsIDOMGeoPositionErrorCallback; %{C++ -#include "DictionaryHelpers.h" +namespace mozilla { +namespace dom { +class PositionOptions; +} +} %} -dictionary GeoPositionOptions -{ - boolean enableHighAccuracy; - long timeout; - long maximumAge; -}; - -[ptr] native NamespacedGeoPositionOptions(mozilla::idl::GeoPositionOptions); +[ptr] native NamespacedPositionOptions(mozilla::dom::PositionOptions); [builtinclass, uuid(1bc7d103-c7ae-4467-881c-21a8dfa17938)] interface nsIDOMGeoGeolocation : nsISupports { int32_t watchPosition(in nsIDOMGeoPositionCallback callback, in nsIDOMGeoPositionErrorCallback errorCallback, - in NamespacedGeoPositionOptions options); + in NamespacedPositionOptions options); void getCurrentPosition(in nsIDOMGeoPositionCallback callback, in nsIDOMGeoPositionErrorCallback errorCallback, - in NamespacedGeoPositionOptions options); + in NamespacedPositionOptions options); void clearWatch(in long watchId); }; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 700f83c5eee8..8f7555931e5d 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -34,6 +34,7 @@ #include "mozilla/dom/bluetooth/PBluetoothParent.h" #include "mozilla/dom/PFMRadioParent.h" #include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h" +#include "mozilla/dom/GeolocationBinding.h" #include "mozilla/dom/telephony/TelephonyParent.h" #include "SmsParent.h" #include "mozilla/Hal.h" @@ -150,7 +151,6 @@ using namespace mozilla::dom::power; using namespace mozilla::dom::mobilemessage; using namespace mozilla::dom::telephony; using namespace mozilla::hal; -using namespace mozilla::idl; using namespace mozilla::ipc; using namespace mozilla::layers; using namespace mozilla::net; @@ -2642,8 +2642,8 @@ AddGeolocationListener(nsIDOMGeoPositionCallback* watcher, bool highAccuracy) return -1; } - GeoPositionOptions* options = new GeoPositionOptions(); - options->enableHighAccuracy = highAccuracy; + PositionOptions* options = new PositionOptions(); + options->mEnableHighAccuracy = highAccuracy; int32_t retval = 1; geo->WatchPosition(watcher, nullptr, options, &retval); return retval; diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 500bbdf75ef2..a650939c6f30 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -71,13 +71,13 @@ class nsGeolocationRequest nsGeolocationRequest(Geolocation* aLocator, const GeoPositionCallback& aCallback, const GeoPositionErrorCallback& aErrorCallback, - idl::GeoPositionOptions* aOptions, + PositionOptions* aOptions, bool aWatchPositionRequest = false, int32_t aWatchId = 0); void Shutdown(); void SendLocation(nsIDOMGeoPosition* location); - bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;} + bool WantsHighAccuracy() {return mOptions && mOptions->mEnableHighAccuracy;} void SetTimeoutTimer(); nsIPrincipal* GetPrincipal(); @@ -94,7 +94,7 @@ class nsGeolocationRequest nsCOMPtr mTimeoutTimer; GeoPositionCallback mCallback; GeoPositionErrorCallback mErrorCallback; - nsAutoPtr mOptions; + nsAutoPtr mOptions; nsRefPtr mLocator; @@ -102,15 +102,14 @@ class nsGeolocationRequest bool mShutdown; }; -static idl::GeoPositionOptions* -GeoPositionOptionsFromPositionOptions(const PositionOptions& aOptions) +static PositionOptions* +CreatePositionOptionsCopy(const PositionOptions& aOptions) { - nsAutoPtr geoOptions( - new idl::GeoPositionOptions()); + nsAutoPtr geoOptions(new PositionOptions()); - geoOptions->enableHighAccuracy = aOptions.mEnableHighAccuracy; - geoOptions->maximumAge = aOptions.mMaximumAge; - geoOptions->timeout = aOptions.mTimeout; + geoOptions->mEnableHighAccuracy = aOptions.mEnableHighAccuracy; + geoOptions->mMaximumAge = aOptions.mMaximumAge; + geoOptions->mTimeout = aOptions.mTimeout; return geoOptions.forget(); } @@ -336,7 +335,7 @@ PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback) nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator, const GeoPositionCallback& aCallback, const GeoPositionErrorCallback& aErrorCallback, - idl::GeoPositionOptions* aOptions, + PositionOptions* aOptions, bool aWatchPositionRequest, int32_t aWatchId) : mIsWatchPositionRequest(aWatchPositionRequest), @@ -460,11 +459,11 @@ nsGeolocationRequest::Allow() uint32_t maximumAge = 30 * PR_MSEC_PER_SEC; if (mOptions) { - if (mOptions->maximumAge >= 0) { - maximumAge = mOptions->maximumAge; + if (mOptions->mMaximumAge >= 0) { + maximumAge = mOptions->mMaximumAge; } } - gs->SetHigherAccuracy(mOptions && mOptions->enableHighAccuracy); + gs->SetHigherAccuracy(mOptions && mOptions->mEnableHighAccuracy); bool canUseCache = lastPosition && maximumAge > 0 && (PRTime(PR_Now() / PR_USEC_PER_MSEC) - maximumAge <= @@ -497,7 +496,7 @@ nsGeolocationRequest::SetTimeoutTimer() } int32_t timeout; - if (mOptions && (timeout = mOptions->timeout) != 0) { + if (mOptions && (timeout = mOptions->mTimeout) != 0) { if (timeout < 0) { timeout = 0; @@ -600,7 +599,7 @@ nsGeolocationRequest::Shutdown() // This should happen last, to ensure that this request isn't taken into consideration // when deciding whether existing requests still require high accuracy. - if (mOptions && mOptions->enableHighAccuracy) { + if (mOptions && mOptions->mEnableHighAccuracy) { nsRefPtr gs = nsGeolocationService::GetGeolocationService(); if (gs) { gs->SetHigherAccuracy(false); @@ -1200,9 +1199,8 @@ Geolocation::GetCurrentPosition(PositionCallback& aCallback, GeoPositionCallback successCallback(&aCallback); GeoPositionErrorCallback errorCallback(aErrorCallback); - nsresult rv = - GetCurrentPosition(successCallback, errorCallback, - GeoPositionOptionsFromPositionOptions(aOptions)); + nsresult rv = GetCurrentPosition(successCallback, errorCallback, + CreatePositionOptionsCopy(aOptions)); if (NS_FAILED(rv)) { aRv.Throw(rv); @@ -1214,7 +1212,7 @@ Geolocation::GetCurrentPosition(PositionCallback& aCallback, NS_IMETHODIMP Geolocation::GetCurrentPosition(nsIDOMGeoPositionCallback* aCallback, nsIDOMGeoPositionErrorCallback* aErrorCallback, - idl::GeoPositionOptions* aOptions) + PositionOptions* aOptions) { NS_ENSURE_ARG_POINTER(aCallback); @@ -1227,7 +1225,7 @@ Geolocation::GetCurrentPosition(nsIDOMGeoPositionCallback* aCallback, nsresult Geolocation::GetCurrentPosition(GeoPositionCallback& callback, GeoPositionErrorCallback& errorCallback, - idl::GeoPositionOptions *options) + PositionOptions *options) { if (mPendingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) { return NS_ERROR_NOT_AVAILABLE; @@ -1289,9 +1287,8 @@ Geolocation::WatchPosition(PositionCallback& aCallback, GeoPositionCallback successCallback(&aCallback); GeoPositionErrorCallback errorCallback(aErrorCallback); - nsresult rv = - WatchPosition(successCallback, errorCallback, - GeoPositionOptionsFromPositionOptions(aOptions), &ret); + nsresult rv = WatchPosition(successCallback, errorCallback, + CreatePositionOptionsCopy(aOptions), &ret); if (NS_FAILED(rv)) { aRv.Throw(rv); @@ -1303,7 +1300,7 @@ Geolocation::WatchPosition(PositionCallback& aCallback, NS_IMETHODIMP Geolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback, nsIDOMGeoPositionErrorCallback *aErrorCallback, - idl::GeoPositionOptions *aOptions, + PositionOptions *aOptions, int32_t* aRv) { NS_ENSURE_ARG_POINTER(aCallback); @@ -1317,7 +1314,7 @@ Geolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback, nsresult Geolocation::WatchPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, - idl::GeoPositionOptions* aOptions, + PositionOptions* aOptions, int32_t* aRv) { if (mWatchingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) { diff --git a/dom/src/geolocation/nsGeolocation.h b/dom/src/geolocation/nsGeolocation.h index ce7be6d526e7..ec8bebebdf84 100644 --- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -176,8 +176,8 @@ private: ~Geolocation(); - nsresult GetCurrentPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, mozilla::idl::GeoPositionOptions* aOptions); - nsresult WatchPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, mozilla::idl::GeoPositionOptions* aOptions, int32_t* aRv); + nsresult GetCurrentPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, PositionOptions* aOptions); + nsresult WatchPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, PositionOptions* aOptions, int32_t* aRv); bool RegisterRequestWithPrompt(nsGeolocationRequest* request); diff --git a/js/xpconnect/src/dictionary_helper_gen.conf b/js/xpconnect/src/dictionary_helper_gen.conf index ee90cdddc9ea..dc2bb55c9c93 100644 --- a/js/xpconnect/src/dictionary_helper_gen.conf +++ b/js/xpconnect/src/dictionary_helper_gen.conf @@ -4,7 +4,6 @@ # Dictionary interface name, interface file name dictionaries = [ - [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ], [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ], [ 'CameraSize', 'nsIDOMCameraManager.idl' ], [ 'CameraRegion', 'nsIDOMCameraManager.idl' ],