Closed Bug 455327 Opened 16 years ago Closed 16 years ago

geolocation - support timeout position option

Categories

(Core :: DOM: Geolocation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dougt, Assigned: dougt)

References

Details

Attachments

(1 file, 4 obsolete files)

Attached patch patch v.1 (obsolete) — Splinter Review
Attachment #342944 - Flags: review?(jst)
smaug, do you think you can take a look at this?
Attachment #342944 - Flags: review?(jst) → review?(Olli.Pettay)
i will switch the lists over to use nsTArray<nsRefPtr<nsSomeClass> > instead of casting.
Comment on attachment 342944 [details] [diff] [review]
patch v.1

>+  nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
>+  if (!stack || NS_FAILED(stack->Push(nsnull)))
>+    return;
>+  
>+  callbackProxy->HandleEvent(this);
>+  
>+  // remove the stack
>+  JSContext* cx;
>+  stack->Pop(&cx);
Perhaps you could make a simple cxpusher helper class to be used on stack.
Or maybe even just modify nsCxPusher so that it works also in this case.
Anyway, since you're just moving this code, no need to make the change in this bug.

>+      nsRefPtr<nsDOMGeoPositionError> positionError = new nsDOMGeoPositionError(4, NS_LITERAL_STRING("Timeout"));
Please #define this magical 4. Same thing elsewhere. 

From l10n point of few, I'm not sure if using literals is the right thing to do here.
The spec doesn't say if the message is possibly localized.

>+      // remove ourselves from the locators callback lists.
Should it be locator's, not locators?


>     for (PRUint32 i = 0; i< mGeolocators.Length(); i++)
>-      mGeolocators[i]->Shutdown();
>+      ((nsGeolocationRequest*)mGeolocators[i])->Shutdown();
Should use c++ casting here and elsewhere, but I guess you don't need
any casting if you use nsTArray

>   nsGeolocation* mLocator; // The locator exists alonger than this object.
alonger?

>-  nsCOMArray<nsGeolocationRequest> mPendingCallbacks;
>-  nsCOMArray<nsGeolocationRequest> mWatchingCallbacks;
>+  // We use nsCOMArray's here because we want the reference counting magic,
>+  // but sadly we have to cast because we want to access the implementation class.
>+  nsCOMArray<nsIGeolocationRequest> mPendingCallbacks;
>+  nsCOMArray<nsIGeolocationRequest> mWatchingCallbacks;
These will change...

>+++ b/dom/tests/mochitest/geolocation/Makefile.in
>@@ -53,6 +53,7 @@
> 		test_cancelWatch.html \
> 		test_clearWatch.html \
> 		test_geoPrompt.html \
>+       test_timeoutWatch.html \
Using spaces when you should use tabs

I'd like to see clarification to that l10n/.message question.
Attachment #342944 - Flags: review?(Olli.Pettay) → review-
thanks for the feedback.

i sent a message to the w3c geolocation wg regarding the l10n issue you raised.  as I recall, this was suppose to be for debugging purposed only -- not for something that is displayed to the end user.
Attached patch patch v.2 (obsolete) — Splinter Review
regarding the l10n issue on the PositionError message.  This is suppose to be a "debug" message for "application developers" and not to be displayed to the end user.  The spec is going to be updated to reflect this.  For now, i have simply removed the text message as they are really just a duplication of the numeric value.  If/when things get more complex, we can pass more interesting strings back.
Attachment #342944 - Attachment is obsolete: true
Attachment #343121 - Flags: review?
Did you diff somehow comparing to the earlier version of the patch or what?
The patch looks a bit strange.

Some comments, including some nits:
- I should have caught this earlier, but I think using nsITimerCallback might
  be better than nsIObserver
- To empty a string, use .Truncate() (not NS_LITERAL_STRING(""), and btw, if 
  you need an empty string, use EmptyString())
