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

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

Issue 542733002: Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix EnumerateAndMatchKeys 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
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 int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, 117 virtual scoped_ptr<Iterator> CreateIterator() OVERRIDE;
118 const net::CompletionCallback& callback) OVERRIDE;
119 virtual void EndEnumeration(void** iter) OVERRIDE;
120 virtual void GetStats( 118 virtual void GetStats(
121 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; 119 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
122 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 120 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
123 121
124 // Returns number of times a cache entry was successfully opened. 122 // Returns number of times a cache entry was successfully opened.
125 int open_count() const { return open_count_; } 123 int open_count() const { return open_count_; }
126 124
127 // Returns number of times a cache entry was successfully created. 125 // Returns number of times a cache entry was successfully created.
128 int create_count() const { return create_count_; } 126 int create_count() const { return create_count_; }
129 127
130 // Fail any subsequent CreateEntry and OpenEntry. 128 // Fail any subsequent CreateEntry and OpenEntry.
131 void set_fail_requests() { fail_requests_ = true; } 129 void set_fail_requests() { fail_requests_ = true; }
132 130
133 // Return entries that fail some of their requests. 131 // Return entries that fail some of their requests.
134 void set_soft_failures(bool value) { soft_failures_ = value; } 132 void set_soft_failures(bool value) { soft_failures_ = value; }
135 133
136 // Makes sure that CreateEntry is not called twice for a given key. 134 // Makes sure that CreateEntry is not called twice for a given key.
137 void set_double_create_check(bool value) { double_create_check_ = value; } 135 void set_double_create_check(bool value) { double_create_check_ = value; }
138 136
139 // Makes all requests for data ranges to fail as not implemented. 137 // Makes all requests for data ranges to fail as not implemented.
140 void set_fail_sparse_requests() { fail_sparse_requests_ = true; } 138 void set_fail_sparse_requests() { fail_sparse_requests_ = true; }
141 139
142 void ReleaseAll(); 140 void ReleaseAll();
143 141
144 private: 142 private:
145 typedef base::hash_map<std::string, MockDiskEntry*> EntryMap; 143 typedef base::hash_map<std::string, MockDiskEntry*> EntryMap;
144 class NotImplementedIterator;
146 145
147 void CallbackLater(const net::CompletionCallback& callback, int result); 146 void CallbackLater(const net::CompletionCallback& callback, int result);
148 147
149 EntryMap entries_; 148 EntryMap entries_;
150 int open_count_; 149 int open_count_;
151 int create_count_; 150 int create_count_;
152 bool fail_requests_; 151 bool fail_requests_;
153 bool soft_failures_; 152 bool soft_failures_;
154 bool double_create_check_; 153 bool double_create_check_;
155 bool fail_sparse_requests_; 154 bool fail_sparse_requests_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 private: 243 private:
245 int Result() { return fail_ ? net::ERR_FAILED : net::OK; } 244 int Result() { return fail_ ? net::ERR_FAILED : net::OK; }
246 245
247 scoped_ptr<disk_cache::Backend>* backend_; 246 scoped_ptr<disk_cache::Backend>* backend_;
248 net::CompletionCallback callback_; 247 net::CompletionCallback callback_;
249 bool block_; 248 bool block_;
250 bool fail_; 249 bool fail_;
251 }; 250 };
252 251
253 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_ 252 #endif // NET_HTTP_MOCK_HTTP_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698