summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/http/http_cache.cc6
-rw-r--r--net/http/http_cache.h13
-rw-r--r--net/http/http_cache_transaction.cc9
-rw-r--r--net/http/http_cache_unittest.cc10
-rw-r--r--net/url_request/view_cache_helper.cc8
5 files changed, 24 insertions, 22 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 8a44565..f1ddaf9 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -32,12 +32,6 @@
namespace net {
-// disk cache entry data indices.
-enum {
- kResponseInfoIndex,
- kResponseContentIndex
-};
-
//-----------------------------------------------------------------------------
HttpCache::ActiveEntry::ActiveEntry(disk_cache::Entry* e)
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index f9c1d7f..f8db513 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -28,6 +28,7 @@
#include "net/http/http_transaction_factory.h"
class GURL;
+class ViewCacheHelper;
namespace disk_cache {
class Backend;
@@ -158,6 +159,18 @@ class HttpCache : public HttpTransactionFactory,
enable_range_support_ = value;
}
+ protected:
+ // Disk cache entry data indices.
+ enum {
+ kResponseInfoIndex = 0,
+ kResponseContentIndex,
+ kMetadataIndex,
+
+ // Must remain at the end of the enum.
+ kNumCacheEntryDataIndices
+ };
+ friend class ::ViewCacheHelper;
+
private:
// Types --------------------------------------------------------------------
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 3ca78be..b5b3515 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -30,15 +30,6 @@ using base::Time;
namespace net {
-// disk cache entry data indices.
-enum {
- kResponseInfoIndex,
- kResponseContentIndex,
- kMetadataIndex
-};
-
-//-----------------------------------------------------------------------------
-
struct HeaderNameAndValue {
const char* name;
const char* value;
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 3132abe..4e8a139 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -62,6 +62,8 @@ int GetEffectiveTestMode(int test_mode) {
//-----------------------------------------------------------------------------
// mock disk cache (a very basic memory cache implementation)
+static const int kNumCacheEntryDataIndices = 3;
+
class MockDiskEntry : public disk_cache::Entry,
public base::RefCounted<MockDiskEntry> {
public:
@@ -101,13 +103,13 @@ class MockDiskEntry : public disk_cache::Entry,
}
virtual int32 GetDataSize(int index) const {
- DCHECK(index >= 0 && index < 3);
+ DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
return static_cast<int32>(data_[index].size());
}
virtual int ReadData(int index, int offset, net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
- DCHECK(index >= 0 && index < 3);
+ DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
if (fail_requests_)
return net::ERR_CACHE_READ_FAILURE;
@@ -130,7 +132,7 @@ class MockDiskEntry : public disk_cache::Entry,
virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback, bool truncate) {
- DCHECK(index >= 0 && index < 3);
+ DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
DCHECK(truncate);
if (fail_requests_)
@@ -338,7 +340,7 @@ class MockDiskEntry : public disk_cache::Entry,
}
std::string key_;
- std::vector<char> data_[3];
+ std::vector<char> data_[kNumCacheEntryDataIndices];
int test_mode_;
bool doomed_;
bool sparse_;
diff --git a/net/url_request/view_cache_helper.cc b/net/url_request/view_cache_helper.cc
index 2f19529..17dcab5 100644
--- a/net/url_request/view_cache_helper.cc
+++ b/net/url_request/view_cache_helper.cc
@@ -66,7 +66,8 @@ static std::string FormatEntryInfo(disk_cache::Entry* entry,
return row;
}
-static std::string FormatEntryDetails(disk_cache::Entry* entry) {
+static std::string FormatEntryDetails(disk_cache::Entry* entry,
+ int num_entry_data_indices) {
std::string result = EscapeForHTML(entry->GetKey());
net::HttpResponseInfo response;
@@ -91,7 +92,7 @@ static std::string FormatEntryDetails(disk_cache::Entry* entry) {
result.append("</pre>");
}
- for (int i = 0; i < 2; ++i) {
+ for (int i = 0; i < num_entry_data_indices; ++i) {
result.append("<hr><pre>");
int data_size = entry->GetDataSize(i);
@@ -160,7 +161,8 @@ void ViewCacheHelper::GetEntryInfoHTML(const std::string& key,
} else {
disk_cache::Entry* entry;
if (disk_cache->OpenEntry(key, &entry)) {
- data->assign(FormatEntryDetails(entry));
+ data->assign(FormatEntryDetails(
+ entry, net::HttpCache::kNumCacheEntryDataIndices));
entry->Close();
} else {
data->assign("no matching cache entry for: " + EscapeForHTML(key));