Backed out changeset 201d347cda5d (bug 874069) for xpcshell crashes.

This commit is contained in:
Ryan VanderMeulen 2013-06-05 20:39:49 -04:00
parent e8d6d018a5
commit 826cfdea72
2 changed files with 10 additions and 14 deletions

View File

@ -1052,8 +1052,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
// be true.
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
mGeo = do_CreateInstance("@mozilla.org/geolocation;1");
// Insert ourselves into the global linked list of ContentParent objects.
sContentParents.insertBack(this);
@ -2370,17 +2368,18 @@ ContentParent::RecvFilePathUpdateNotify(const nsString& aType,
return true;
}
int32_t
ContentParent::AddGeolocationListener(bool highAccuracy)
static int32_t
AddGeolocationListener(nsIDOMGeoPositionCallback* watcher, bool highAccuracy)
{
if (!mGeo) {
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
if (!geo) {
return -1;
}
GeoPositionOptions* options = new GeoPositionOptions();
options->enableHighAccuracy = highAccuracy;
int32_t retval = 1;
mGeo->WatchPosition(this, nullptr, options, &retval);
geo->WatchPosition(watcher, nullptr, options, &retval);
return retval;
}
@ -2438,7 +2437,7 @@ ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal,
// To ensure no geolocation updates are skipped, we always force the
// creation of a new listener.
RecvRemoveGeolocationListener();
mGeolocationWatchID = AddGeolocationListener(aHighAccuracy);
mGeolocationWatchID = AddGeolocationListener(this, aHighAccuracy);
return true;
}
@ -2446,10 +2445,11 @@ bool
ContentParent::RecvRemoveGeolocationListener()
{
if (mGeolocationWatchID != -1) {
if (!mGeo) {
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
if (!geo) {
return true;
}
mGeo->ClearWatch(mGeolocationWatchID);
geo->ClearWatch(mGeolocationWatchID);
mGeolocationWatchID = -1;
}
return true;
@ -2462,7 +2462,7 @@ ContentParent::RecvSetGeolocationHigherAccuracy(const bool& aEnable)
// so this check allows us to forgo securing privileges.
if (mGeolocationWatchID != -1) {
RecvRemoveGeolocationListener();
mGeolocationWatchID = AddGeolocationListener(aEnable);
mGeolocationWatchID = AddGeolocationListener(this, aEnable);
}
return true;
}

View File

@ -26,7 +26,6 @@
#include "nsIDOMGeoPositionCallback.h"
#include "nsIMemoryReporter.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "PermissionMessageUtils.h"
@ -36,7 +35,6 @@
class mozIApplication;
class nsConsoleService;
class nsIDOMBlob;
class nsIDOMGeoGeolocation;
namespace mozilla {
@ -177,12 +175,10 @@ private:
static nsTArray<ContentParent*>* sNonAppContentParents;
static nsTArray<ContentParent*>* sPrivateContent;
static LinkedList<ContentParent> sContentParents;
nsCOMPtr<nsIDOMGeoGeolocation> mGeo;
static void JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
Monitor* aMonitor, bool* aDone);
int32_t AddGeolocationListener(bool highAccuracy);
// Take the preallocated process and transform it into a "real" app process,
// for the specified manifest URL. If there is no preallocated process (or
// if it's dead), this returns false.