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/cache_util.h" | 5 #include "net/disk_cache/cache_util.h" |
6 | 6 |
7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 FROM_HERE, base::Bind(&CleanupCallback, path, name_str), true); | 138 FROM_HERE, base::Bind(&CleanupCallback, path, name_str), true); |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 // Returns the preferred maximum number of bytes for the cache given the | 142 // Returns the preferred maximum number of bytes for the cache given the |
143 // number of available bytes. | 143 // number of available bytes. |
144 int PreferredCacheSize(int64 available) { | 144 int PreferredCacheSize(int64 available) { |
145 if (available < 0) | 145 if (available < 0) |
146 return kDefaultCacheSize; | 146 return kDefaultCacheSize; |
147 | 147 |
148 int64 max_size = PreferredCacheSizeInternal(available); | |
149 | |
150 // Limit cache size to somewhat less than kint32max to avoid potential | 148 // Limit cache size to somewhat less than kint32max to avoid potential |
151 // integer overflows in cache backend implementations. | 149 // integer overflows in cache backend implementations. |
152 DCHECK(kDefaultCacheSize * 4 < kint32max); | 150 DCHECK_LT(kDefaultCacheSize * 4, kint32max); |
153 if (max_size > kDefaultCacheSize * 4) | 151 return static_cast<int32>(std::min( |
154 max_size = kDefaultCacheSize * 4; | 152 PreferredCacheSizeInternal(available), |
155 | 153 static_cast<int64>(kDefaultCacheSize * 4))); |
156 return implicit_cast<int32>(max_size); | |
Peter Kasting
2014/10/08 19:21:56
This needs a static_cast, not an implicit_cast, to
rvargas (doing something else)
2014/10/08 20:01:14
Certainly!
| |
157 } | 154 } |
158 | 155 |
159 } // namespace disk_cache | 156 } // namespace disk_cache |
OLD | NEW |