diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 01:35:18 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 01:35:18 +0000 |
commit | f73e358d841bef31ece39c4b0436b17869d6241b (patch) | |
tree | 5e1a27671c371b70bb17d100ac9b4ee620a05532 /net | |
parent | 5bc7183a8a86f77d79187b545f4442c02b4b5da4 (diff) | |
download | chromium_src-f73e358d841bef31ece39c4b0436b17869d6241b.zip chromium_src-f73e358d841bef31ece39c4b0436b17869d6241b.tar.gz chromium_src-f73e358d841bef31ece39c4b0436b17869d6241b.tar.bz2 |
Http cache: Remove the option to disable byte range support.
BUG=58323
TEST=current tests
Review URL: http://codereview.chromium.org/5522014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache.cc | 14 | ||||
-rw-r--r-- | net/http/http_cache.h | 6 | ||||
-rw-r--r-- | net/http/http_cache_transaction.cc | 29 | ||||
-rw-r--r-- | net/http/http_cache_transaction.h | 3 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 39 |
5 files changed, 12 insertions, 79 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 896a6ac..ea4e48b 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -297,8 +297,7 @@ HttpCache::HttpCache(HostResolver* host_resolver, ssl_host_info_factory_.get(), proxy_service, ssl_config_service, http_auth_handler_factory, network_delegate, net_log)), - ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), - enable_range_support_(true) { + ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { } HttpCache::HttpCache(HttpNetworkSession* session, @@ -307,8 +306,7 @@ HttpCache::HttpCache(HttpNetworkSession* session, building_backend_(false), mode_(NORMAL), network_layer_(HttpNetworkLayer::CreateFactory(session)), - ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), - enable_range_support_(true) { + ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { } HttpCache::HttpCache(HttpTransactionFactory* network_layer, @@ -317,8 +315,7 @@ HttpCache::HttpCache(HttpTransactionFactory* network_layer, building_backend_(false), mode_(NORMAL), network_layer_(network_layer), - ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), - enable_range_support_(true) { + ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { } HttpCache::~HttpCache() { @@ -385,7 +382,7 @@ int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { if (!disk_cache_.get()) CreateBackend(NULL, NULL); // We don't care about the result. - trans->reset(new HttpCache::Transaction(this, enable_range_support_)); + trans->reset(new HttpCache::Transaction(this)); return OK; } @@ -421,8 +418,7 @@ void HttpCache::WriteMetadata(const GURL& url, if (!disk_cache_.get()) CreateBackend(NULL, NULL); // We don't care about the result. - HttpCache::Transaction* trans = - new HttpCache::Transaction(this, enable_range_support_); + HttpCache::Transaction* trans = new HttpCache::Transaction(this); MetadataWriter* writer = new MetadataWriter(trans); // The writer will self destruct when done. diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 06c2ab9..4b7d736 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -179,10 +179,6 @@ class HttpCache : public HttpTransactionFactory, // immediately, but they will not be reusable. This is for debugging. void CloseCurrentConnections(); - void set_enable_range_support(bool value) { - enable_range_support_ = value; - } - protected: // Disk cache entry data indices. enum { @@ -368,8 +364,6 @@ class HttpCache : public HttpTransactionFactory, ScopedRunnableMethodFactory<HttpCache> task_factory_; - bool enable_range_support_; - typedef base::hash_map<std::string, int> PlaybackCacheMap; scoped_ptr<PlaybackCacheMap> playback_cache_map_; diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 1720509..923ee25 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -97,7 +97,7 @@ static bool HeaderMatches(const HttpRequestHeaders& headers, //----------------------------------------------------------------------------- -HttpCache::Transaction::Transaction(HttpCache* cache, bool enable_range_support) +HttpCache::Transaction::Transaction(HttpCache* cache) : next_state_(STATE_NONE), request_(NULL), cache_(cache->AsWeakPtr()), @@ -110,7 +110,6 @@ HttpCache::Transaction::Transaction(HttpCache* cache, bool enable_range_support) target_state_(STATE_NONE), reading_(false), invalid_range_(false), - enable_range_support_(enable_range_support), truncated_(false), is_sparse_(false), server_responded_206_(false), @@ -139,7 +138,7 @@ HttpCache::Transaction::~Transaction() { if (cache_) { if (entry_) { - bool cancel_request = reading_ && enable_range_support_; + bool cancel_request = reading_; if (cancel_request) { if (partial_.get()) { entry_->disk_entry->CancelSparseIO(); @@ -683,7 +682,7 @@ int HttpCache::Transaction::DoSuccessfulSendRequest() { DoneWritingToEntry(false); } - if (enable_range_support_ && new_response_->headers->response_code() == 416) { + if (new_response_->headers->response_code() == 416) { DCHECK_EQ(NONE, mode_); response_ = *new_response_; return OK; @@ -1284,13 +1283,8 @@ void HttpCache::Transaction::SetRequest(const BoundNetLog& net_log, bool range_found = false; bool external_validation_error = false; - if (request_->extra_headers.HasHeader(HttpRequestHeaders::kRange)) { - if (enable_range_support_) { - range_found = true; - } else { - effective_load_flags_ |= LOAD_DISABLE_CACHE; - } - } + if (request_->extra_headers.HasHeader(HttpRequestHeaders::kRange)) + range_found = true; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSpecialHeaders); ++i) { if (HeaderMatches(request_->extra_headers, kSpecialHeaders[i].search)) { @@ -1429,9 +1423,6 @@ int HttpCache::Transaction::BeginPartialCacheValidation() { !truncated_) return BeginCacheValidation(); - if (!enable_range_support_) - return BeginCacheValidation(); - bool byte_range_requested = partial_.get() != NULL; if (byte_range_requested) { next_state_ = STATE_CACHE_QUERY_DATA; @@ -1552,9 +1543,6 @@ bool HttpCache::Transaction::RequiresValidation() { if (effective_load_flags_ & LOAD_VALIDATE_CACHE) return true; - if (response_.headers->response_code() == 206 && !enable_range_support_) - return true; - if (response_.headers->RequiresValidation( response_.request_time, response_.response_time, Time::Now())) return true; @@ -1570,11 +1558,6 @@ bool HttpCache::Transaction::RequiresValidation() { bool HttpCache::Transaction::ConditionalizeRequest() { DCHECK(response_.headers); - if (!enable_range_support_ && response_.headers->response_code() != 200) { - // This only makes sense for cached 200 responses. - return false; - } - // This only makes sense for cached 200 or 206 responses. if (response_.headers->response_code() != 200 && response_.headers->response_code() != 206) @@ -1653,7 +1636,7 @@ bool HttpCache::Transaction::ConditionalizeRequest() { bool HttpCache::Transaction::ValidatePartialResponse(bool* partial_content) { const HttpResponseHeaders* headers = new_response_->headers; int response_code = headers->response_code(); - bool partial_response = enable_range_support_ ? response_code == 206 : false; + bool partial_response = (response_code == 206); *partial_content = false; if (!entry_) diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h index a842ade..bc0b211 100644 --- a/net/http/http_cache_transaction.h +++ b/net/http/http_cache_transaction.h @@ -28,7 +28,7 @@ struct HttpRequestInfo; // factory. class HttpCache::Transaction : public HttpTransaction { public: - Transaction(HttpCache* cache, bool enable_range_support); + Transaction(HttpCache* cache); virtual ~Transaction(); // HttpTransaction methods: @@ -339,7 +339,6 @@ class HttpCache::Transaction : public HttpTransaction { State target_state_; bool reading_; // We are already reading. bool invalid_range_; // We may bypass the cache for this request. - bool enable_range_support_; bool truncated_; // We don't have all the response data. bool is_sparse_; // The data is stored in sparse byte ranges. bool server_responded_206_; diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 1e4c7a4..a40a5b8 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -2778,7 +2778,6 @@ TEST(HttpCache, RangeGET_SkipsCache) { // header. TEST(HttpCache, RangeGET_SkipsCache2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kRangeGET_Transaction); transaction.request_headers = "If-None-Match: foo\r\n" @@ -2813,7 +2812,6 @@ TEST(HttpCache, RangeGET_SkipsCache2) { // Tests that receiving 206 for a regular request is handled correctly. TEST(HttpCache, GET_Crazy206) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); // Write to the cache. MockTransaction transaction(kRangeGET_TransactionOK); @@ -2839,7 +2837,6 @@ TEST(HttpCache, GET_Crazy206) { // cache and the network. TEST(HttpCache, RangeGET_OK) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -2895,7 +2892,6 @@ TEST(HttpCache, RangeGET_OK) { // cache and the network, with synchronous responses. TEST(HttpCache, RangeGET_SyncOK) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kRangeGET_TransactionOK); transaction.test_mode = TEST_MODE_SYNC_ALL; @@ -2950,7 +2946,6 @@ TEST(HttpCache, RangeGET_SyncOK) { // Tests that we don't revalidate an entry unless we are required to do so. TEST(HttpCache, RangeGET_Revalidate1) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; // Write to the cache (40-49). @@ -2992,7 +2987,6 @@ TEST(HttpCache, RangeGET_Revalidate1) { // Checks that we revalidate an entry when the headers say so. TEST(HttpCache, RangeGET_Revalidate2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; // Write to the cache (40-49). @@ -3025,7 +3019,6 @@ TEST(HttpCache, RangeGET_Revalidate2) { // Tests that we deal with 304s for range requests. TEST(HttpCache, RangeGET_304) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3056,7 +3049,6 @@ TEST(HttpCache, RangeGET_304) { // Tests that we deal with 206s when revalidating range requests. TEST(HttpCache, RangeGET_ModifiedResult) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3094,7 +3086,6 @@ TEST(HttpCache, RangeGET_ModifiedResult) { // We start with one suffix request, followed by a request from a given point. TEST(HttpCache, UnknownRangeGET_1) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3130,7 +3121,6 @@ TEST(HttpCache, UnknownRangeGET_1) { // We'll also verify that synchronous cache responses work as intended. TEST(HttpCache, UnknownRangeGET_2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3169,7 +3159,6 @@ TEST(HttpCache, UnknownRangeGET_2) { // up things. TEST(HttpCache, UnknownRangeGET_304) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3198,7 +3187,6 @@ TEST(HttpCache, UnknownRangeGET_304) { // Tests that we can handle non-range requests when we have cached a range. TEST(HttpCache, GET_Previous206) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3230,7 +3218,6 @@ TEST(HttpCache, GET_Previous206) { // part of the object and the server replies with 304 (Not Modified). TEST(HttpCache, GET_Previous206_NotModified) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kRangeGET_TransactionOK); AddMockTransaction(&transaction); @@ -3271,7 +3258,6 @@ TEST(HttpCache, GET_Previous206_NotModified) { // new content provided by the server (206). TEST(HttpCache, GET_Previous206_NewContent) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3313,7 +3299,6 @@ TEST(HttpCache, GET_Previous206_NewContent) { // Tests that we can handle cached 206 responses that are not sparse. TEST(HttpCache, GET_Previous206_NotSparse) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); // Create a disk cache entry that stores 206 headers while not being sparse. disk_cache::Entry* entry; @@ -3356,7 +3341,6 @@ TEST(HttpCache, GET_Previous206_NotSparse) { // we issue a range request and expect to receive a range. TEST(HttpCache, RangeGET_Previous206_NotSparse_2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Create a disk cache entry that stores 206 headers while not being sparse. @@ -3398,7 +3382,6 @@ TEST(HttpCache, RangeGET_Previous206_NotSparse_2) { // Tests that we can handle range requests with cached 200 responses. TEST(HttpCache, RangeGET_Previous200) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); // Store the whole thing with status 200. MockTransaction transaction(kTypicalGET_Transaction); @@ -3469,7 +3452,6 @@ TEST(HttpCache, RangeGET_Previous200) { // Tests that we can handle a 200 response when dealing with sparse entries. TEST(HttpCache, RangeRequestResultsIn200) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3510,7 +3492,6 @@ TEST(HttpCache, RangeRequestResultsIn200) { // only deletes the entry if the resource has indeed changed. TEST(HttpCache, RangeGET_MoreThanCurrentSize) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); std::string headers; @@ -3544,7 +3525,6 @@ TEST(HttpCache, RangeGET_MoreThanCurrentSize) { // Tests that we don't delete a sparse entry when we cancel a request. TEST(HttpCache, RangeGET_Cancel) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); MockHttpRequest request(kRangeGET_TransactionOK); @@ -3582,7 +3562,6 @@ TEST(HttpCache, RangeGET_Cancel) { // cancelling the previous one. TEST(HttpCache, RangeGET_Cancel2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); @@ -3628,7 +3607,6 @@ TEST(HttpCache, RangeGET_Cancel2) { // a row, making sure that the second is waiting for the entry to be ready. TEST(HttpCache, RangeGET_Cancel3) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); @@ -3688,7 +3666,6 @@ TEST(HttpCache, RangeGET_Cancel3) { // Tests that an invalid range response results in no cached entry. TEST(HttpCache, RangeGET_InvalidResponse1) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3717,7 +3694,6 @@ TEST(HttpCache, RangeGET_InvalidResponse1) { // Tests that we reject a range that doesn't match the content-length. TEST(HttpCache, RangeGET_InvalidResponse2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3747,7 +3723,6 @@ TEST(HttpCache, RangeGET_InvalidResponse2) { // ignore the response. TEST(HttpCache, RangeGET_InvalidResponse3) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3795,7 +3770,6 @@ TEST(HttpCache, RangeGET_InvalidResponse3) { TEST(HttpCache, RangeGET_LargeValues) { // We need a real sparse cache for this test. MockHttpCache cache(net::HttpCache::DefaultBackend::InMemory(1024 * 1024)); - cache.http_cache()->set_enable_range_support(true); std::string headers; MockTransaction transaction(kRangeGET_TransactionOK); @@ -3831,7 +3805,6 @@ TEST(HttpCache, RangeGET_NoDiskCache) { factory->FinishCreation(); // We'll complete synchronously. MockHttpCache cache(factory); - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); @@ -3843,7 +3816,6 @@ TEST(HttpCache, RangeGET_NoDiskCache) { // Tests that we handle byte range requests that skip the cache. TEST(HttpCache, RangeHEAD) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); MockTransaction transaction(kRangeGET_TransactionOK); @@ -3866,7 +3838,6 @@ TEST(HttpCache, RangeHEAD) { // request for the next range and the server gives us a 200 synchronously. TEST(HttpCache, RangeGET_FastFlakyServer) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kRangeGET_TransactionOK); transaction.request_headers = "Range: bytes = 40-\r\n" EXTRA_HEADER; @@ -3893,7 +3864,6 @@ TEST(HttpCache, RangeGET_FastFlakyServer) { // asking for more data. TEST(HttpCache, RangeGET_FastFlakyServer2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); // First, check with an empty cache (WRITE mode). MockTransaction transaction(kRangeGET_TransactionOK); @@ -3934,7 +3904,6 @@ TEST(HttpCache, RangeGET_FastFlakyServer2) { // This test hits a NOTREACHED so it is a release mode only test. TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Write to the cache (40-49). @@ -3999,7 +3968,6 @@ TEST(HttpCache, WriteResponseInfo_Truncated) { // to read from the network. TEST(HttpCache, DoomOnDestruction) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockHttpRequest request(kSimpleGET_Transaction); @@ -4030,7 +3998,6 @@ TEST(HttpCache, DoomOnDestruction) { // does not have content-length and strong validators. TEST(HttpCache, DoomOnDestruction2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockHttpRequest request(kSimpleGET_Transaction); @@ -4067,7 +4034,6 @@ TEST(HttpCache, DoomOnDestruction2) { // has an "Accept-Ranges: none" header. TEST(HttpCache, DoomOnDestruction3) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kSimpleGET_Transaction); transaction.response_headers = @@ -4112,7 +4078,6 @@ TEST(HttpCache, DoomOnDestruction3) { // Tests that we mark an entry as incomplete when the request is cancelled. TEST(HttpCache, Set_Truncated_Flag) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); MockTransaction transaction(kSimpleGET_Transaction); transaction.response_headers = @@ -4173,7 +4138,6 @@ TEST(HttpCache, Set_Truncated_Flag) { // Tests that we can continue with a request that was interrupted. TEST(HttpCache, GET_IncompleteResource) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Create a disk cache entry that stores an incomplete resource. @@ -4234,7 +4198,6 @@ TEST(HttpCache, GET_IncompleteResource) { // Tests that we delete truncated entries if the server changes its mind midway. TEST(HttpCache, GET_IncompleteResource2) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Create a disk cache entry that stores an incomplete resource. @@ -4294,7 +4257,6 @@ TEST(HttpCache, GET_IncompleteResource2) { // as truncated. TEST(HttpCache, GET_CancelIncompleteResource) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Create a disk cache entry that stores an incomplete resource. @@ -4360,7 +4322,6 @@ TEST(HttpCache, GET_CancelIncompleteResource) { // Tests that we can handle range requests when we have a truncated entry. TEST(HttpCache, RangeGET_IncompleteResource) { MockHttpCache cache; - cache.http_cache()->set_enable_range_support(true); AddMockTransaction(&kRangeGET_TransactionOK); // Create a disk cache entry that stores an incomplete resource. |