This wants to NS_PRECONDITION aData and NS_PRECONDITION aRequest, right?
Also, why is it ok to have an aRequest here that's not a channel? When would
that happen, exactly? URILoader in general only handles channels, and we
really do want a channel here to be able to do SetContentType...
>+ // Save type and stream listener
"save old type and stream listener in case we fail to redispatch", right?
>+ rv = aData->Available(&count);
>+ // XXX what if that failed?
We cancel aRequest with rv? That would make the most sense...
Hmm... I guess this is an OK context to pass, since there's really no better
one in sight, and we _did_ open this channel ourselves with a null context,
huh?
Could you write a comment to that effect?
> nsCOMPtr<nsIExternalHelperAppService> helperAppService =
> do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &rv);
>- if (helperAppService) {
>+ if (!aAllowExt) {
>+ rv = NS_ERROR_NOT_AVAILABLE;
>+ } else if (helperAppService) {
I think this would be clearer written as:
nsCOMPtr<nsIExternalHelperAppService> helperAppService;
if (allowExt) {
helperAppService =
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &rv);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}
if (helperAppService) {
...
Could we please put this in a different file? Especially if we expect to allow
embeddors to implement nsIDispatchable?
Then again, do we expect people to either call nsIExternalHelperAppService
directly or to implement it? If not, perhaps none of these need be public
apis? I suppose that's for another bug, huh? :)
>+ * In no case will this re-enter the original content handler.
This can only be guaranteed if the original content handler is the helper app
service, no? I think this should be clarified.
>+ * *When this function returns successfully, the current handler WILL NOT
>+ * get an onStopRequest call!*
Maybe it should? Would that actually break anything in this case?
>+ * THIS MUST NOT BE CALLED FROM doContent!
This is an internal implementation notes for nsExternalHelperAppService, no? I
don't see how it would apply in general... Again, do we expect embeddors to
implement nsIExternalHelperAppService?
>+ * This method may be called event after onStopRequest has been called,
"even", not "event". Which onStopRequest? That's non-obvious from looking at
this interface.
>+ * in which case the new listener will receive an onStopRequest call before
>+ * this method returns.
Will or must? That is, is this documentation for implementors of
nsIDispatchable, or for coders in nsExternalHelperAppService? The latter
reaslly does not belong here...
>+ * @param aRequest
>+ * The request to dispatch as. Must be the same as passed to doContent.
>+ * XXX this sucks.
I rather agree.... I'm not sure what the best way to fix this is,
conceptually. Perhaps some verbiage indicating the overall interaction of
nsIExternalHelperAppService and nsIDispatchable is in order?
>+ * No content handler for the registered type was registered; or the
>+ * current handler is the handler for the requested type.
Do we ever enforce the latter condition? I don't believe we do, and don't see
a good way to do it without assuming that the current handler is always the
externalhelperappservice.
>+ void handleAs(in ACString aMIMEType);
This should document that it throws anytime canHandleAs is false or something
like that. At the very least, canHandleAs needs to be mentioned here.
(From update of attachment 165908) base/nsURILoade r.cpp nfo::ReDispatch (const nsACString& aMIMEType,
>Index: uriloader/
>+NS_IMETHODIMP nsDocumentOpenI
This wants to NS_PRECONDITION aData and NS_PRECONDITION aRequest, right?
Also, why is it ok to have an aRequest here that's not a channel? When would
that happen, exactly? URILoader in general only handles channels, and we
really do want a channel here to be able to do SetContentType...
>+ // Save type and stream listener
"save old type and stream listener in case we fail to redispatch", right?
>+ rv = aData-> Available( &count) ;
>+ // XXX what if that failed?
We cancel aRequest with rv? That would make the most sense...
>+ rv = m_targetStreamL istener- >OnDataAvailabl e(aRequest, nsnull, aData, 0, count);
Hmm... I guess this is an OK context to pass, since there's really no better
one in sight, and we _did_ open this channel ourselves with a null context,
huh?
Could you write a comment to that effect?
> nsCOMPtr< nsIExternalHelp erAppService> helperAppService = NS_EXTERNALHELP ERAPPSERVICE_ CONTRACTID, &rv); NOT_AVAILABLE;
> do_GetService(
>- if (helperAppService) {
>+ if (!aAllowExt) {
>+ rv = NS_ERROR_
>+ } else if (helperAppService) {
I think this would be clearer written as:
nsCOMPtr< nsIExternalHelp erAppService> helperAppService; GetService( NS_EXTERNALHELP ERAPPSERVICE_ CONTRACTID, &rv); NOT_AVAILABLE;
if (allowExt) {
helperAppService =
do_
} else {
rv = NS_ERROR_
}
if (helperAppService) {
...
> nsDocumentOpenI nfo::TryContent Listener( nsIURIContentLi stener* aListener,
>- nsIChannel* aChannel)
>+ nsIRequest* aRequest)
I'm not so enamored of that change, for the same reasons as apply to the first
comment on this patch...
>- NS_PRECONDITION (aChannel, "Must have a channel"); (aRequest, "Must have a channel");
>+ NS_PRECONDITION
If the change _is_ made, please fix the assert text.
>Index: uriloader/ exthandler/ nsExternalHelpe rAppService. cpp
>+NS_IMETHODIMP nsExternalAppHa ndler:: GetCanHandleAs( PRBool* aCanHandleAs)
This would be better named GetCanCallHandleAs, I think...
> NS_IMETHODIMP nsExternalAppHa ndler:: OnStopRequest( nsIRequest *request, nsISupports *aCtxt,
>- mRequest = nsnull;
You sure this doesn't introduce any cycles? Maybe we want to null it out here
only if we've got disposition info or something?
>@@ -2115,12 +2126,15 @@ nsresult nsExternalAppHa ndler:: CreatePro
> mDialog = nsnull;
>+
>+ mDispatchable = nsnull;
>+
Add a comment explaining that this breaks the cycle?
>+NS_IMETHODIMP nsExternalAppHa ndler:: HandleAs( const nsACString& aMIMEType)
This needs to enforce the constraints of GetCanHandleAs() and throw if that
would return false, I think....
>Index: uriloader/ exthandler/ nsIExternalHelp erAppService. idl
>+interface nsIDispatchable : nsISupports
Could we please put this in a different file? Especially if we expect to allow
embeddors to implement nsIDispatchable?
Then again, do we expect people to either call nsIExternalHelp erAppService
directly or to implement it? If not, perhaps none of these need be public
apis? I suppose that's for another bug, huh? :)
>+ * In no case will this re-enter the original content handler.
This can only be guaranteed if the original content handler is the helper app
service, no? I think this should be clarified.
>+ * *When this function returns successfully, the current handler WILL NOT
>+ * get an onStopRequest call!*
Maybe it should? Would that actually break anything in this case?
>+ * THIS MUST NOT BE CALLED FROM doContent!
This is an internal implementation notes for nsExternalHelpe rAppService, no? I erAppService?
don't see how it would apply in general... Again, do we expect embeddors to
implement nsIExternalHelp
>+ * This method may be called event after onStopRequest has been called,
"even", not "event". Which onStopRequest? That's non-obvious from looking at
this interface.
>+ * in which case the new listener will receive an onStopRequest call before
>+ * this method returns.
Will or must? That is, is this documentation for implementors of rAppService? The latter
nsIDispatchable, or for coders in nsExternalHelpe
reaslly does not belong here...
>+ * @param aRequest
>+ * The request to dispatch as. Must be the same as passed to doContent.
>+ * XXX this sucks.
I rather agree.... I'm not sure what the best way to fix this is, erAppService and nsIDispatchable is in order?
conceptually. Perhaps some verbiage indicating the overall interaction of
nsIExternalHelp
>+ * No content handler for the registered type was registered; or the
>+ * current handler is the handler for the requested type.
Do we ever enforce the latter condition? I don't believe we do, and don't see ppservice.
a good way to do it without assuming that the current handler is always the
externalhelpera
>+ void handleAs(in ACString aMIMEType);
This should document that it throws anytime canHandleAs is false or something
like that. At the very least, canHandleAs needs to be mentioned here.