Closed Bug 832411 Opened 11 years ago Closed 11 years ago

a> nsIGeolocationProvider::SetHighAccuracy does not get called from nsgeolocation service for all cases.

Categories

(Core :: DOM: Geolocation, defect)

x86_64
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22
blocking-b2g leo+
Tracking Status
firefox20 --- wontfix
firefox21 --- wontfix
firefox22 --- fixed
b2g18 + fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- wontfix

People

(Reporter: stephenl, Assigned: jdm)

Details

Attachments

(2 files, 3 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Build ID: 20130104151925

Steps to reproduce:

In custom nsIGeolocationProvider implementation want to be able to take some decisions based on whether high/low accuracy fix is requested.




Actual results:

nsIGeolocationProvider::setHighAccuracy does not get called in all cases.
At http://mxr.mozilla.org/mozilla-beta/source/dom/src/geolocation/nsGeolocation.cpp#441, nsgeolocationService::SetHigherAccuracy gets called only if enableHighAccuracy is true. Here switching becomes an issue, i.e. if at first you have high accuracy selected and then we switch back to low. 


Expected results:

Need the accuracy call for every session requested  be it high/low.
OS: Windows 7 → Gonk (Firefox OS)
Hardware: x86_64 → ARM
Here's the design: in a process, the service is notified of the most recent high accuracy state for each new request. It scans all existing requests to see if any of them require high accuracy, and if there's any change (ie. it's now needed or not needed), it updates the providers. When multiple processes are involved, it's more complicated - the service behaves as before, but passes the required high accuracy status for that process to the parent. The parent process removes any existing geolocation request for that process unconditionally and recreates it with the desired accuracy. This causes the providers to be updated if necessary with the new accuracy status.
Assignee: nobody → josh
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Gonk (Firefox OS) → Windows 7
Hardware: ARM → x86_64
Attachment #705435 - Flags: review?(doug.turner)
Now with fewer copy/paste errors.
Attachment #705440 - Flags: review?(doug.turner)
Attachment #705435 - Attachment is obsolete: true
Attachment #705435 - Flags: review?(doug.turner)
OS: Windows 7 → Gonk (Firefox OS)
Comment on attachment 705440 [details] [diff] [review]
Track geolocation requests' use of high accuracy and ensure the providers are update when necessary.

Review of attachment 705440 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/ipc/ContentParent.cpp
@@ +2131,5 @@
> +AddGeolocationListener(nsIDOMGeoPositionCallback* watcher, bool highAccuracy)
> +{
> +    nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
> +    if (!geo) {
> +        return -1;

Is -1 a valid watch id?

@@ +2134,5 @@
> +    if (!geo) {
> +        return -1;
> +    }
> +
> +    nsRefPtr<nsGeolocation> geosvc = static_cast<nsGeolocation*>(geo.get());

You really should have a nsIGeolocation and do the xpcom thing here... and if you did that, you wouldn't have to fuck around with jsval.  Just create a new method that fits your need.

::: dom/src/geolocation/nsGeolocation.cpp
@@ +1224,5 @@
>    return mPendingCallbacks.Length() != 0;
>  }
>  
> +bool
> +nsGeolocation::HighAccuracyRequired()

I'd prefer the name HighAccuracyRequested()
Attachment #705440 - Flags: review?(doug.turner) → review-
Look, here are some tests as well. Also -1 is a value that indicates that we don't have a listener.
Attachment #709649 - Flags: review?(doug.turner)
Attachment #705440 - Attachment is obsolete: true
blocking-b2g: --- → leo?
blocking-b2g: leo? → leo+
Comment on attachment 709649 [details] [diff] [review]
Track geolocation requests' use of high accuracy and ensure the providers are update when necessary.

Review of attachment 709649 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm

::: dom/ipc/ContentParent.cpp
@@ +2142,5 @@
> +AddGeolocationListener(nsIDOMGeoPositionCallback* watcher, bool highAccuracy)
> +{
> +    nsCOMPtr<nsIGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
> +    if (!geo) {
> +        return -1;

4 spaces or 2 in this file?

@@ +2145,5 @@
> +    if (!geo) {
> +        return -1;
> +    }
> +
> +    mozilla::dom::GeoPositionOptions* options = new mozilla::dom::GeoPositionOptions();

Can't you just use GeoPositionOptions here?  I think we are using mozilla::dom in this file.

@@ +2146,5 @@
> +        return -1;
> +    }
> +
> +    mozilla::dom::GeoPositionOptions* options = new mozilla::dom::GeoPositionOptions();
> +    options->enableHighAccuracy = highAccuracy;

OOC, Are there setters for these sorts of things, or do we just assign like this?

@@ +2147,5 @@
> +    }
> +
> +    mozilla::dom::GeoPositionOptions* options = new mozilla::dom::GeoPositionOptions();
> +    options->enableHighAccuracy = highAccuracy;
> +    int32_t retval;

set to -1 or..

@@ +2148,5 @@
> +
> +    mozilla::dom::GeoPositionOptions* options = new mozilla::dom::GeoPositionOptions();
> +    options->enableHighAccuracy = highAccuracy;
> +    int32_t retval;
> +    geo->WatchPosition(watcher, nullptr, options, &retval);

You'll want to test for an error result here.
Attachment #709649 - Flags: review?(doug.turner) → review+
Attachment #718501 - Attachment description: Track geolocation requests' use of high accuracy and ensure the providers are update when necessary. → B2G18 - Track geolocation requests' use of high accuracy and ensure the providers are update when necessary.
Keywords: checkin-needed
Attachment #718501 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/6e195e29b4d6
https://hg.mozilla.org/mozilla-central/rev/b5ec301ad6c0
Status: NEW → RESOLVED
Closed: 11 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Flags: in-moztrap-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: