Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: net/http/mock_http_cache.cc

Issue 22926031: Sparse IO: Allow failover to network in debug builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trying another upload, hopefully it will override the previous "old chunk mismatch" Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/mock_http_cache.cc
diff --git a/net/http/mock_http_cache.cc b/net/http/mock_http_cache.cc
index 85ffa74584efe289123c9f7d8da4691427d60e12..a3d55b17e6b57fbf7d32003bc6a1cfd6bce93579 100644
--- a/net/http/mock_http_cache.cc
+++ b/net/http/mock_http_cache.cc
@@ -50,14 +50,10 @@ struct MockDiskEntry::CallbackInfo {
int result;
};
-MockDiskEntry::MockDiskEntry()
- : test_mode_(0), doomed_(false), sparse_(false),
- fail_requests_(false), busy_(false), delayed_(false) {
-}
-
MockDiskEntry::MockDiskEntry(const std::string& key)
: key_(key), doomed_(false), sparse_(false),
- fail_requests_(false), busy_(false), delayed_(false) {
+ fail_requests_(false), fail_sparse_requests_(false), busy_(false),
+ delayed_(false) {
test_mode_ = GetTestModeForEntry(key);
}
@@ -139,6 +135,8 @@ int MockDiskEntry::WriteData(
int MockDiskEntry::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
const net::CompletionCallback& callback) {
DCHECK(!callback.is_null());
+ if (fail_sparse_requests_)
+ return net::ERR_NOT_IMPLEMENTED;
if (!sparse_ || busy_)
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
if (offset < 0)
@@ -169,6 +167,8 @@ int MockDiskEntry::WriteSparseData(int64 offset, net::IOBuffer* buf,
int buf_len,
const net::CompletionCallback& callback) {
DCHECK(!callback.is_null());
+ if (fail_sparse_requests_)
+ return net::ERR_NOT_IMPLEMENTED;
if (busy_)
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
if (!sparse_) {
@@ -237,6 +237,8 @@ int MockDiskEntry::GetAvailableRange(int64 offset, int len, int64* start,
}
bool MockDiskEntry::CouldBeSparse() const {
+ if (fail_sparse_requests_)
+ return false;
return sparse_;
}
@@ -245,6 +247,8 @@ void MockDiskEntry::CancelSparseIO() {
}
int MockDiskEntry::ReadyForSparseIO(const net::CompletionCallback& callback) {
+ if (fail_sparse_requests_)
+ return net::ERR_NOT_IMPLEMENTED;
if (!cancel_)
return net::OK;
@@ -333,7 +337,8 @@ bool MockDiskEntry::ignore_callbacks_ = false;
MockDiskCache::MockDiskCache()
: open_count_(0), create_count_(0), fail_requests_(false),
- soft_failures_(false), double_create_check_(true) {
+ soft_failures_(false), double_create_check_(true),
+ fail_sparse_requests_(false) {
}
MockDiskCache::~MockDiskCache() {
@@ -411,6 +416,9 @@ int MockDiskCache::CreateEntry(const std::string& key,
if (soft_failures_)
new_entry->set_fail_requests();
+ if (fail_sparse_requests_)
+ new_entry->set_fail_sparse_requests();
+
if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
return net::OK;
« no previous file with comments | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698