Bug 908031 - Remove Geolocation::PendingRequest. r=jdm

This commit is contained in:
Michael Harrison 2013-09-09 08:57:37 -04:00
parent e005e6184b
commit 2c9908315e
2 changed files with 16 additions and 47 deletions

View File

@ -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);

View File

@ -209,18 +209,8 @@ private:
// Watch ID
uint32_t mLastWatchId;
// Pending requests are used when the service is not ready:
class PendingRequest
{
public:
nsRefPtr<nsGeolocationRequest> request;
enum {
GetCurrentPosition,
WatchPosition
} type;
};
nsTArray<PendingRequest> mPendingRequests;
// Pending requests are used when the service is not ready
nsTArray<nsRefPtr<nsGeolocationRequest> > mPendingRequests;
};
class PositionError MOZ_FINAL : public nsIDOMGeoPositionError,