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

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

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698