summaryrefslogtreecommitdiff
blob: 822033abcc458c90254c52b2e635ebc43f161ddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From a06818f3a358e6c4502b944ecd264fd2ccaff5bf Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@fscked.org>
Date: Fri, 2 Sep 2011 20:47:02 -0700
Subject: [PATCH 05/13] Add a string-based cacheKey.

Used for isolating cache according to same-origin policy.
---
 netwerk/base/public/nsICachingChannel.idl |    7 +++++++
 netwerk/protocol/http/nsHttpChannel.cpp   |   22 ++++++++++++++++++++++
 netwerk/protocol/http/nsHttpChannel.h     |    1 +
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/netwerk/base/public/nsICachingChannel.idl b/netwerk/base/public/nsICachingChannel.idl
index 2da46d6..4ee5774 100644
--- a/netwerk/base/public/nsICachingChannel.idl
+++ b/netwerk/base/public/nsICachingChannel.idl
@@ -98,6 +98,13 @@ interface nsICachingChannel : nsICacheInfoChannel
     attribute nsISupports cacheKey;
 
     /**
+     * Set/get the cache domain... uniquely identifies the data in the cache
+     * for this channel.  Holding a reference to this key does NOT prevent
+     * the cached data from being removed.
+     */
+    attribute AUTF8String cacheDomain;
+
+    /**
      * Specifies whether or not the data should be cached to a file.  This
      * may fail if the disk cache is not present.  The value of this attribute
      * is usually only settable during the processing of a channel's
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
index 4c5e759..6205d62 100644
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -2389,6 +2389,12 @@ nsHttpChannel::AssembleCacheKey(const char *spec, PRUint32 postID,
         cacheKey.Append(buf);
     }
 
+    if (strlen(mCacheDomain.get()) > 0) {
+        cacheKey.AppendLiteral("domain=");
+        cacheKey.Append(mCacheDomain.get());
+        cacheKey.AppendLiteral("&");
+    }
+
     if (!cacheKey.IsEmpty()) {
         cacheKey.AppendLiteral("uri=");
     }
@@ -4695,6 +4701,22 @@ nsHttpChannel::SetCacheForOfflineUse(bool value)
 }
 
 NS_IMETHODIMP
+nsHttpChannel::GetCacheDomain(nsACString &value)
+{
+    value = mCacheDomain;
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHttpChannel::SetCacheDomain(const nsACString &value)
+{
+    mCacheDomain = value;
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
 nsHttpChannel::GetOfflineCacheClientID(nsACString &value)
 {
     value = mOfflineCacheClientID;
diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h
index 88ce469..53538cf 100644
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -303,6 +303,7 @@ private:
     nsCOMPtr<nsICacheEntryDescriptor> mOfflineCacheEntry;
     nsCacheAccessMode                 mOfflineCacheAccess;
     nsCString                         mOfflineCacheClientID;
+    nsCString                         mCacheDomain;
 
     // auth specific data
     nsCOMPtr<nsIHttpChannelAuthProvider> mAuthProvider;
-- 
1.7.5.4