From 2e005c04f65338b4d600ab9ed9a11fb379bd45dd Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Mon, 9 Sep 2013 08:57:37 -0400 Subject: [PATCH] Bug 908031 - Remove Geolocation::PendingRequest. r=jdm --- dom/src/geolocation/nsGeolocation.cpp | 49 ++++++++------------------- dom/src/geolocation/nsGeolocation.h | 14 ++------ 2 files changed, 16 insertions(+), 47 deletions(-) diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index a650939c6f30..22726afb8f6a 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -1011,26 +1011,11 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(Geolocation) NS_IMPL_CYCLE_COLLECTING_RELEASE(Geolocation) -NS_IMPL_CYCLE_COLLECTION_CLASS(Geolocation) - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Geolocation) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedPosition) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER - tmp->mPendingRequests.Clear(); - NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingCallbacks) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mWatchingCallbacks) -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Geolocation) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCachedPosition) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - for (uint32_t i = 0; i < tmp->mPendingRequests.Length(); ++i) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingRequests[i].request) - - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingCallbacks) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWatchingCallbacks) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Geolocation) +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(Geolocation, + mCachedPosition, + mPendingCallbacks, + mWatchingCallbacks, + mPendingRequests) Geolocation::Geolocation() : mLastWatchId(0) @@ -1248,8 +1233,7 @@ Geolocation::GetCurrentPosition(GeoPositionCallback& callback, } if (sGeoInitPending) { - PendingRequest req = { request, PendingRequest::GetCurrentPosition }; - mPendingRequests.AppendElement(req); + mPendingRequests.AppendElement(request); return NS_OK; } @@ -1342,8 +1326,7 @@ Geolocation::WatchPosition(GeoPositionCallback& aCallback, } if (sGeoInitPending) { - PendingRequest req = { request, PendingRequest::WatchPosition }; - mPendingRequests.AppendElement(req); + mPendingRequests.AppendElement(request); return NS_OK; } @@ -1387,9 +1370,9 @@ Geolocation::ClearWatch(int32_t aWatchId) // make sure we also search through the pending requests lists for // watches to clear... for (uint32_t i = 0, length = mPendingRequests.Length(); i < length; ++i) { - if ((mPendingRequests[i].type == PendingRequest::WatchPosition) && - (mPendingRequests[i].request->WatchId() == aWatchId)) { - mPendingRequests[i].request->Shutdown(); + if (mPendingRequests[i]->IsWatch() && + (mPendingRequests[i]->WatchId() == aWatchId)) { + mPendingRequests[i]->Shutdown(); mPendingRequests.RemoveElementAt(i); break; } @@ -1402,14 +1385,10 @@ void Geolocation::ServiceReady() { for (uint32_t length = mPendingRequests.Length(); length > 0; --length) { - switch (mPendingRequests[0].type) { - case PendingRequest::GetCurrentPosition: - GetCurrentPositionReady(mPendingRequests[0].request); - break; - - case PendingRequest::WatchPosition: - WatchPositionReady(mPendingRequests[0].request); - break; + if (mPendingRequests[0]->IsWatch()) { + WatchPositionReady(mPendingRequests[0]); + } else { + GetCurrentPositionReady(mPendingRequests[0]); } mPendingRequests.RemoveElementAt(0); diff --git a/dom/src/geolocation/nsGeolocation.h b/dom/src/geolocation/nsGeolocation.h index ec8bebebdf84..af1bfaa33e2b 100644 --- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -209,18 +209,8 @@ private: // Watch ID uint32_t mLastWatchId; - // Pending requests are used when the service is not ready: - class PendingRequest - { - public: - nsRefPtr request; - enum { - GetCurrentPosition, - WatchPosition - } type; - }; - - nsTArray mPendingRequests; + // Pending requests are used when the service is not ready + nsTArray > mPendingRequests; }; class PositionError MOZ_FINAL : public nsIDOMGeoPositionError,