- parameter names should start with 'a' and then a capital letter
- Use C++ casting; static_cast<nsSomeClass*>(expr)
- Add OOM checks after |new|
- I think the GEO defines should have NS_ -prefix
- nsGeolocation::HasActiveCallbacks() should either return 0 or 1, so
  return mWatchingCallbacks.Length() != 0;

With those r=me, even though you didn't ask me to re-review ;)
Attached patch patch v.3 (obsolete) — Splinter Review
with all of smaug's nits.

This is just the patch that is in my patch queue.  seems to apply to a clean tree, more or less.
Attachment #343121 - Attachment is obsolete: true
Attachment #343135 - Flags: review?
Attachment #343121 - Flags: review?
Comment on attachment 343135 [details] [diff] [review]
patch v.3

>+++ b/dom/src/geolocation/nsGeolocation.cpp
>+  void Send(nsIDOMGeoPositionErrorCallback* callback);

I'd call this NotifyCallback() perhaps, but see below.

>+nsDOMGeoPositionError::Send(nsIDOMGeoPositionErrorCallback* aCallback)

As discussed on IRC, this shouldn't need the proxy.  If it needs to be async, just use a runnable.

>+nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator, nsIDOMGeoPositionCallback* aCallback, nsIDOMGeoPositionErrorCallback* aErrorCallback, nsIDOMGeoPositionOptions* aOptions)
>+  : mAllowed(PR_FALSE), mCleared(PR_FALSE), mFuzzLocation(PR_FALSE), mHasSentData(PR_FALSE), mCallback(aCallback), mErrorCallback(aErrorCallback), mOptions(aOptions), mLocator(aLocator)

80 columns?

> nsGeolocationRequest::Cancel()

This is basically copy/pasting code from Notify() that differs only in the error code passed to the nsDOMGeoPositionError constructor.  Perhaps better to have a ReportError method that takes said code and then share it between the two callsites?  That method could even do the JSContext stack munging, instead of putting that on the error object itself.

>+nsGeolocation::RemoveRequest(nsGeolocationRequest* aRequest)
>+  nsIGeolocationRequest* r = static_cast<nsIGeolocationRequest*>(aRequest);

That cast doesn't seem to be needed.  Why are we doing it?

The rest looks OK, though you might want to also drop the ref to the timer when it fires.

Oh, one more thing.  I don't see how the part about watchPosition triggering the timeout on position changes can possibly work with this code.  Is it meant to?

Also, a -p -U 8 patch would be much easier to review..
Blocks: 460065
Blocks: 460066
Attached patch patch v.4 (obsolete) — Splinter Review
w/ bz's comments.

i didn't combine the Send stuff, but did rename it.

Also, as I mentioned on IRC, this patch deals with timing out the request due to acquisition timeout failures. 

I do not think if location changes and we don't make the corresponding successCallback call within the timeout, we need to report an error.  I will send a email to the wg about this case.  I don't want to support this as it seem not very useful and overly complex.
Attachment #343135 - Attachment is obsolete: true
Attachment #343135 - Flags: review?
Attachment #343257 - Flags: superreview?(bzbarsky)
Attachment #343257 - Flags: review?(Olli.Pettay)
So why not merge the NotifyCallback callers?
Attached patch patch v.5Splinter Review
bz -  no reason.  here i merged them.
Attachment #343257 - Attachment is obsolete: true
Attachment #343318 - Flags: superreview?(bzbarsky)
Attachment #343318 - Flags: review?
Attachment #343257 - Flags: superreview?(bzbarsky)
Attachment #343257 - Flags: review?(Olli.Pettay)
Attachment #343318 - Flags: superreview?(bzbarsky)
Attachment #343318 - Flags: superreview+
Attachment #343318 - Flags: review?(Olli.Pettay)
Attachment #343318 - Flags: review?
Attachment #343318 - Flags: review?(Olli.Pettay) → review+
Component: DOM → Geolocation
Version: unspecified → Trunk
QA Contact: general → geolocation
a087bc8963b3

thanks bz+olli for your comments.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: