| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/sys_info.h" | 7 #include "base/sys_info.h" |
| 8 #include "net/disk_cache/cache_util.h" | 8 #include "net/disk_cache/cache_util.h" |
| 9 #include "net/disk_cache/mem_entry_impl.h" | 9 #include "net/disk_cache/mem_entry_impl.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 // ------------------------------------------------------------------------ | 38 // ------------------------------------------------------------------------ |
| 39 | 39 |
| 40 bool MemBackendImpl::Init() { | 40 bool MemBackendImpl::Init() { |
| 41 if (max_size_) | 41 if (max_size_) |
| 42 return true; | 42 return true; |
| 43 | 43 |
| 44 int64 total_memory = base::SysInfo::AmountOfPhysicalMemory(); | 44 int64 total_memory = base::SysInfo::AmountOfPhysicalMemory(); |
| 45 | 45 |
| 46 if (total_memory < 0) { | 46 if (total_memory <= 0) { |
| 47 max_size_ = kDefaultCacheSize; | 47 max_size_ = kDefaultCacheSize; |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // We want to use up to 2% of the computer's memory, with a limit of 50 MB, | 51 // We want to use up to 2% of the computer's memory, with a limit of 50 MB, |
| 52 // reached on systemd with more than 2.5 GB of RAM. | 52 // reached on systemd with more than 2.5 GB of RAM. |
| 53 total_memory = total_memory * 2 / 100; | 53 total_memory = total_memory * 2 / 100; |
| 54 if (total_memory > kDefaultCacheSize * 5) | 54 if (total_memory > kDefaultCacheSize * 5) |
| 55 max_size_ = kDefaultCacheSize * 5; | 55 max_size_ = kDefaultCacheSize * 5; |
| 56 else | 56 else |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void MemBackendImpl::UpdateRank(MemEntryImpl* node) { | 244 void MemBackendImpl::UpdateRank(MemEntryImpl* node) { |
| 245 rankings_.UpdateRank(node); | 245 rankings_.UpdateRank(node); |
| 246 } | 246 } |
| 247 | 247 |
| 248 int MemBackendImpl::MaxFileSize() const { | 248 int MemBackendImpl::MaxFileSize() const { |
| 249 return max_size_ / 8; | 249 return max_size_ / 8; |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace disk_cache | 252 } // namespace disk_cache |
| 253 | 253 |
| OLD | NEW |