summaryrefslogtreecommitdiff
path: root/chromium/net/http/mock_http_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/http/mock_http_cache.cc')
-rw-r--r--chromium/net/http/mock_http_cache.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/chromium/net/http/mock_http_cache.cc b/chromium/net/http/mock_http_cache.cc
index c9f416cfce4..3ae150b10fd 100644
--- a/chromium/net/http/mock_http_cache.cc
+++ b/chromium/net/http/mock_http_cache.cc
@@ -35,21 +35,28 @@ const int kMaxMockCacheEntrySize = 100 * 1000 * 1000;
int g_test_mode = 0;
int GetTestModeForEntry(const std::string& key) {
+ std::string url = key;
+
// 'key' is prefixed with an identifier if it corresponds to a cached POST.
// Skip past that to locate the actual URL.
//
// TODO(darin): It breaks the abstraction a bit that we assume 'key' is an
// URL corresponding to a registered MockTransaction. It would be good to
// have another way to access the test_mode.
- GURL url;
if (isdigit(key[0])) {
size_t slash = key.find('/');
DCHECK(slash != std::string::npos);
- url = GURL(key.substr(slash + 1));
- } else {
- url = GURL(key);
+ url = url.substr(slash + 1);
+ }
+
+ // If we split the cache by top frame origin, then the origin is prepended to
+ // the key. Skip to the second url in the key.
+ if (base::StartsWith(url, "_dk_", base::CompareCase::SENSITIVE)) {
+ auto const pos = url.find("\nhttp");
+ url = url.substr(pos + 1);
}
- const MockTransaction* t = FindMockTransaction(url);
+
+ const MockTransaction* t = FindMockTransaction(GURL(url));
DCHECK(t);
return t->test_mode;
}
@@ -568,6 +575,7 @@ void MockDiskCache::GetStats(base::StringPairs* stats) {
}
void MockDiskCache::OnExternalCacheHit(const std::string& key) {
+ external_cache_hits_.push_back(key);
}
size_t MockDiskCache::DumpMemoryStats(
@@ -629,6 +637,10 @@ scoped_refptr<MockDiskEntry> MockDiskCache::GetDiskEntryRef(
return it->second;
}
+const std::vector<std::string>& MockDiskCache::GetExternalCacheHits() const {
+ return external_cache_hits_;
+}
+
//-----------------------------------------------------------------------------
int MockBackendFactory::CreateBackend(