| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/mem_backend_impl.h" | 5 #include "net/disk_cache/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // reached on systemd with more than 2.5 GB of RAM. | 55 // reached on systemd with more than 2.5 GB of RAM. |
| 56 total_memory = total_memory * 2 / 100; | 56 total_memory = total_memory * 2 / 100; |
| 57 if (total_memory > kDefaultCacheSize * 5) | 57 if (total_memory > kDefaultCacheSize * 5) |
| 58 max_size_ = kDefaultCacheSize * 5; | 58 max_size_ = kDefaultCacheSize * 5; |
| 59 else | 59 else |
| 60 max_size_ = static_cast<int32>(total_memory); | 60 max_size_ = static_cast<int32>(total_memory); |
| 61 | 61 |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 MemBackendImpl::MemBackendImpl() : max_size_(0), current_size_(0) {} |
| 66 |
| 65 MemBackendImpl::~MemBackendImpl() { | 67 MemBackendImpl::~MemBackendImpl() { |
| 66 EntryMap::iterator it = entries_.begin(); | 68 EntryMap::iterator it = entries_.begin(); |
| 67 while (it != entries_.end()) { | 69 while (it != entries_.end()) { |
| 68 it->second->Doom(); | 70 it->second->Doom(); |
| 69 it = entries_.begin(); | 71 it = entries_.begin(); |
| 70 } | 72 } |
| 71 DCHECK(!current_size_); | 73 DCHECK(!current_size_); |
| 72 } | 74 } |
| 73 | 75 |
| 74 bool MemBackendImpl::SetMaxSize(int max_bytes) { | 76 bool MemBackendImpl::SetMaxSize(int max_bytes) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 310 |
| 309 void MemBackendImpl::InsertIntoRankingList(MemEntryImpl* entry) { | 311 void MemBackendImpl::InsertIntoRankingList(MemEntryImpl* entry) { |
| 310 rankings_.Insert(entry); | 312 rankings_.Insert(entry); |
| 311 } | 313 } |
| 312 | 314 |
| 313 void MemBackendImpl::RemoveFromRankingList(MemEntryImpl* entry) { | 315 void MemBackendImpl::RemoveFromRankingList(MemEntryImpl* entry) { |
| 314 rankings_.Remove(entry); | 316 rankings_.Remove(entry); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace disk_cache | 319 } // namespace disk_cache |
| OLD | NEW |