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

Unified Diff: net/http/http_cache_unittest.cc

Issue 201065: Http cache: Convert data writes from sysnchronous to asynchronous.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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/http_cache.cc ('k') | net/http/http_transaction_unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
===================================================================
--- net/http/http_cache_unittest.cc (revision 25867)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -126,7 +126,12 @@
data_[index].resize(offset + buf_len);
if (buf_len)
memcpy(&data_[index][offset], buf->data(), buf_len);
- return buf_len;
+
+ if (!callback || (test_mode_ & TEST_MODE_SYNC_CACHE_WRITE))
+ return buf_len;
+
+ CallbackLater(callback, buf_len);
+ return net::ERR_IO_PENDING;
}
virtual int ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len,
@@ -177,7 +182,11 @@
data_[1].resize(real_offset + buf_len);
memcpy(&data_[1][real_offset], buf->data(), buf_len);
- return buf_len;
+ if (!completion_callback || (test_mode_ & TEST_MODE_SYNC_CACHE_WRITE))
+ return buf_len;
+
+ CallbackLater(completion_callback, buf_len);
+ return net::ERR_IO_PENDING;
}
virtual int GetAvailableRange(int64 offset, int len, int64* start) {
@@ -1969,7 +1978,8 @@
MockTransaction transaction(kRangeGET_TransactionOK);
transaction.test_mode = TEST_MODE_SYNC_CACHE_START |
- TEST_MODE_SYNC_CACHE_READ;
+ TEST_MODE_SYNC_CACHE_READ |
+ TEST_MODE_SYNC_CACHE_WRITE;
AddMockTransaction(&transaction);
// Write to the cache (70-79).
@@ -2534,7 +2544,8 @@
ScopedMockTransaction transaction(kSimpleGET_Transaction);
transaction.test_mode |= (TEST_MODE_SYNC_CACHE_START |
- TEST_MODE_SYNC_CACHE_READ);
+ TEST_MODE_SYNC_CACHE_READ |
+ TEST_MODE_SYNC_CACHE_WRITE);
MockHttpRequest r1(transaction),
r2(transaction),
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_transaction_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698