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

Side by Side Diff: net/disk_cache/cache_util.cc

Issue 2854243003: Use constexpr TaskTraits constructor in net. (Closed)
Patch Set: Created 3 years, 7 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/blockfile/file_ios.cc ('k') | net/dns/address_sorter_win.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/cache_util.h" 5 #include "net/disk_cache/cache_util.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 LOG(ERROR) << "Unable to get another cache folder"; 129 LOG(ERROR) << "Unable to get another cache folder";
130 return false; 130 return false;
131 } 131 }
132 132
133 if (!disk_cache::MoveCache(full_path, to_delete)) { 133 if (!disk_cache::MoveCache(full_path, to_delete)) {
134 LOG(ERROR) << "Unable to move cache folder " << full_path.value() << " to " 134 LOG(ERROR) << "Unable to move cache folder " << full_path.value() << " to "
135 << to_delete.value(); 135 << to_delete.value();
136 return false; 136 return false;
137 } 137 }
138 138
139 base::PostTaskWithTraits( 139 base::PostTaskWithTraits(FROM_HERE,
140 FROM_HERE, base::TaskTraits() 140 {base::MayBlock(), base::TaskPriority::BACKGROUND,
141 .MayBlock() 141 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
142 .WithPriority(base::TaskPriority::BACKGROUND) 142 base::Bind(&CleanupCallback, path, name_str));
143 .WithShutdownBehavior(
144 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
145 base::Bind(&CleanupCallback, path, name_str));
146 return true; 143 return true;
147 } 144 }
148 145
149 // Returns the preferred maximum number of bytes for the cache given the 146 // Returns the preferred maximum number of bytes for the cache given the
150 // number of available bytes. 147 // number of available bytes.
151 int PreferredCacheSize(int64_t available) { 148 int PreferredCacheSize(int64_t available) {
152 if (available < 0) 149 if (available < 0)
153 return kDefaultCacheSize; 150 return kDefaultCacheSize;
154 151
155 // Limit cache size to somewhat less than kint32max to avoid potential 152 // Limit cache size to somewhat less than kint32max to avoid potential
156 // integer overflows in cache backend implementations. 153 // integer overflows in cache backend implementations.
157 DCHECK_LT(kDefaultCacheSize * 4, std::numeric_limits<int32_t>::max()); 154 DCHECK_LT(kDefaultCacheSize * 4, std::numeric_limits<int32_t>::max());
158 return static_cast<int32_t>( 155 return static_cast<int32_t>(
159 std::min(PreferredCacheSizeInternal(available), 156 std::min(PreferredCacheSizeInternal(available),
160 static_cast<int64_t>(kDefaultCacheSize * 4))); 157 static_cast<int64_t>(kDefaultCacheSize * 4)));
161 } 158 }
162 159
163 } // namespace disk_cache 160 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/file_ios.cc ('k') | net/dns/address_sorter_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698