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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 MockDiskCache(); | 95 MockDiskCache(); |
96 virtual ~MockDiskCache(); | 96 virtual ~MockDiskCache(); |
97 | 97 |
98 virtual int32 GetEntryCount() const OVERRIDE; | 98 virtual int32 GetEntryCount() const OVERRIDE; |
99 virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry, | 99 virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry, |
100 net::OldCompletionCallback* callback) OVERRIDE; | 100 net::OldCompletionCallback* callback) OVERRIDE; |
101 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, | 101 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, |
102 net::OldCompletionCallback* callback) OVERRIDE; | 102 net::OldCompletionCallback* callback) OVERRIDE; |
103 virtual int DoomEntry(const std::string& key, | 103 virtual int DoomEntry(const std::string& key, |
104 net::OldCompletionCallback* callback) OVERRIDE; | 104 net::OldCompletionCallback* callback) OVERRIDE; |
105 virtual int DoomAllEntries(net::OldCompletionCallback* callback) OVERRIDE; | |
106 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE; | 105 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE; |
107 virtual int DoomEntriesBetween(const base::Time initial_time, | |
108 const base::Time end_time, | |
109 net::OldCompletionCallback* callback) OVERRIDE; | |
110 virtual int DoomEntriesBetween( | 106 virtual int DoomEntriesBetween( |
111 const base::Time initial_time, | 107 const base::Time initial_time, |
112 const base::Time end_time, | 108 const base::Time end_time, |
113 const net::CompletionCallback& callback) OVERRIDE; | 109 const net::CompletionCallback& callback) OVERRIDE; |
114 virtual int DoomEntriesSince(const base::Time initial_time, | 110 virtual int DoomEntriesSince(const base::Time initial_time, |
115 net::OldCompletionCallback* callback) OVERRIDE; | 111 net::OldCompletionCallback* callback) OVERRIDE; |
116 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, | 112 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, |
117 net::OldCompletionCallback* callback) OVERRIDE; | |
118 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, | |
119 const net::CompletionCallback& callback) OVERRIDE; | 113 const net::CompletionCallback& callback) OVERRIDE; |
120 virtual void EndEnumeration(void** iter) OVERRIDE; | 114 virtual void EndEnumeration(void** iter) OVERRIDE; |
121 virtual void GetStats( | 115 virtual void GetStats( |
122 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; | 116 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; |
123 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; | 117 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; |
124 | 118 |
125 // Returns number of times a cache entry was successfully opened. | 119 // Returns number of times a cache entry was successfully opened. |
126 int open_count() const { return open_count_; } | 120 int open_count() const { return open_count_; } |
127 | 121 |
128 // Returns number of times a cache entry was successfully created. | 122 // Returns number of times a cache entry was successfully created. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 private: | 229 private: |
236 int Result() { return fail_ ? net::ERR_FAILED : net::OK; } | 230 int Result() { return fail_ ? net::ERR_FAILED : net::OK; } |
237 | 231 |
238 disk_cache::Backend** backend_; | 232 disk_cache::Backend** backend_; |
239 net::OldCompletionCallback* callback_; | 233 net::OldCompletionCallback* callback_; |
240 bool block_; | 234 bool block_; |
241 bool fail_; | 235 bool fail_; |
242 }; | 236 }; |
243 | 237 |
244 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ | 238 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ |
OLD | NEW |