1 From c4212c764149b74a04aad7d15cb3df810512e4ba Mon Sep 17 00:00:00 2001
2 From: Mike Perry <mikeperry-git@fscked.org>
3 Date: Fri, 2 Sep 2011 20:47:02 -0700
4 Subject: [PATCH 04/16] Add a string-based cacheKey.
6 Used for isolating cache according to same-origin policy.
8 netwerk/base/public/nsICachingChannel.idl | 7 +++++++
9 netwerk/protocol/http/nsHttpChannel.cpp | 22 ++++++++++++++++++++++
10 netwerk/protocol/http/nsHttpChannel.h | 1 +
11 3 files changed, 30 insertions(+), 0 deletions(-)
13 diff --git a/netwerk/base/public/nsICachingChannel.idl b/netwerk/base/public/nsICachingChannel.idl
14 index 2da46d6..4ee5774 100644
15 --- a/netwerk/base/public/nsICachingChannel.idl
16 +++ b/netwerk/base/public/nsICachingChannel.idl
17 @@ -98,6 +98,13 @@ interface nsICachingChannel : nsICacheInfoChannel
18 attribute nsISupports cacheKey;
21 + * Set/get the cache domain... uniquely identifies the data in the cache
22 + * for this channel. Holding a reference to this key does NOT prevent
23 + * the cached data from being removed.
25 + attribute AUTF8String cacheDomain;
28 * Specifies whether or not the data should be cached to a file. This
29 * may fail if the disk cache is not present. The value of this attribute
30 * is usually only settable during the processing of a channel's
31 diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
32 index fab0726..5f42b7b 100644
33 --- a/netwerk/protocol/http/nsHttpChannel.cpp
34 +++ b/netwerk/protocol/http/nsHttpChannel.cpp
35 @@ -2415,6 +2415,12 @@ nsHttpChannel::AssembleCacheKey(const char *spec, PRUint32 postID,
39 + if (strlen(mCacheDomain.get()) > 0) {
40 + cacheKey.AppendLiteral("domain=");
41 + cacheKey.Append(mCacheDomain.get());
42 + cacheKey.AppendLiteral("&");
45 if (!cacheKey.IsEmpty()) {
46 cacheKey.AppendLiteral("uri=");
48 @@ -4762,6 +4768,22 @@ nsHttpChannel::SetCacheForOfflineUse(bool value)
52 +nsHttpChannel::GetCacheDomain(nsACString &value)
54 + value = mCacheDomain;
60 +nsHttpChannel::SetCacheDomain(const nsACString &value)
62 + mCacheDomain = value;
68 nsHttpChannel::GetOfflineCacheClientID(nsACString &value)
70 value = mOfflineCacheClientID;
71 diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h
72 index b7bba48..605dc80 100644
73 --- a/netwerk/protocol/http/nsHttpChannel.h
74 +++ b/netwerk/protocol/http/nsHttpChannel.h
75 @@ -304,6 +304,7 @@ private:
76 nsCOMPtr<nsICacheEntryDescriptor> mOfflineCacheEntry;
77 nsCacheAccessMode mOfflineCacheAccess;
78 nsCString mOfflineCacheClientID;
79 + nsCString mCacheDomain;
82 nsCOMPtr<nsIHttpChannelAuthProvider> mAuthProvider;