diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 23:46:58 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 23:46:58 +0000 |
commit | 84d4ceeee6546783aff920ba0625c0ce01f624ef (patch) | |
tree | 502d43daabfcabfc08a8b5b24cf302ddbe265cfa /net/disk_cache/entry_impl.cc | |
parent | a8c1a314d8277b7ce4f701ce73957146e61a215f (diff) | |
download | chromium_src-84d4ceeee6546783aff920ba0625c0ce01f624ef.zip chromium_src-84d4ceeee6546783aff920ba0625c0ce01f624ef.tar.gz chromium_src-84d4ceeee6546783aff920ba0625c0ce01f624ef.tar.bz2 |
Disk cache: First pass to add support for sparse entries.
Adding Read/Write support.
BUG=12258
TEST=unittests.
original review: http://codereview.chromium.org/126179
Review URL: http://codereview.chromium.org/132031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r-- | net/disk_cache/entry_impl.cc | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index ea20b3c..c9bab9a 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,8 +10,10 @@ #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/disk_cache/backend_impl.h" +#include "net/disk_cache/bitmap.h" #include "net/disk_cache/cache_util.h" #include "net/disk_cache/histogram_macros.h" +#include "net/disk_cache/sparse_control.h" using base::Time; using base::TimeDelta; @@ -91,6 +93,9 @@ EntryImpl::EntryImpl(BackendImpl* backend, Addr address) // data related to a previous cache entry because the range was not fully // written before). EntryImpl::~EntryImpl() { + // Save the sparse info to disk before deleting this entry. + sparse_.reset(); + if (doomed_) { DeleteEntryData(true); } else { @@ -353,16 +358,32 @@ int EntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, int EntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, net::CompletionCallback* completion_callback) { - return net::ERR_CACHE_OPERATION_NOT_SUPPORTED; + DCHECK(node_.Data()->dirty); + int result = InitSparseData(); + if (net::OK != result) + return result; + + return sparse_->StartIO(SparseControl::kReadOperation, offset, buf, buf_len, + completion_callback); } int EntryImpl::WriteSparseData(int64 offset, net::IOBuffer* buf, int buf_len, net::CompletionCallback* completion_callback) { - return net::ERR_CACHE_OPERATION_NOT_SUPPORTED; + DCHECK(node_.Data()->dirty); + int result = InitSparseData(); + if (net::OK != result) + return result; + + return sparse_->StartIO(SparseControl::kWriteOperation, offset, buf, buf_len, + completion_callback); } int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start) { - return net::ERR_CACHE_OPERATION_NOT_SUPPORTED; + int result = InitSparseData(); + if (net::OK != result) + return result; + + return sparse_->GetAvailableRange(offset, len, start); } uint32 EntryImpl::GetHash() { @@ -813,6 +834,17 @@ bool EntryImpl::Flush(int index, int size, bool async) { return true; } +int EntryImpl::InitSparseData() { + if (sparse_.get()) + return net::OK; + + sparse_.reset(new SparseControl(this)); + int result = sparse_->Init(); + if (net::OK != result) + sparse_.reset(); + return result; +} + void EntryImpl::Log(const char* msg) { void* pointer = NULL; int dirty = 0; |