mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1125372 - use nsISupports as first param of asyncResolve instead of switching wholesale from nsIURI to nsIChannel, for improved add-on compat, r=mcmanus
This commit is contained in:
parent
8dcd64ba41
commit
60cc51fd47
@ -18,7 +18,7 @@ interface nsIURI;
|
||||
* nsIProtocolProxyService provides methods to access information about
|
||||
* various network proxies.
|
||||
*/
|
||||
[scriptable, uuid(ab363090-c331-489f-aabb-7fe4481795b8)]
|
||||
[scriptable, uuid(deec8e08-a246-443c-90b6-f655632d1abf)]
|
||||
interface nsIProtocolProxyService : nsISupports
|
||||
{
|
||||
/** Flag 1 << 0 is unused **/
|
||||
@ -68,8 +68,11 @@ interface nsIProtocolProxyService : nsISupports
|
||||
* a proxy to be used for the given channel. Otherwise, this method returns
|
||||
* null indicating that a direct connection should be used.
|
||||
*
|
||||
* @param aChannel
|
||||
* The channel for which a proxy is to be found.
|
||||
* @param aChannelOrURI
|
||||
* The channel for which a proxy is to be found, or, if no channel is
|
||||
* available, a URI indicating the same. This method will return
|
||||
* NS_ERROR_NOINTERFACE if this argument isn't either an nsIURI or an
|
||||
* nsIChannel.
|
||||
* @param aFlags
|
||||
* A bit-wise combination of the RESOLVE_ flags defined above. Pass
|
||||
* 0 to specify the default behavior. Any additional bits that do
|
||||
@ -95,7 +98,7 @@ interface nsIProtocolProxyService : nsISupports
|
||||
*
|
||||
* @see nsIProxiedProtocolHandler::newProxiedChannel
|
||||
*/
|
||||
nsICancelable asyncResolve(in nsIChannel aChannel, in unsigned long aFlags,
|
||||
nsICancelable asyncResolve(in nsISupports aChannelOrURI, in unsigned long aFlags,
|
||||
in nsIProtocolProxyCallback aCallback);
|
||||
|
||||
/**
|
||||
|
@ -19,10 +19,11 @@ interface nsIProtocolProxyService2 : nsIProtocolProxyService
|
||||
void reloadPAC();
|
||||
|
||||
/**
|
||||
* This method is identical to asyncResolve() except it may execute the
|
||||
* callback function immediately (i.e from the stack of asyncResolve2()) if
|
||||
* it is immediately ready to run. The nsICancelable return value will be
|
||||
* null in that case.
|
||||
* This method is identical to asyncResolve() except:
|
||||
* - it only accepts an nsIChannel, not an nsIURI;
|
||||
* - it may execute the callback function immediately (i.e from the stack
|
||||
* of asyncResolve2()) if it is immediately ready to run.
|
||||
* The nsICancelable return value will be null in that case.
|
||||
*/
|
||||
nsICancelable asyncResolve2(in nsIChannel aChannel, in unsigned long aFlags,
|
||||
in nsIProtocolProxyCallback aCallback);
|
||||
|
@ -1271,10 +1271,27 @@ nsProtocolProxyService::AsyncResolve2(nsIChannel *channel, uint32_t flags,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::AsyncResolve(nsIChannel *channel, uint32_t flags,
|
||||
nsProtocolProxyService::AsyncResolve(nsISupports *channelOrURI, uint32_t flags,
|
||||
nsIProtocolProxyCallback *callback,
|
||||
nsICancelable **result)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
// Check if we got a channel:
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(channelOrURI);
|
||||
if (!channel) {
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(channelOrURI);
|
||||
if (!uri) {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
// make a temporary channel from the URI
|
||||
nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = ios->NewChannelFromURI(uri, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return AsyncResolveInternal(channel, flags, callback, result, false);
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1873,7 @@ nsFtpState::Init(nsFtpChannel *channel)
|
||||
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID);
|
||||
|
||||
if (pps && !mChannel->ProxyInfo()) {
|
||||
pps->AsyncResolve(mChannel, 0, this,
|
||||
pps->AsyncResolve(static_cast<nsIChannel*>(mChannel), 0, this,
|
||||
getter_AddRefs(mProxyRequest));
|
||||
}
|
||||
|
||||
|
@ -2039,7 +2039,7 @@ nsHttpChannel::ResolveProxy()
|
||||
rv = pps2->AsyncResolve2(this, mProxyResolveFlags,
|
||||
this, getter_AddRefs(mProxyRequest));
|
||||
} else {
|
||||
rv = pps->AsyncResolve(this, mProxyResolveFlags,
|
||||
rv = pps->AsyncResolve(static_cast<nsIChannel*>(this), mProxyResolveFlags,
|
||||
this, getter_AddRefs(mProxyRequest));
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,63 @@ function filter_test0_5(pi)
|
||||
pps.unregisterChannelFilter(filter03);
|
||||
check_proxy(pi, "http", "www.mozilla.org", 7777, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
run_filter_test_uri();
|
||||
}
|
||||
|
||||
function run_filter_test_uri() {
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test_uri0_1;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
pps.asyncResolve(uri, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test_uri0_1(pi) {
|
||||
do_check_eq(pi, null);
|
||||
|
||||
// Push a filter and verify the results
|
||||
|
||||
filter01 = new BasicFilter();
|
||||
filter02 = new BasicFilter();
|
||||
pps.registerFilter(filter01, 10);
|
||||
pps.registerFilter(filter02, 20);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test_uri0_2;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
pps.asyncResolve(uri, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test_uri0_2(pi)
|
||||
{
|
||||
check_proxy(pi, "http", "localhost", 8080, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
|
||||
pps.unregisterFilter(filter02);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test_uri0_3;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
pps.asyncResolve(uri, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test_uri0_3(pi)
|
||||
{
|
||||
check_proxy(pi, "http", "localhost", 8080, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
|
||||
// Remove filter and verify that we return to the initial state
|
||||
|
||||
pps.unregisterFilter(filter01);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test_uri0_4;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
pps.asyncResolve(uri, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test_uri0_4(pi)
|
||||
{
|
||||
do_check_eq(pi, null);
|
||||
run_filter_test2();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user