From 5d9c3072e0a9c52122a28b1d1345b173aefe03ea Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 28 Aug 2013 00:14:57 -0400 Subject: [PATCH] Bug 909645 part 1. Don't include ipdl headers in nsGeolocation.h. r=ms2ger --- dom/src/geolocation/nsGeolocation.cpp | 75 ++++++++++++++++++++++----- dom/src/geolocation/nsGeolocation.h | 50 +----------------- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 3fa9a53c74b..ae638b1761c 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -23,6 +23,7 @@ #include "mozilla/unused.h" #include "mozilla/Preferences.h" #include "mozilla/ClearOnShutdown.h" +#include "PCOMContentPermissionRequestChild.h" class nsIPrincipal; @@ -57,11 +58,59 @@ using mozilla::unused; // using namespace mozilla; using namespace mozilla::dom; -static mozilla::idl::GeoPositionOptions* +class nsGeolocationRequest + : public nsIContentPermissionRequest + , public nsITimerCallback + , public nsIGeolocationUpdate + , public PCOMContentPermissionRequestChild +{ + public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_NSICONTENTPERMISSIONREQUEST + NS_DECL_NSITIMERCALLBACK + NS_DECL_NSIGEOLOCATIONUPDATE + + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGeolocationRequest, nsIContentPermissionRequest) + + nsGeolocationRequest(Geolocation* aLocator, + const GeoPositionCallback& aCallback, + const GeoPositionErrorCallback& aErrorCallback, + idl::GeoPositionOptions* aOptions, + bool aWatchPositionRequest = false, + int32_t aWatchId = 0); + void Shutdown(); + + void SendLocation(nsIDOMGeoPosition* location); + bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;} + void SetTimeoutTimer(); + nsIPrincipal* GetPrincipal(); + + ~nsGeolocationRequest(); + + virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE; + virtual void IPDLRelease() MOZ_OVERRIDE { Release(); } + + bool IsWatch() { return mIsWatchPositionRequest; } + int32_t WatchId() { return mWatchId; } + private: + bool mIsWatchPositionRequest; + + nsCOMPtr mTimeoutTimer; + GeoPositionCallback mCallback; + GeoPositionErrorCallback mErrorCallback; + nsAutoPtr mOptions; + + nsRefPtr mLocator; + + int32_t mWatchId; + bool mShutdown; +}; + +static idl::GeoPositionOptions* GeoPositionOptionsFromPositionOptions(const PositionOptions& aOptions) { - nsAutoPtr geoOptions( - new mozilla::idl::GeoPositionOptions()); + nsAutoPtr geoOptions( + new idl::GeoPositionOptions()); geoOptions->enableHighAccuracy = aOptions.mEnableHighAccuracy; geoOptions->maximumAge = aOptions.mMaximumAge; @@ -291,7 +340,7 @@ PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback) nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator, const GeoPositionCallback& aCallback, const GeoPositionErrorCallback& aErrorCallback, - mozilla::idl::GeoPositionOptions* aOptions, + idl::GeoPositionOptions* aOptions, bool aWatchPositionRequest, int32_t aWatchId) : mIsWatchPositionRequest(aWatchPositionRequest), @@ -624,7 +673,7 @@ nsresult nsGeolocationService::Init() } // geolocation service can be enabled -> now register observer - nsCOMPtr obs = mozilla::services::GetObserverService(); + nsCOMPtr obs = services::GetObserverService(); if (!obs) { return NS_ERROR_FAILURE; } @@ -733,7 +782,7 @@ nsGeolocationService::Observe(nsISupports* aSubject, const PRUnichar* aData) { if (!strcmp("quit-application", aTopic)) { - nsCOMPtr obs = mozilla::services::GetObserverService(); + nsCOMPtr obs = services::GetObserverService(); if (obs) { obs->RemoveObserver(this, "quit-application"); obs->RemoveObserver(this, "mozsettings-changed"); @@ -822,7 +871,7 @@ nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal) } // Start them up! - nsCOMPtr obs = mozilla::services::GetObserverService(); + nsCOMPtr obs = services::GetObserverService(); if (!obs) { return NS_ERROR_FAILURE; } @@ -908,7 +957,7 @@ nsGeolocationService::StopDevice() return; // bail early } - nsCOMPtr obs = mozilla::services::GetObserverService(); + nsCOMPtr obs = services::GetObserverService(); if (!obs) { return; } @@ -1173,7 +1222,7 @@ Geolocation::GetCurrentPosition(PositionCallback& aCallback, NS_IMETHODIMP Geolocation::GetCurrentPosition(nsIDOMGeoPositionCallback* aCallback, nsIDOMGeoPositionErrorCallback* aErrorCallback, - mozilla::idl::GeoPositionOptions* aOptions) + idl::GeoPositionOptions* aOptions) { NS_ENSURE_ARG_POINTER(aCallback); @@ -1186,7 +1235,7 @@ Geolocation::GetCurrentPosition(nsIDOMGeoPositionCallback* aCallback, nsresult Geolocation::GetCurrentPosition(GeoPositionCallback& callback, GeoPositionErrorCallback& errorCallback, - mozilla::idl::GeoPositionOptions *options) + idl::GeoPositionOptions *options) { if (mPendingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) { return NS_ERROR_NOT_AVAILABLE; @@ -1262,7 +1311,7 @@ Geolocation::WatchPosition(PositionCallback& aCallback, NS_IMETHODIMP Geolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback, nsIDOMGeoPositionErrorCallback *aErrorCallback, - mozilla::idl::GeoPositionOptions *aOptions, + idl::GeoPositionOptions *aOptions, int32_t* aRv) { NS_ENSURE_ARG_POINTER(aCallback); @@ -1276,7 +1325,7 @@ Geolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback, nsresult Geolocation::WatchPosition(GeoPositionCallback& aCallback, GeoPositionErrorCallback& aErrorCallback, - mozilla::idl::GeoPositionOptions* aOptions, + idl::GeoPositionOptions* aOptions, int32_t* aRv) { if (mWatchingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) { @@ -1460,5 +1509,5 @@ Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) JSObject* Geolocation::WrapObject(JSContext *aCtx, JS::Handle aScope) { - return mozilla::dom::GeolocationBinding::Wrap(aCtx, aScope, this); + return GeolocationBinding::Wrap(aCtx, aScope, this); } diff --git a/dom/src/geolocation/nsGeolocation.h b/dom/src/geolocation/nsGeolocation.h index 1e2b97ac62c..ce7be6d526e 100644 --- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -33,10 +33,10 @@ #include "nsIContentPermissionPrompt.h" #include "nsIDOMWindow.h" #include "DictionaryHelpers.h" -#include "PCOMContentPermissionRequestChild.h" #include "mozilla/Attributes.h" class nsGeolocationService; +class nsGeolocationRequest; namespace mozilla { namespace dom { @@ -46,54 +46,6 @@ typedef CallbackObjectHolderenableHighAccuracy;} - void SetTimeoutTimer(); - nsIPrincipal* GetPrincipal(); - - ~nsGeolocationRequest(); - - virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE; - virtual void IPDLRelease() MOZ_OVERRIDE { Release(); } - - bool IsWatch() { return mIsWatchPositionRequest; } - int32_t WatchId() { return mWatchId; } - private: - bool mIsWatchPositionRequest; - - nsCOMPtr mTimeoutTimer; - mozilla::dom::GeoPositionCallback mCallback; - mozilla::dom::GeoPositionErrorCallback mErrorCallback; - nsAutoPtr mOptions; - - nsRefPtr mLocator; - - int32_t mWatchId; - bool mShutdown; -}; - /** * Singleton that manages the geolocation provider */