diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 17:49:42 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 17:49:42 +0000 |
commit | 67b09ecdd8769cd291dbd0e52e73826771cf29b5 (patch) | |
tree | 7d11e7c41d0f448767a0676091f714a2d6712991 /net/disk_cache/entry_impl.cc | |
parent | 0bad9b1895f6f0264527a9986044d9d1ee9152b1 (diff) | |
download | chromium_src-67b09ecdd8769cd291dbd0e52e73826771cf29b5.zip chromium_src-67b09ecdd8769cd291dbd0e52e73826771cf29b5.tar.gz chromium_src-67b09ecdd8769cd291dbd0e52e73826771cf29b5.tar.bz2 |
Disk cache: For an AppCache, now we only update the
LRU list when an entry is created. This means that
we don't update the list anymore when an entry is
accessed, even if we are writing to the entry.
The general idea is that now we should be able to
open an AppCache and read from it without modifying
the contents of the cache, so that if the browser
crashes, we won't find "dirty" entries to discard.
By minimizing writes to the LRU list, we reduce the
chances that the list will get corrupt beyond the
point where we cannot trust it anymore if the whole
system crashes (and not just the browser).
BUG=51870
TEST=net_unittests
Review URL: http://codereview.chromium.org/3186032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r-- | net/disk_cache/entry_impl.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 8f514b0..f152f10 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -286,8 +286,8 @@ bool EntryImpl::UserBuffer::GrowBuffer(int required, int limit) { // ------------------------------------------------------------------------ -EntryImpl::EntryImpl(BackendImpl* backend, Addr address) - : entry_(NULL, Addr(0)), node_(NULL, Addr(0)) { +EntryImpl::EntryImpl(BackendImpl* backend, Addr address, bool read_only) + : entry_(NULL, Addr(0)), node_(NULL, Addr(0)), read_only_(read_only) { entry_.LazyInit(backend->File(address), address); doomed_ = false; backend_ = backend; @@ -394,7 +394,7 @@ int EntryImpl::ReadData(int index, int offset, net::IOBuffer* buf, int buf_len, if (!callback) return ReadDataImpl(index, offset, buf, buf_len, callback); - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); if (index < 0 || index >= kNumStreams) return net::ERR_INVALID_ARGUMENT; @@ -415,7 +415,7 @@ int EntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, if (!callback) return WriteDataImpl(index, offset, buf, buf_len, callback, truncate); - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); if (index < 0 || index >= kNumStreams) return net::ERR_INVALID_ARGUMENT; @@ -487,7 +487,7 @@ void EntryImpl::DoomImpl() { int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, CompletionCallback* callback) { - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); if (index < 0 || index >= kNumStreams) return net::ERR_INVALID_ARGUMENT; @@ -553,7 +553,7 @@ int EntryImpl::ReadDataImpl(int index, int offset, net::IOBuffer* buf, int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, int buf_len, CompletionCallback* callback, bool truncate) { - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); if (index < 0 || index >= kNumStreams) return net::ERR_INVALID_ARGUMENT; @@ -639,7 +639,7 @@ int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf, int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, CompletionCallback* callback) { - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); int result = InitSparseData(); if (net::OK != result) return result; @@ -653,7 +653,7 @@ int EntryImpl::ReadSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, int EntryImpl::WriteSparseDataImpl(int64 offset, net::IOBuffer* buf, int buf_len, CompletionCallback* callback) { - DCHECK(node_.Data()->dirty); + DCHECK(node_.Data()->dirty || read_only_); int result = InitSparseData(); if (net::OK != result) return result; @@ -820,6 +820,9 @@ bool EntryImpl::LoadNodeAddress() { bool EntryImpl::Update() { DCHECK(node_.HasData()); + if (read_only_) + return true; + RankingsNode* rankings = node_.Data(); if (!rankings->dirty) { rankings->dirty = backend_->GetCurrentEntryId(); @@ -956,7 +959,7 @@ void EntryImpl::DeleteData(Addr address, int index) { void EntryImpl::UpdateRank(bool modified) { if (!doomed_) { // Everything is handled by the backend. - backend_->UpdateRank(this, true); + backend_->UpdateRank(this, modified); return; } |