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

Unified Diff: net/http/mock_http_cache.h

Issue 2970133002: DoomPartialEntry should not attempt to doom an already doomed entry. (Closed)
Patch Set: GetDiskEntryRef added and doomed_entries_ removed Created 3 years, 5 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_unittest.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/mock_http_cache.h
diff --git a/net/http/mock_http_cache.h b/net/http/mock_http_cache.h
index d568c64db9a5d206a04973c2b82d37d289f97f30..ac4ba72b5b860a28e93ce89885288260895f6ed3 100644
--- a/net/http/mock_http_cache.h
+++ b/net/http/mock_http_cache.h
@@ -27,6 +27,12 @@ namespace net {
class MockDiskEntry : public disk_cache::Entry,
public base::RefCounted<MockDiskEntry> {
public:
+ enum DeferOp {
+ DEFER_NONE,
+ DEFER_CREATE,
+ DEFER_READ,
+ };
+
explicit MockDiskEntry(const std::string& key);
bool is_doomed() const { return doomed_; }
@@ -74,6 +80,12 @@ class MockDiskEntry : public disk_cache::Entry,
// again or all subsequent tests will fail.
static void IgnoreCallbacks(bool value);
+ void SetDefer(DeferOp defer_op) { defer_op_ = defer_op; }
+
+ // Resumes deferred cache operation by posting |resume_callback_| with
+ // |resume_return_code_|. Returns ERR_IO_PENDING.
+ int ResumeCacheOperation();
+
private:
friend class base::RefCounted<MockDiskEntry>;
struct CallbackInfo;
@@ -106,6 +118,12 @@ class MockDiskEntry : public disk_cache::Entry,
bool busy_;
bool delayed_;
bool cancel_;
+
+ // Used for pause and restart.
+ DeferOp defer_op_;
+ CompletionCallback resume_callback_;
+ int resume_return_code_;
+
static bool ignore_callbacks_;
};
@@ -161,8 +179,21 @@ class MockDiskCache : public disk_cache::Backend {
void ReleaseAll();
+ // Returns true if a doomed entry exists with this key.
bool IsDiskEntryDoomed(const std::string& key);
+ // Defers invoking the callback for the given operation.
+ void SetDefer(MockDiskEntry::DeferOp defer_op) { defer_op_ = defer_op; }
+
+ // Resume deferred cache operation by posting |resume_callback_| with
+ // |resume_return_code_|. Returns ERR_IO_PENDING.
+ int ResumeCacheOperation();
jkarlin 2017/07/13 17:27:24 It's unclear when you should get the entry and cal
shivanisha 2017/07/13 18:53:19 Renaming this ResumeDiskEntryOperation to let it b
+
+ // Returns a reference to the disk entry with the given |key|. Also adds a
+ // reference for that entry, so the test should invoke Close() on it to
+ // release the reference count.
+ MockDiskEntry* GetDiskEntryRef(const std::string& key);
jkarlin 2017/07/13 17:27:25 scoped_refptr<MockDiskEntry> GetDiskEntryRef(const
shivanisha 2017/07/13 18:53:45 done
+
private:
using EntryMap = std::unordered_map<std::string, MockDiskEntry*>;
class NotImplementedIterator;
@@ -177,6 +208,11 @@ class MockDiskCache : public disk_cache::Backend {
bool soft_failures_;
bool double_create_check_;
bool fail_sparse_requests_;
+
+ // Used for pause and restart.
+ MockDiskEntry::DeferOp defer_op_;
+ CompletionCallback resume_callback_;
+ int resume_return_code_;
};
class MockBackendFactory : public HttpCache::BackendFactory {
@@ -244,7 +280,6 @@ class MockHttpCache {
static void SetTestMode(int test_mode);
// Functions to test the state of ActiveEntry.
-
bool IsWriterPresent(const std::string& key);
bool IsHeadersTransactionPresent(const std::string& key);
int GetCountReaders(const std::string& key);
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698