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

Side by Side Diff: net/http/mock_http_cache.h

Issue 585833002: Revert of Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is a mock of the http cache and related testing classes. To be fair, it 5 // This is a mock of the http cache and related testing classes. To be fair, it
6 // is not really a mock http cache given that it uses the real implementation of 6 // is not really a mock http cache given that it uses the real implementation of
7 // the http cache, but it has fake implementations of all required components, 7 // the http cache, but it has fake implementations of all required components,
8 // so it is useful for unit tests at the http layer. 8 // so it is useful for unit tests at the http layer.
9 9
10 #ifndef NET_HTTP_MOCK_HTTP_CACHE_H_ 10 #ifndef NET_HTTP_MOCK_HTTP_CACHE_H_
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 virtual int DoomEntry(const std::string& key, 107 virtual int DoomEntry(const std::string& key,
108 const net::CompletionCallback& callback) OVERRIDE; 108 const net::CompletionCallback& callback) OVERRIDE;
109 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE; 109 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE;
110 virtual int DoomEntriesBetween( 110 virtual int DoomEntriesBetween(
111 base::Time initial_time, 111 base::Time initial_time,
112 base::Time end_time, 112 base::Time end_time,
113 const net::CompletionCallback& callback) OVERRIDE; 113 const net::CompletionCallback& callback) OVERRIDE;
114 virtual int DoomEntriesSince( 114 virtual int DoomEntriesSince(
115 base::Time initial_time, 115 base::Time initial_time,
116 const net::CompletionCallback& callback) OVERRIDE; 116 const net::CompletionCallback& callback) OVERRIDE;
117 virtual scoped_ptr<Iterator> CreateIterator() OVERRIDE; 117 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry,
118 const net::CompletionCallback& callback) OVERRIDE;
119 virtual void EndEnumeration(void** iter) OVERRIDE;
118 virtual void GetStats( 120 virtual void GetStats(
119 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; 121 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
120 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 122 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
121 123
122 // Returns number of times a cache entry was successfully opened. 124 // Returns number of times a cache entry was successfully opened.
123 int open_count() const { return open_count_; } 125 int open_count() const { return open_count_; }
124 126
125 // Returns number of times a cache entry was successfully created. 127 // Returns number of times a cache entry was successfully created.
126 int create_count() const { return create_count_; } 128 int create_count() const { return create_count_; }
127 129
128 // Fail any subsequent CreateEntry and OpenEntry. 130 // Fail any subsequent CreateEntry and OpenEntry.
129 void set_fail_requests() { fail_requests_ = true; } 131 void set_fail_requests() { fail_requests_ = true; }
130 132
131 // Return entries that fail some of their requests. 133 // Return entries that fail some of their requests.
132 void set_soft_failures(bool value) { soft_failures_ = value; } 134 void set_soft_failures(bool value) { soft_failures_ = value; }
133 135
134 // Makes sure that CreateEntry is not called twice for a given key. 136 // Makes sure that CreateEntry is not called twice for a given key.
135 void set_double_create_check(bool value) { double_create_check_ = value; } 137 void set_double_create_check(bool value) { double_create_check_ = value; }
136 138
137 // Makes all requests for data ranges to fail as not implemented. 139 // Makes all requests for data ranges to fail as not implemented.
138 void set_fail_sparse_requests() { fail_sparse_requests_ = true; } 140 void set_fail_sparse_requests() { fail_sparse_requests_ = true; }
139 141
140 void ReleaseAll(); 142 void ReleaseAll();
141 143
142 private: 144 private:
143 typedef base::hash_map<std::string, MockDiskEntry*> EntryMap; 145 typedef base::hash_map<std::string, MockDiskEntry*> EntryMap;
144 class NotImplementedIterator;
145 146
146 void CallbackLater(const net::CompletionCallback& callback, int result); 147 void CallbackLater(const net::CompletionCallback& callback, int result);
147 148
148 EntryMap entries_; 149 EntryMap entries_;
149 int open_count_; 150 int open_count_;
150 int create_count_; 151 int create_count_;
151 bool fail_requests_; 152 bool fail_requests_;
152 bool soft_failures_; 153 bool soft_failures_;
153 bool double_create_check_; 154 bool double_create_check_;
154 bool fail_sparse_requests_; 155 bool fail_sparse_requests_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 private: 244 private:
244 int Result() { return fail_ ? net::ERR_FAILED : net::OK; } 245 int Result() { return fail_ ? net::ERR_FAILED : net::OK; }
245 246
246 scoped_ptr<disk_cache::Backend>* backend_; 247 scoped_ptr<disk_cache::Backend>* backend_;
247 net::CompletionCallback callback_; 248 net::CompletionCallback callback_;
248 bool block_; 249 bool block_;
249 bool fail_; 250 bool fail_;
250 }; 251 };
251 252
252 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ 253 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698