summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 19:05:33 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 19:05:33 +0000
commit6a98903971dc62cbb7c67510ea559a51d21222c7 (patch)
treef9a9fe4e70dbfe11ae1dcfa28c1969d06d6bcc5b /net/http/http_cache.cc
parente518616f8e5f78485c144591d2c78da6bf2ad175 (diff)
downloadchromium_src-6a98903971dc62cbb7c67510ea559a51d21222c7.zip
chromium_src-6a98903971dc62cbb7c67510ea559a51d21222c7.tar.gz
chromium_src-6a98903971dc62cbb7c67510ea559a51d21222c7.tar.bz2
Reland 49600 - Http cache: Remove deprecated code.
BUG=26729 TEST=current tests Review URL: http://codereview.chromium.org/2776007 TBR=rvargas@google.com Review URL: http://codereview.chromium.org/2809004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache.cc')
-rw-r--r--net/http/http_cache.cc66
1 files changed, 6 insertions, 60 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 585f9b5..162cc26 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -37,18 +37,8 @@ namespace net {
int HttpCache::DefaultBackend::CreateBackend(disk_cache::Backend** backend,
CompletionCallback* callback) {
DCHECK_GE(max_bytes_, 0);
- if (callback)
- return disk_cache::CreateCacheBackend(type_, path_, max_bytes_, true,
- thread_, backend, callback);
-
- // This is just old code needed to support synchronous cache creation.
- // TODO(rvargas): Remove this once all callers provide a callback.
- if (type_ == MEMORY_CACHE) {
- *backend = disk_cache::CreateInMemoryCacheBackend(max_bytes_);
- } else {
- *backend = disk_cache::CreateCacheBackend(path_, true, max_bytes_, type_);
- }
- return (*backend ? OK : ERR_FAILED);
+ return disk_cache::CreateCacheBackend(type_, path_, max_bytes_, true,
+ thread_, backend, callback);
}
//-----------------------------------------------------------------------------
@@ -301,19 +291,6 @@ HttpCache::~HttpCache() {
}
}
-disk_cache::Backend* HttpCache::GetBackend() {
- if (disk_cache_.get())
- return disk_cache_.get();
-
- if (backend_factory_.get()) {
- disk_cache::Backend* backend;
- if (OK == backend_factory_->CreateBackend(&backend, NULL))
- disk_cache_.reset(backend);
- backend_factory_.reset(); // Reclaim memory.
- }
- return disk_cache_.get();
-}
-
int HttpCache::GetBackend(disk_cache::Backend** backend,
CompletionCallback* callback) {
DCHECK(callback != NULL);
@@ -354,40 +331,6 @@ void HttpCache::Suspend(bool suspend) {
}
// static
-bool HttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry,
- HttpResponseInfo* response_info,
- bool* response_truncated) {
- int size = disk_entry->GetDataSize(kResponseInfoIndex);
-
- scoped_refptr<IOBuffer> buffer = new IOBuffer(size);
- int rv = disk_entry->ReadData(kResponseInfoIndex, 0, buffer, size, NULL);
- if (rv != size) {
- DLOG(ERROR) << "ReadData failed: " << rv;
- return false;
- }
-
- return ParseResponseInfo(buffer->data(), size, response_info,
- response_truncated);
-}
-
-// static
-bool HttpCache::WriteResponseInfo(disk_cache::Entry* disk_entry,
- const HttpResponseInfo* response_info,
- bool skip_transient_headers,
- bool response_truncated) {
- Pickle pickle;
- response_info->Persist(
- &pickle, skip_transient_headers, response_truncated);
-
- scoped_refptr<WrappedIOBuffer> data = new WrappedIOBuffer(
- reinterpret_cast<const char*>(pickle.data()));
- int len = static_cast<int>(pickle.size());
-
- return disk_entry->WriteData(kResponseInfoIndex, 0, data, len, NULL,
- true) == len;
-}
-
-// static
bool HttpCache::ParseResponseInfo(const char* data, int len,
HttpResponseInfo* response_info,
bool* response_truncated) {
@@ -401,7 +344,10 @@ void HttpCache::WriteMetadata(const GURL& url,
if (!buf_len)
return;
- GetBackend();
+ // Do lazy initialization of disk cache if needed.
+ if (!disk_cache_.get())
+ CreateBackend(NULL, NULL); // We don't care about the result.
+
HttpCache::Transaction* trans =
new HttpCache::Transaction(this, enable_range_support_);
MetadataWriter* writer = new MetadataWriter(trans);