diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-14 19:05:33 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-14 19:05:33 +0000 |
commit | 6a98903971dc62cbb7c67510ea559a51d21222c7 (patch) | |
tree | f9a9fe4e70dbfe11ae1dcfa28c1969d06d6bcc5b /net/http | |
parent | e518616f8e5f78485c144591d2c78da6bf2ad175 (diff) | |
download | chromium_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')
-rw-r--r-- | net/http/http_cache.cc | 66 | ||||
-rw-r--r-- | net/http/http_cache.h | 21 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 13 |
3 files changed, 16 insertions, 84 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); diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 79c2134..04dc144 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -135,12 +135,6 @@ class HttpCache : public HttpTransactionFactory, HttpTransactionFactory* network_layer() { return network_layer_.get(); } - // Returns the cache backend for this HttpCache instance. If the backend - // is not initialized yet, this method will initialize it. If the return - // value is NULL then the backend cannot be initialized. - // This method is deprecated. - disk_cache::Backend* GetBackend(); - // Retrieves the cache backend for this HttpCache instance. If the backend // is not initialized yet, this method will initialize it. The return value is // a network error code, and it could be ERR_IO_PENDING, in which case the @@ -157,21 +151,6 @@ class HttpCache : public HttpTransactionFactory, virtual HttpNetworkSession* GetSession(); virtual void Suspend(bool suspend); - // Helper function for reading response info from the disk cache. If the - // cache doesn't have the whole resource *|request_truncated| is set to true. - // NOTE: This method is deprecated. - static bool ReadResponseInfo(disk_cache::Entry* disk_entry, - HttpResponseInfo* response_info, - bool* response_truncated); - - // Helper function for writing response info into the disk cache. If the - // cache doesn't have the whole resource |request_truncated| should be true. - // NOTE: This method is deprecated. - static bool WriteResponseInfo(disk_cache::Entry* disk_entry, - const HttpResponseInfo* response_info, - bool skip_transient_headers, - bool response_truncated); - // Given a header data blob, convert it to a response info object. static bool ParseResponseInfo(const char* data, int len, HttpResponseInfo* response_info, diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 4337d3b..ed2f377 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -591,7 +591,11 @@ class MockHttpCache { return static_cast<MockNetworkLayer*>(http_cache_.network_layer()); } MockDiskCache* disk_cache() { - return static_cast<MockDiskCache*>(http_cache_.GetBackend()); + TestCompletionCallback cb; + disk_cache::Backend* backend; + int rv = http_cache_.GetBackend(&backend, &cb); + rv = cb.GetResult(rv); + return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL; } // Helper function for reading response info from the disk cache. @@ -1018,8 +1022,11 @@ TEST(HttpCache, CreateThenDestroy) { TEST(HttpCache, GetBackend) { MockHttpCache cache(net::HttpCache::DefaultBackend::InMemory(0)); + disk_cache::Backend* backend; + TestCompletionCallback cb; // This will lazily initialize the backend. - EXPECT_TRUE(cache.http_cache()->GetBackend()); + int rv = cache.http_cache()->GetBackend(&backend, &cb); + EXPECT_EQ(net::OK, cb.GetResult(rv)); } TEST(HttpCache, SimpleGET) { @@ -1076,7 +1083,7 @@ TEST(HttpCache, SimpleGETNoDiskCache2) { RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); EXPECT_EQ(1, cache.network_layer()->transaction_count()); - EXPECT_FALSE(cache.http_cache()->GetBackend()); + EXPECT_FALSE(cache.http_cache()->GetCurrentBackend()); } TEST(HttpCache, SimpleGETWithDiskFailures) { |