diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 7597fb21b14..32161ffcc2d 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -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 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 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; } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 138a5b02eb8..f06571aa5c3 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -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* sNonAppContentParents; static nsTArray* sPrivateContent; static LinkedList sContentParents; - nsCOMPtr mGeo; static void JoinProcessesIOThread(const nsTArray* 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.