зеркало из https://github.com/mozilla/gecko-dev.git
Bug 235853: Defer proxy resolution for HTTP and HTTPS PAC to avoid blocking main thread during DNS resolution, and fix HTTP channel code to properly forward cache-related properties to new proxied channels, patch by shaver@mozilla.org, r+sr=biesi, a=beltzner
This commit is contained in:
Родитель
36404ec7b9
Коммит
632b77dde8
|
@ -6,7 +6,7 @@
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 1, 2)">
|
<body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 1, 4)">
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
<script class="testbody" type="text/javascript" src="file_testloadflags.js">
|
<script class="testbody" type="text/javascript" src="file_testloadflags.js">
|
||||||
|
|
|
@ -550,7 +550,17 @@ nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result)
|
||||||
NS_WARNING("failed to get protocol proxy service");
|
NS_WARNING("failed to get protocol proxy service");
|
||||||
}
|
}
|
||||||
if (mProxyService) {
|
if (mProxyService) {
|
||||||
rv = mProxyService->Resolve(aURI, 0, getter_AddRefs(pi));
|
PRUint32 flags = 0;
|
||||||
|
if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("https"))
|
||||||
|
flags = nsIProtocolProxyService::RESOLVE_NON_BLOCKING;
|
||||||
|
rv = mProxyService->Resolve(aURI, flags, getter_AddRefs(pi));
|
||||||
|
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||||
|
// Use an UNKNOWN proxy to defer resolution and avoid blocking.
|
||||||
|
rv = mProxyService->NewProxyInfo(NS_LITERAL_CSTRING("unknown"),
|
||||||
|
NS_LITERAL_CSTRING(""),
|
||||||
|
-1, 0, 0, nsnull,
|
||||||
|
getter_AddRefs(pi));
|
||||||
|
}
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
pi = nsnull;
|
pi = nsnull;
|
||||||
}
|
}
|
||||||
|
|
|
@ -923,7 +923,8 @@ nsProtocolProxyService::NewProxyInfo(const nsACString &aType,
|
||||||
kProxyType_HTTP,
|
kProxyType_HTTP,
|
||||||
kProxyType_SOCKS,
|
kProxyType_SOCKS,
|
||||||
kProxyType_SOCKS4,
|
kProxyType_SOCKS4,
|
||||||
kProxyType_DIRECT
|
kProxyType_DIRECT,
|
||||||
|
kProxyType_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
// resolve type; this allows us to avoid copying the type string into each
|
// resolve type; this allows us to avoid copying the type string into each
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ nsHttpChannel::DoReplaceWithProxy(nsIProxyInfo* pi)
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE);
|
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE, PR_TRUE);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -2249,7 +2249,8 @@ CopyProperties(const nsAString& aKey, nsIVariant *aData, void *aClosure)
|
||||||
nsresult
|
nsresult
|
||||||
nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||||
nsIChannel *newChannel,
|
nsIChannel *newChannel,
|
||||||
PRBool preserveMethod)
|
PRBool preserveMethod,
|
||||||
|
PRBool transferCacheInfo)
|
||||||
{
|
{
|
||||||
PRUint32 newLoadFlags = mLoadFlags | LOAD_REPLACE;
|
PRUint32 newLoadFlags = mLoadFlags | LOAD_REPLACE;
|
||||||
// if the original channel was using SSL and this channel is not using
|
// if the original channel was using SSL and this channel is not using
|
||||||
|
@ -2334,6 +2335,26 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||||
if (bag)
|
if (bag)
|
||||||
mPropertyHash.EnumerateRead(CopyProperties, bag.get());
|
mPropertyHash.EnumerateRead(CopyProperties, bag.get());
|
||||||
|
|
||||||
|
// Transfer the cache info to the new channel, if needed.
|
||||||
|
if (transferCacheInfo) {
|
||||||
|
nsCOMPtr<nsICachingChannel> cachingChannel = do_QueryInterface(newChannel);
|
||||||
|
if (cachingChannel) {
|
||||||
|
// cacheKey is just mPostID wrapped in an nsISupportsPRUint32,
|
||||||
|
// we don't need to transfer it if it's 0.
|
||||||
|
if (mPostID) {
|
||||||
|
nsCOMPtr<nsISupports> cacheKey;
|
||||||
|
GetCacheKey(getter_AddRefs(cacheKey));
|
||||||
|
if (cacheKey) {
|
||||||
|
cachingChannel->SetCacheKey(cacheKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cacheClientID, cacheForOfflineUse
|
||||||
|
cachingChannel->SetOfflineCacheClientID(mOfflineCacheClientID);
|
||||||
|
cachingChannel->SetCacheForOfflineUse(mCacheForOfflineUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2419,7 +2440,7 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
||||||
rv = ioService->NewChannelFromURI(newURI, getter_AddRefs(newChannel));
|
rv = ioService->NewChannelFromURI(newURI, getter_AddRefs(newChannel));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
rv = SetupReplacementChannel(newURI, newChannel, preserveMethod);
|
rv = SetupReplacementChannel(newURI, newChannel, preserveMethod, PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
PRUint32 redirectFlags;
|
PRUint32 redirectFlags;
|
||||||
|
|
|
@ -167,7 +167,7 @@ private:
|
||||||
void HandleAsyncRedirect();
|
void HandleAsyncRedirect();
|
||||||
void HandleAsyncNotModified();
|
void HandleAsyncNotModified();
|
||||||
nsresult PromptTempRedirect();
|
nsresult PromptTempRedirect();
|
||||||
nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, PRBool preserveMethod);
|
nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, PRBool preserveMethod, PRBool transferCacheInfo);
|
||||||
|
|
||||||
// proxy specific methods
|
// proxy specific methods
|
||||||
nsresult ProxyFailover();
|
nsresult ProxyFailover();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче