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

Side by Side Diff: net/disk_cache/memory/mem_backend_impl.cc

Issue 542733002: Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: narrowest, remove unused function 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/disk_cache/memory/mem_backend_impl.h" 5 #include "net/disk_cache/memory/mem_backend_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/disk_cache/cache_util.h" 10 #include "net/disk_cache/cache_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 int MemBackendImpl::DoomEntriesSince(const base::Time initial_time, 175 int MemBackendImpl::DoomEntriesSince(const base::Time initial_time,
176 const CompletionCallback& callback) { 176 const CompletionCallback& callback) {
177 if (DoomEntriesSince(initial_time)) 177 if (DoomEntriesSince(initial_time))
178 return net::OK; 178 return net::OK;
179 179
180 return net::ERR_FAILED; 180 return net::ERR_FAILED;
181 } 181 }
182 182
183 int MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry, 183 int MemBackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry,
184 const CompletionCallback& callback) { 184 const CompletionCallback& callback) {
185 if (OpenNextEntry(iter, next_entry)) 185 if (OpenNextEntry(iter, next_entry))
186 return net::OK; 186 return net::OK;
187 187
188 return net::ERR_FAILED; 188 return net::ERR_FAILED;
189 } 189 }
190 190
191 void MemBackendImpl::EndEnumeration(void** iter) {
192 *iter = NULL;
193 }
194
195 void MemBackendImpl::OnExternalCacheHit(const std::string& key) { 191 void MemBackendImpl::OnExternalCacheHit(const std::string& key) {
196 EntryMap::iterator it = entries_.find(key); 192 EntryMap::iterator it = entries_.find(key);
197 if (it != entries_.end()) { 193 if (it != entries_.end()) {
198 UpdateRank(it->second); 194 UpdateRank(it->second);
199 } 195 }
200 } 196 }
201 197
202 bool MemBackendImpl::OpenEntry(const std::string& key, Entry** entry) { 198 bool MemBackendImpl::OpenEntry(const std::string& key, Entry** entry) {
203 EntryMap::iterator it = entries_.find(key); 199 EntryMap::iterator it = entries_.find(key);
204 if (it == entries_.end()) 200 if (it == entries_.end())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Get the entry in the front. 276 // Get the entry in the front.
281 Entry* entry = rankings_.GetNext(NULL); 277 Entry* entry = rankings_.GetNext(NULL);
282 278
283 // Break the loop when there are no more entries or the entry is too old. 279 // Break the loop when there are no more entries or the entry is too old.
284 if (!entry || entry->GetLastUsed() < initial_time) 280 if (!entry || entry->GetLastUsed() < initial_time)
285 return true; 281 return true;
286 entry->Doom(); 282 entry->Doom();
287 } 283 }
288 } 284 }
289 285
290 bool MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry) { 286 bool MemBackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry) {
291 MemEntryImpl* current = reinterpret_cast<MemEntryImpl*>(*iter); 287 class State : public EnumerationState {
292 MemEntryImpl* node = rankings_.GetNext(current); 288 public:
289 State() : current_(NULL) {}
290
291 MemEntryImpl* current() { return current_; }
292 void set_current(MemEntryImpl* current) { current_ = current; }
293
294 private:
295 MemEntryImpl* current_;
296 };
297 if (!*iter)
298 iter->reset(new State());
299 State* state = static_cast<State*>(iter->get());
300
301 MemEntryImpl* node = rankings_.GetNext(state->current());
293 // We should never return a child entry so iterate until we hit a parent 302 // We should never return a child entry so iterate until we hit a parent
294 // entry. 303 // entry.
295 while (node && node->type() != MemEntryImpl::kParentEntry) { 304 while (node && node->type() != MemEntryImpl::kParentEntry) {
296 node = rankings_.GetNext(node); 305 node = rankings_.GetNext(node);
297 } 306 }
298 *next_entry = node; 307 *next_entry = node;
299 *iter = node; 308 state->set_current(node);
300 309
301 if (node) 310 if (node)
302 node->Open(); 311 node->Open();
303 312
304 return NULL != node; 313 return NULL != node;
305 } 314 }
306 315
307 void MemBackendImpl::TrimCache(bool empty) { 316 void MemBackendImpl::TrimCache(bool empty) {
308 MemEntryImpl* next = rankings_.GetPrev(NULL); 317 MemEntryImpl* next = rankings_.GetPrev(NULL);
309 if (!next) 318 if (!next)
(...skipping 18 matching lines...) Expand all
328 if (current_size_ > max_size_) 337 if (current_size_ > max_size_)
329 TrimCache(false); 338 TrimCache(false);
330 } 339 }
331 340
332 void MemBackendImpl::SubstractStorageSize(int32 bytes) { 341 void MemBackendImpl::SubstractStorageSize(int32 bytes) {
333 current_size_ -= bytes; 342 current_size_ -= bytes;
334 DCHECK_GE(current_size_, 0); 343 DCHECK_GE(current_size_, 0);
335 } 344 }
336 345
337 } // namespace disk_cache 346 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698