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

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

Issue 2661333002: Track SimpleCache memory usage in net/ MemoryDumpProvider (Closed)
Patch Set: Pure rebase before addressing comments Created 3 years, 10 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 <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return std::unique_ptr<Backend::Iterator>( 276 return std::unique_ptr<Backend::Iterator>(
277 new MemIterator(weak_factory_.GetWeakPtr())); 277 new MemIterator(weak_factory_.GetWeakPtr()));
278 } 278 }
279 279
280 void MemBackendImpl::OnExternalCacheHit(const std::string& key) { 280 void MemBackendImpl::OnExternalCacheHit(const std::string& key) {
281 EntryMap::iterator it = entries_.find(key); 281 EntryMap::iterator it = entries_.find(key);
282 if (it != entries_.end()) 282 if (it != entries_.end())
283 it->second->UpdateStateOnUse(MemEntryImpl::ENTRY_WAS_NOT_MODIFIED); 283 it->second->UpdateStateOnUse(MemEntryImpl::ENTRY_WAS_NOT_MODIFIED);
284 } 284 }
285 285
286 size_t MemBackendImpl::EstimateMemoryUsage() const {
287 // TODO(xunjieli): Implement this. crbug.com/669108.
288 return 0;
289 }
290
286 void MemBackendImpl::EvictIfNeeded() { 291 void MemBackendImpl::EvictIfNeeded() {
287 if (current_size_ <= max_size_) 292 if (current_size_ <= max_size_)
288 return; 293 return;
289 294
290 int target_size = std::max(0, max_size_ - kDefaultEvictionSize); 295 int target_size = std::max(0, max_size_ - kDefaultEvictionSize);
291 296
292 base::LinkNode<MemEntryImpl>* entry = lru_list_.head(); 297 base::LinkNode<MemEntryImpl>* entry = lru_list_.head();
293 while (current_size_ > target_size && entry != lru_list_.end()) { 298 while (current_size_ > target_size && entry != lru_list_.end()) {
294 MemEntryImpl* to_doom = entry->value(); 299 MemEntryImpl* to_doom = entry->value();
295 entry = entry->next(); 300 entry = entry->next();
296 if (!to_doom->InUse()) 301 if (!to_doom->InUse())
297 to_doom->Doom(); 302 to_doom->Doom();
298 } 303 }
299 } 304 }
300 305
301 } // namespace disk_cache 306 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698