From 62cdf1eb96a4c410b503652a5656e0b197b1b9eb Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Thu, 4 Dec 2008 23:03:33 +0000 Subject: Disk cache: Add support for an extra data stream for each cache entry. This is the first step to allow the http cache to store additional metadata for certain entries. The cache file format changes to version 2.0 so an effect of this cl is that the borwser will discard the old cache files. Review URL: http://codereview.chromium.org/12880 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6392 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/mem_entry_impl.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'net/disk_cache/mem_entry_impl.cc') diff --git a/net/disk_cache/mem_entry_impl.cc b/net/disk_cache/mem_entry_impl.cc index 2bbf4a5..6bc7b6b 100644 --- a/net/disk_cache/mem_entry_impl.cc +++ b/net/disk_cache/mem_entry_impl.cc @@ -15,12 +15,13 @@ MemEntryImpl::MemEntryImpl(MemBackendImpl* backend) { doomed_ = false; backend_ = backend; ref_count_ = 0; - data_size_[0] = data_size_[1] = 0; + for (int i = 0; i < NUM_STREAMS; i++) + data_size_[i] = 0; } MemEntryImpl::~MemEntryImpl() { - backend_->ModifyStorageSize(data_size_[0], 0); - backend_->ModifyStorageSize(data_size_[1], 0); + for (int i = 0; i < NUM_STREAMS; i++) + backend_->ModifyStorageSize(data_size_[i], 0); backend_->ModifyStorageSize(static_cast(key_.size()), 0); } @@ -75,7 +76,7 @@ Time MemEntryImpl::GetLastModified() const { } int32 MemEntryImpl::GetDataSize(int index) const { - if (index < 0 || index > 1) + if (index < 0 || index >= NUM_STREAMS) return 0; return data_size_[index]; @@ -83,7 +84,7 @@ int32 MemEntryImpl::GetDataSize(int index) const { int MemEntryImpl::ReadData(int index, int offset, char* buf, int buf_len, net::CompletionCallback* completion_callback) { - if (index < 0 || index > 1) + if (index < 0 || index >= NUM_STREAMS) return net::ERR_INVALID_ARGUMENT; int entry_size = GetDataSize(index); @@ -105,7 +106,7 @@ int MemEntryImpl::ReadData(int index, int offset, char* buf, int buf_len, int MemEntryImpl::WriteData(int index, int offset, const char* buf, int buf_len, net::CompletionCallback* completion_callback, bool truncate) { - if (index < 0 || index > 1) + if (index < 0 || index >= NUM_STREAMS) return net::ERR_INVALID_ARGUMENT; if (offset < 0 || buf_len < 0) -- cgit v1.1