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

View File

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