commit 8425b9a358211777543303d2194b378b2765f144 Author: Mike Perry mikeperry-git@torproject.org Date: Wed Nov 12 16:16:40 2014 -0800
Bug 13742: Isolate cache to URL bar domain. --- netwerk/protocol/http/nsHttpChannel.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 41ef8bb..6e8fa0b 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -66,6 +66,7 @@ #include "nsPerformance.h" #include "CacheObserver.h" #include "mozilla/Telemetry.h" +#include "mozIThirdPartyUtil.h"
namespace mozilla { namespace net {
@@ -2558,6 +2559,19 @@ nsHttpChannel::OpenCacheEntry(bool usingSSL) nsRefPtr<LoadContextInfo> info = GetLoadContextInfo(this); nsCOMPtr<nsICacheStorage> cacheStorage; nsCOMPtr<nsIURI> openURI; + + /* Obtain optional third party isolation domain */ + nsAutoCString cacheDomain; + nsCOMPtr<nsIURI> firstPartyIsolationURI; + nsCOMPtr<mozIThirdPartyUtil> thirdPartySvc + = do_GetService(THIRDPARTYUTIL_CONTRACTID); + rv = thirdPartySvc->GetFirstPartyIsolationURI(this, nullptr, + getter_AddRefs(firstPartyIsolationURI)); + if (NS_SUCCEEDED(rv) && firstPartyIsolationURI) { + thirdPartySvc->GetFirstPartyHostForIsolation(firstPartyIsolationURI, + cacheDomain); + } + if (!mFallbackKey.IsEmpty() && mFallbackChannel) { // This is a fallback channel, open fallback URI instead rv = NS_NewURI(getter_AddRefs(openURI), mFallbackKey); @@ -2612,7 +2626,7 @@ nsHttpChannel::OpenCacheEntry(bool usingSSL) cacheEntryOpenFlags |= nsICacheStorage::OPEN_BYPASS_IF_BUSY;
rv = cacheStorage->AsyncOpenURI( - openURI, mPostID ? nsPrintfCString("%d", mPostID) : EmptyCString(), + openURI, nsPrintfCString("%s@%d", cacheDomain.get(), mPostID), cacheEntryOpenFlags, this); NS_ENSURE_SUCCESS(rv, rv);
@@ -2647,7 +2661,7 @@ bypassCacheEntryOpen: NS_ENSURE_SUCCESS(rv, rv);
rv = cacheStorage->AsyncOpenURI( - mURI, EmptyCString(), nsICacheStorage::OPEN_TRUNCATE, this); + mURI, cacheDomain, nsICacheStorage::OPEN_TRUNCATE, this); NS_ENSURE_SUCCESS(rv, rv);
waitFlags.Keep(WAIT_FOR_OFFLINE_CACHE_ENTRY);
tbb-commits@lists.torproject.org