]> Pileus Git - ~andy/sunrise/blob - www-client/torbrowser/files/12.0/0004-Add-a-string-based-cacheKey.patch
7ddd877a653f6a46af869c23aa13d3cec021182c
[~andy/sunrise] / www-client / torbrowser / files / 12.0 / 0004-Add-a-string-based-cacheKey.patch
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.
5
6 Used for isolating cache according to same-origin policy.
7 ---
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(-)
12
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;
19  
20      /**
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.
24 +     */
25 +    attribute AUTF8String cacheDomain;
26 +
27 +    /**
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,
36          cacheKey.Append(buf);
37      }
38  
39 +    if (strlen(mCacheDomain.get()) > 0) {
40 +        cacheKey.AppendLiteral("domain=");
41 +        cacheKey.Append(mCacheDomain.get());
42 +        cacheKey.AppendLiteral("&");
43 +    }
44 +
45      if (!cacheKey.IsEmpty()) {
46          cacheKey.AppendLiteral("uri=");
47      }
48 @@ -4762,6 +4768,22 @@ nsHttpChannel::SetCacheForOfflineUse(bool value)
49  }
50  
51  NS_IMETHODIMP
52 +nsHttpChannel::GetCacheDomain(nsACString &value)
53 +{
54 +    value = mCacheDomain;
55 +
56 +    return NS_OK;
57 +}
58 +
59 +NS_IMETHODIMP
60 +nsHttpChannel::SetCacheDomain(const nsACString &value)
61 +{
62 +    mCacheDomain = value;
63 +
64 +    return NS_OK;
65 +}
66 +
67 +NS_IMETHODIMP
68  nsHttpChannel::GetOfflineCacheClientID(nsACString &value)
69  {
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;
80  
81      // auth specific data
82      nsCOMPtr<nsIHttpChannelAuthProvider> mAuthProvider;
83 -- 
84 1.7.5.4
85