OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 total_memory = total_memory * 2 / 100; | 69 total_memory = total_memory * 2 / 100; |
70 if (total_memory > kDefaultInMemoryCacheSize * 5) | 70 if (total_memory > kDefaultInMemoryCacheSize * 5) |
71 max_size_ = kDefaultInMemoryCacheSize * 5; | 71 max_size_ = kDefaultInMemoryCacheSize * 5; |
72 else | 72 else |
73 max_size_ = static_cast<int32>(total_memory); | 73 max_size_ = static_cast<int32>(total_memory); |
74 | 74 |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 bool MemBackendImpl::SetMaxSize(int max_bytes) { | 78 bool MemBackendImpl::SetMaxSize(int max_bytes) { |
79 COMPILE_ASSERT(sizeof(max_bytes) == sizeof(max_size_), unsupported_int_model); | 79 static_assert(sizeof(max_bytes) == sizeof(max_size_), |
| 80 "unsupported int model"); |
80 if (max_bytes < 0) | 81 if (max_bytes < 0) |
81 return false; | 82 return false; |
82 | 83 |
83 // Zero size means use the default. | 84 // Zero size means use the default. |
84 if (!max_bytes) | 85 if (!max_bytes) |
85 return true; | 86 return true; |
86 | 87 |
87 max_size_ = max_bytes; | 88 max_size_ = max_bytes; |
88 return true; | 89 return true; |
89 } | 90 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 if (current_size_ > max_size_) | 337 if (current_size_ > max_size_) |
337 TrimCache(false); | 338 TrimCache(false); |
338 } | 339 } |
339 | 340 |
340 void MemBackendImpl::SubstractStorageSize(int32 bytes) { | 341 void MemBackendImpl::SubstractStorageSize(int32 bytes) { |
341 current_size_ -= bytes; | 342 current_size_ -= bytes; |
342 DCHECK_GE(current_size_, 0); | 343 DCHECK_GE(current_size_, 0); |
343 } | 344 } |
344 | 345 |
345 } // namespace disk_cache | 346 } // namespace disk_cache |
OLD | NEW |