Closed Bug 287648 Opened 19 years ago Closed 19 years ago

Unify 'request' object interface for DNS and PPS asyncResolve methods

Categories

(Core :: Networking, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: darin.moz, Assigned: darin.moz)

References

Details

(Keywords: arch)

Attachments

(3 files, 1 obsolete file)

Unify 'request' object interface for DNS and PPS asyncResolve methods

nsIProtocolProxyService::asyncResolve returns a nsISupports request object that
can be canceled via nsIProtocolProxyService::cancelAsyncResolve.

nsIDNSService::asyncResolve returns a nsIDNSReqeuest object that can be canceled
via nsIDNSRequest::cancel.

These should be handled similarly.  Maybe they should each return an object with
a cancel method, or maybe they should each move the cancel method onto the
service interface.  Another approach involves implementing nsIRequest, but that
is very heavy weight for these objects.  See bug 282442 comment #43.
Status: NEW → ASSIGNED
Depends on: 282442
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta2
Attached patch v1 patch (obsolete) — Splinter Review
OK, I went ahead with the nsIProtocolProxyRequest solution.  I think this is
cleaner and easier for consumers than cancelAsyncResolve.  The extra interface
is not that bad.  As for a unified interface shared between the DNS and PPS:
*shrug*
At least the programming paradigm is the same.
Attachment #178888 - Flags: review?(cbiesinger)
Comment on attachment 178888 [details] [diff] [review]
v1 patch

+	 // Provided we haven't been canceled...
+	 if (mStatus == NS_OK) {

not NS_SUCCEEDED?
Attachment #178888 - Flags: review?(cbiesinger) → review+
> (From update of attachment 178888 [details] [diff] [review] [edit])
> +	 // Provided we haven't been canceled...
> +	 if (mStatus == NS_OK) {
> 
> not NS_SUCCEEDED?

This code is testing to see if Cancel was called.  Since we initialize mStatus
to NS_OK, I figured I'd test for NS_OK.  There's no point in testing for the
more generic NS_SUCCEEDED.  The alternative would be to test for NS_ERROR_ABORT.
Attachment #178888 - Flags: superreview?(bzbarsky)
Comment on attachment 178888 [details] [diff] [review]
v1 patch

>Index: base/public/nsIProtocolProxyRequest.idl

I almost wonder whether we should use the same nsIBasicCancelableRequest
interface for both this and the DNS service... It seems silly to have two
interfaces with the same exact functionality and different names.  If we really
do want the two separate interfaces for some reason, perhaps they should both
inherit from nsIBasicCancelableRequest or something?

>Index: base/src/nsProtocolProxyService.cpp
>     nsresult DispatchCallback()

It's probably best to null out mCallback if this method ends up throwing;
otherwise I don't see any way for the reference cycle to be broken...

>     void OnQueryComplete(nsresult status, const nsCString &pacString)
>+        // If we've already called DoCallback then, nothing more to do.

Comma should be before "then", not after.

sr=bzbarsky with the two nits and if we're happy with the interfaces setup
as-is....
Attachment #178888 - Flags: superreview?(bzbarsky) → superreview+
bz: thanks for the feedback.  any better name than nsIBasicCancelableRequest?
nsICancelable?
Attached patch v1.1 patchSplinter Review
Spoke to bz over IRC, and he seemed happy with nsICancelable.  This patch
implements that, but only for the PPS at this time.  I'm going to wack the DNS
interfaces with a subsequent patch (need to get rid of init and shutdown as
well in that patch).
Attachment #178888 - Attachment is obsolete: true
Attachment #179300 - Flags: review?(cbiesinger)
Attached patch v1.1 interdiffSplinter Review
interdiff for easier reviewing.
Comment on attachment 179300 [details] [diff] [review]
v1.1 patch

given:
+   *	     being canceled.  It is an error to pass a success code.

can this:
+	 NS_ENSURE_ARG(NS_FAILED(reason));
just be an NS_ASSERTION?

r=me either way
Attachment #179300 - Flags: review?(cbiesinger) → review+
The v1.1 patch landed.  I'm preparing a followup patch that makes the DNS
service use nsICancelable as well.
Attachment #179785 - Flags: review?(cbiesinger)
Comment on attachment 179785 [details] [diff] [review]
patch: make DNS service use nsICancelable (v1)

looks good. should nsPIDNSService maybe be nonscriptable?

+    // TODO(darin): make XPCOM proxies support any nsIEventTarget impl

wanna file a bug on this?
Attachment #179785 - Flags: review?(cbiesinger) → review+
yeah, i'll file a bug on that.  no reason in my mind to make the interface
non-scriptable.  we might want to use it from a unit test for instance.
Attachment #179785 - Flags: superreview?(bzbarsky)
Attachment #179785 - Flags: superreview?(bzbarsky) → superreview+
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: