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

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

Issue 2847653002: Revert of HttpCache::Transaction layer allowing parallel validation (Closed)
Patch Set: Created 3 years, 7 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/http/http_transaction_test_util.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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void set_soft_failures(bool value) { soft_failures_ = value; } 151 void set_soft_failures(bool value) { soft_failures_ = value; }
152 152
153 // Makes sure that CreateEntry is not called twice for a given key. 153 // Makes sure that CreateEntry is not called twice for a given key.
154 void set_double_create_check(bool value) { double_create_check_ = value; } 154 void set_double_create_check(bool value) { double_create_check_ = value; }
155 155
156 // Makes all requests for data ranges to fail as not implemented. 156 // Makes all requests for data ranges to fail as not implemented.
157 void set_fail_sparse_requests() { fail_sparse_requests_ = true; } 157 void set_fail_sparse_requests() { fail_sparse_requests_ = true; }
158 158
159 void ReleaseAll(); 159 void ReleaseAll();
160 160
161 bool IsDiskEntryDoomed(const std::string& key);
162
163 private: 161 private:
164 using EntryMap = std::unordered_map<std::string, MockDiskEntry*>; 162 using EntryMap = std::unordered_map<std::string, MockDiskEntry*>;
165 class NotImplementedIterator; 163 class NotImplementedIterator;
166 164
167 void CallbackLater(const CompletionCallback& callback, int result); 165 void CallbackLater(const CompletionCallback& callback, int result);
168 166
169 EntryMap entries_; 167 EntryMap entries_;
170 int open_count_; 168 int open_count_;
171 int create_count_; 169 int create_count_;
172 bool fail_requests_; 170 bool fail_requests_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 disk_cache::Entry** entry, 227 disk_cache::Entry** entry,
230 NetLog* net_log); 228 NetLog* net_log);
231 229
232 // Returns the test mode after considering the global override. 230 // Returns the test mode after considering the global override.
233 static int GetTestMode(int test_mode); 231 static int GetTestMode(int test_mode);
234 232
235 // Overrides the test mode for a given operation. Remember to reset it after 233 // Overrides the test mode for a given operation. Remember to reset it after
236 // the test! (by setting test_mode to zero). 234 // the test! (by setting test_mode to zero).
237 static void SetTestMode(int test_mode); 235 static void SetTestMode(int test_mode);
238 236
239 // Functions to test the state of ActiveEntry.
240
241 bool IsWriterPresent(const std::string& key);
242 bool IsHeadersTransactionPresent(const std::string& key);
243 int GetCountReaders(const std::string& key);
244 int GetCountAddToEntryQueue(const std::string& key);
245 int GetCountDoneHeadersQueue(const std::string& key);
246
247 private: 237 private:
248 HttpCache http_cache_; 238 HttpCache http_cache_;
249 }; 239 };
250 240
251 // This version of the disk cache doesn't invoke CreateEntry callbacks. 241 // This version of the disk cache doesn't invoke CreateEntry callbacks.
252 class MockDiskCacheNoCB : public MockDiskCache { 242 class MockDiskCacheNoCB : public MockDiskCache {
253 int CreateEntry(const std::string& key, 243 int CreateEntry(const std::string& key,
254 disk_cache::Entry** entry, 244 disk_cache::Entry** entry,
255 const CompletionCallback& callback) override; 245 const CompletionCallback& callback) override;
256 }; 246 };
(...skipping 29 matching lines...) Expand all
286 276
287 std::unique_ptr<disk_cache::Backend>* backend_; 277 std::unique_ptr<disk_cache::Backend>* backend_;
288 CompletionCallback callback_; 278 CompletionCallback callback_;
289 bool block_; 279 bool block_;
290 bool fail_; 280 bool fail_;
291 }; 281 };
292 282
293 } // namespace net 283 } // namespace net
294 284
295 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ 285 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_
OLDNEW
« no previous file with comments | « net/http/http_transaction_test_util.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698