summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 22:07:37 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 22:07:37 +0000
commit7bd394d220e29b212b9480cb8a7f4986cb8275ce (patch)
tree18342f9a8c2b2b840af8cea6ccf127902b0d1253 /net/http
parent1db97ce76cad4c569c4ae79ad1422620ea5d97cf (diff)
downloadchromium_src-7bd394d220e29b212b9480cb8a7f4986cb8275ce.zip
chromium_src-7bd394d220e29b212b9480cb8a7f4986cb8275ce.tar.gz
chromium_src-7bd394d220e29b212b9480cb8a7f4986cb8275ce.tar.bz2
Revert cl 24015
BUG=none TEST=none Review URL: http://codereview.chromium.org/174260 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache.cc44
-rw-r--r--net/http/http_cache.h5
-rw-r--r--net/http/http_cache_unittest.cc45
3 files changed, 39 insertions, 55 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 303f9ba..4de8080 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -13,8 +13,6 @@
#include <unistd.h>
#endif
-#include "base/base_switches.h"
-#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/ref_counted.h"
@@ -36,6 +34,9 @@
using base::Time;
+// Uncomment this to enable experimental byte-range support.
+// #define ENABLE_RANGE_SUPPORT
+
namespace net {
// disk cache entry data indices.
@@ -169,7 +170,7 @@ HttpCache::ActiveEntry::~ActiveEntry() {
class HttpCache::Transaction
: public HttpTransaction, public RevocableStore::Revocable {
public:
- Transaction(HttpCache* cache, bool enable_range_support)
+ explicit Transaction(HttpCache* cache)
: RevocableStore::Revocable(&cache->transactions_),
request_(NULL),
cache_(cache),
@@ -179,7 +180,6 @@ class HttpCache::Transaction
mode_(NONE),
reading_(false),
invalid_range_(false),
- enable_range_support_(enable_range_support),
read_offset_(0),
effective_load_flags_(0),
final_upload_progress_(0),
@@ -386,7 +386,6 @@ class HttpCache::Transaction
Mode mode_;
bool reading_; // We are already reading.
bool invalid_range_; // We may bypass the cache for this request.
- bool enable_range_support_;
scoped_refptr<IOBuffer> read_buf_;
int read_buf_len_;
int read_offset_;
@@ -778,12 +777,12 @@ void HttpCache::Transaction::SetRequest(LoadLog* load_log,
new_extra_headers.append(it.name_begin(), it.values_end());
new_extra_headers.append("\r\n");
} else {
- if (enable_range_support_) {
- range_found = true;
- } else {
- effective_load_flags_ |= LOAD_DISABLE_CACHE;
- continue;
- }
+#ifdef ENABLE_RANGE_SUPPORT
+ range_found = true;
+#else
+ effective_load_flags_ |= LOAD_DISABLE_CACHE;
+ continue;
+#endif
}
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSpecialHeaders); ++i) {
if (HeaderMatches(it, kSpecialHeaders[i].search)) {
@@ -908,8 +907,9 @@ int HttpCache::Transaction::BeginPartialCacheValidation() {
if (response_.headers->response_code() != 206 && !partial_.get())
return BeginCacheValidation();
- if (!enable_range_support_)
- return BeginCacheValidation();
+#if !defined(ENABLE_RANGE_SUPPORT)
+ return BeginCacheValidation();
+#endif
bool byte_range_requested = partial_.get() != NULL;
if (!byte_range_requested) {
@@ -1070,10 +1070,11 @@ 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.
+#if !defined(ENABLE_RANGE_SUPPORT)
+ // This only makes sense for cached 200 responses.
+ if (response_.headers->response_code() != 200)
return false;
- }
+#endif
// This only makes sense for cached 200 or 206 responses.
if (response_.headers->response_code() != 200 &&
@@ -1146,8 +1147,12 @@ bool HttpCache::Transaction::ConditionalizeRequest() {
// course, maybe we already returned the headers.
bool HttpCache::Transaction::ValidatePartialResponse(
const HttpResponseHeaders* headers) {
- int response_code = headers->response_code();
- bool partial_content = enable_range_support_ ? response_code == 206 : false;
+ int response_code = headers->response_code();
+#ifdef ENABLE_RANGE_SUPPORT
+ bool partial_content = response_code == 206;
+#else
+ bool partial_content = false;
+#endif
if (invalid_range_) {
// We gave up trying to match this request with the stored data. If the
@@ -1580,7 +1585,6 @@ HttpCache::HttpCache(HttpTransactionFactory* network_layer,
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
in_memory_cache_(false),
deleted_(false),
- enable_range_support_(false),
cache_size_(0) {
}
@@ -1621,7 +1625,7 @@ HttpTransaction* HttpCache::CreateTransaction() {
disk_cache_dir_.clear(); // Reclaim memory.
}
}
- return new HttpCache::Transaction(this, enable_range_support_);
+ return new HttpCache::Transaction(this);
}
HttpCache* HttpCache::GetCache() {
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index af5c55e..19c4331 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -116,10 +116,6 @@ class HttpCache : public HttpTransactionFactory {
// Close All Idle Sockets. This is for debugging.
void CloseIdleConnections();
- void set_enable_range_support(bool value) {
- enable_range_support_ = value;
- }
-
private:
// Types --------------------------------------------------------------------
@@ -192,7 +188,6 @@ class HttpCache : public HttpTransactionFactory {
bool in_memory_cache_;
bool deleted_; // TODO(rvargas): remove this member. See bug 9952.
- bool enable_range_support_;
int cache_size_;
typedef base::hash_map<std::string, int> PlaybackCacheMap;
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 90b0774..14299b0 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1639,7 +1639,6 @@ TEST(HttpCache, SimplePOST_LoadOnlyFromCache_Hit) {
TEST(HttpCache, RangeGET_SkipsCache) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
// Test that we skip the cache for range GET requests. Eventually, we will
// want to cache these, but we'll still have cases where skipping the cache
@@ -1671,7 +1670,6 @@ TEST(HttpCache, RangeGET_SkipsCache) {
// 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);
@@ -1688,16 +1686,15 @@ TEST(HttpCache, GET_Crazy206) {
RunTransactionTest(cache.http_cache(), transaction);
EXPECT_EQ(2, cache.network_layer()->transaction_count());
- EXPECT_EQ(0, cache.disk_cache()->open_count());
- EXPECT_EQ(2, cache.disk_cache()->create_count());
+ EXPECT_EQ(1, cache.disk_cache()->open_count());
+ EXPECT_EQ(1, cache.disk_cache()->create_count());
RemoveMockTransaction(&transaction);
}
// Tests that we can cache range requests and fetch random blocks from the
// cache and the network.
-TEST(HttpCache, RangeGET_OK) {
+TEST(HttpCache, DISABLED_RangeGET_OK) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -1750,9 +1747,8 @@ TEST(HttpCache, RangeGET_OK) {
}
// Tests that we deal with 304s for range requests.
-TEST(HttpCache, RangeGET_304) {
+TEST(HttpCache, DISABLED_RangeGET_304) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -1780,9 +1776,8 @@ TEST(HttpCache, RangeGET_304) {
}
// Tests that we deal with 206s when revalidating range requests.
-TEST(HttpCache, RangeGET_ModifiedResult) {
+TEST(HttpCache, DISABLED_RangeGET_ModifiedResult) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -1817,9 +1812,8 @@ TEST(HttpCache, RangeGET_ModifiedResult) {
// Tests that we can cache range requests when the start or end is unknown.
// We start with one suffix request, followed by a request from a given point.
-TEST(HttpCache, UnknownRangeGET_1) {
+TEST(HttpCache, DISABLED_UnknownRangeGET_1) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -1853,9 +1847,8 @@ TEST(HttpCache, UnknownRangeGET_1) {
// Tests that we can cache range requests when the start or end is unknown.
// We start with one request from a given point, followed by a suffix request.
// We'll also verify that synchronous cache responses work as intended.
-TEST(HttpCache, UnknownRangeGET_2) {
+TEST(HttpCache, DISABLED_UnknownRangeGET_2) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
std::string headers;
MockTransaction transaction(kRangeGET_TransactionOK);
@@ -1891,9 +1884,8 @@ TEST(HttpCache, UnknownRangeGET_2) {
// Tests that receiving Not Modified when asking for an open range doesn't mess
// up things.
-TEST(HttpCache, UnknownRangeGET_304) {
+TEST(HttpCache, DISABLED_UnknownRangeGET_304) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
std::string headers;
MockTransaction transaction(kRangeGET_TransactionOK);
@@ -1920,9 +1912,8 @@ TEST(HttpCache, UnknownRangeGET_304) {
}
// Tests that we can handle non-range requests when we have cached a range.
-TEST(HttpCache, GET_Previous206) {
+TEST(HttpCache, DISABLED_GET_Previous206) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -1951,9 +1942,8 @@ TEST(HttpCache, GET_Previous206) {
}
// Tests that we can handle cached 206 responses that are not sparse.
-TEST(HttpCache, GET_Previous206_NotSparse) {
+TEST(HttpCache, DISABLED_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;
@@ -1993,9 +1983,8 @@ TEST(HttpCache, GET_Previous206_NotSparse) {
// Tests that we can handle cached 206 responses that are not sparse. This time
// we issue a range request and expect to receive a range.
-TEST(HttpCache, RangeGET_Previous206_NotSparse_2) {
+TEST(HttpCache, DISABLED_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.
@@ -2034,9 +2023,8 @@ TEST(HttpCache, RangeGET_Previous206_NotSparse_2) {
}
// Tests that we can handle range requests with cached 200 responses.
-TEST(HttpCache, RangeGET_Previous200) {
+TEST(HttpCache, DISABLED_RangeGET_Previous200) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
// Store the whole thing with status 200.
MockTransaction transaction(kTypicalGET_Transaction);
@@ -2081,9 +2069,8 @@ TEST(HttpCache, RangeGET_Previous200) {
}
// Tests that we can handle a 200 response when dealing with sparse entries.
-TEST(HttpCache, RangeRequestResultsIn200) {
+TEST(HttpCache, DISABLED_RangeRequestResultsIn200) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -2122,9 +2109,8 @@ TEST(HttpCache, RangeRequestResultsIn200) {
// Tests that a range request that falls outside of the size that we know about
// only deletes the entry if the resource has indeed changed.
-TEST(HttpCache, RangeGET_MoreThanCurrentSize) {
+TEST(HttpCache, DISABLED_RangeGET_MoreThanCurrentSize) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
std::string headers;
@@ -2156,9 +2142,8 @@ TEST(HttpCache, RangeGET_MoreThanCurrentSize) {
#ifdef NDEBUG
// This test hits a NOTREACHED so it is a release mode only test.
-TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) {
+TEST(HttpCache, DISABLED_RangeGET_OK_LoadOnlyFromCache) {
MockHttpCache cache;
- cache.http_cache()->set_enable_range_support(true);
AddMockTransaction(&kRangeGET_TransactionOK);
// Write to the cache (40-49).