OLD | NEW |
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 scoped_ptr<Iterator> CreateIterator() override; | 130 scoped_ptr<Iterator> CreateIterator() override; |
131 void GetStats(base::StringPairs* stats) override; | 131 void GetStats(base::StringPairs* stats) override; |
132 void OnExternalCacheHit(const std::string& key) override; | 132 void OnExternalCacheHit(const std::string& key) override; |
133 | 133 |
134 // Returns number of times a cache entry was successfully opened. | 134 // Returns number of times a cache entry was successfully opened. |
135 int open_count() const { return open_count_; } | 135 int open_count() const { return open_count_; } |
136 | 136 |
137 // Returns number of times a cache entry was successfully created. | 137 // Returns number of times a cache entry was successfully created. |
138 int create_count() const { return create_count_; } | 138 int create_count() const { return create_count_; } |
139 | 139 |
| 140 // Resets open_count() and create_count(). Calling this is recommended to |
| 141 // reset the counts after test setup. |
| 142 void ResetCounts(); |
| 143 |
140 // Fail any subsequent CreateEntry and OpenEntry. | 144 // Fail any subsequent CreateEntry and OpenEntry. |
141 void set_fail_requests() { fail_requests_ = true; } | 145 void set_fail_requests() { fail_requests_ = true; } |
142 | 146 |
143 // Return entries that fail some of their requests. | 147 // Return entries that fail some of their requests. |
144 void set_soft_failures(bool value) { soft_failures_ = value; } | 148 void set_soft_failures(bool value) { soft_failures_ = value; } |
145 | 149 |
146 // Makes sure that CreateEntry is not called twice for a given key. | 150 // Makes sure that CreateEntry is not called twice for a given key. |
147 void set_double_create_check(bool value) { double_create_check_ = value; } | 151 void set_double_create_check(bool value) { double_create_check_ = value; } |
148 | 152 |
149 // Makes all requests for data ranges to fail as not implemented. | 153 // Makes all requests for data ranges to fail as not implemented. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 267 |
264 scoped_ptr<disk_cache::Backend>* backend_; | 268 scoped_ptr<disk_cache::Backend>* backend_; |
265 CompletionCallback callback_; | 269 CompletionCallback callback_; |
266 bool block_; | 270 bool block_; |
267 bool fail_; | 271 bool fail_; |
268 }; | 272 }; |
269 | 273 |
270 } // namespace net | 274 } // namespace net |
271 | 275 |
272 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ | 276 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ |
OLD | NEW |