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

Side by Side Diff: net/disk_cache/simple/simple_backend_impl.cc

Issue 509993002: Downgrade all CHECKs to DCHECKs in SimpleCache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/simple/simple_backend_impl.h" 5 #include "net/disk_cache/simple/simple_backend_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <functional> 9 #include <functional>
10 10
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 int SimpleBackendImpl::GetMaxFileSize() const { 250 int SimpleBackendImpl::GetMaxFileSize() const {
251 return index_->max_size() / kMaxFileRatio; 251 return index_->max_size() / kMaxFileRatio;
252 } 252 }
253 253
254 void SimpleBackendImpl::OnDeactivated(const SimpleEntryImpl* entry) { 254 void SimpleBackendImpl::OnDeactivated(const SimpleEntryImpl* entry) {
255 active_entries_.erase(entry->entry_hash()); 255 active_entries_.erase(entry->entry_hash());
256 } 256 }
257 257
258 void SimpleBackendImpl::OnDoomStart(uint64 entry_hash) { 258 void SimpleBackendImpl::OnDoomStart(uint64 entry_hash) {
259 // TODO(ttuttle): Revert to DCHECK once http://crbug.com/317138 is fixed. 259 DCHECK_EQ(0u, entries_pending_doom_.count(entry_hash));
260 CHECK_EQ(0u, entries_pending_doom_.count(entry_hash));
261 entries_pending_doom_.insert( 260 entries_pending_doom_.insert(
262 std::make_pair(entry_hash, std::vector<Closure>())); 261 std::make_pair(entry_hash, std::vector<Closure>()));
263 } 262 }
264 263
265 void SimpleBackendImpl::OnDoomComplete(uint64 entry_hash) { 264 void SimpleBackendImpl::OnDoomComplete(uint64 entry_hash) {
266 // TODO(ttuttle): Revert to DCHECK once http://crbug.com/317138 is fixed. 265 DCHECK_EQ(1u, entries_pending_doom_.count(entry_hash));
267 CHECK_EQ(1u, entries_pending_doom_.count(entry_hash));
268 base::hash_map<uint64, std::vector<Closure> >::iterator it = 266 base::hash_map<uint64, std::vector<Closure> >::iterator it =
269 entries_pending_doom_.find(entry_hash); 267 entries_pending_doom_.find(entry_hash);
270 std::vector<Closure> to_run_closures; 268 std::vector<Closure> to_run_closures;
271 to_run_closures.swap(it->second); 269 to_run_closures.swap(it->second);
272 entries_pending_doom_.erase(it); 270 entries_pending_doom_.erase(it);
273 271
274 std::for_each(to_run_closures.begin(), to_run_closures.end(), 272 std::for_each(to_run_closures.begin(), to_run_closures.end(),
275 std::mem_fun_ref(&Closure::Run)); 273 std::mem_fun_ref(&Closure::Run));
276 } 274 }
277 275
278 void SimpleBackendImpl::DoomEntries(std::vector<uint64>* entry_hashes, 276 void SimpleBackendImpl::DoomEntries(std::vector<uint64>* entry_hashes,
279 const net::CompletionCallback& callback) { 277 const net::CompletionCallback& callback) {
280 scoped_ptr<std::vector<uint64> > 278 scoped_ptr<std::vector<uint64> >
281 mass_doom_entry_hashes(new std::vector<uint64>()); 279 mass_doom_entry_hashes(new std::vector<uint64>());
282 mass_doom_entry_hashes->swap(*entry_hashes); 280 mass_doom_entry_hashes->swap(*entry_hashes);
283 281
284 std::vector<uint64> to_doom_individually_hashes; 282 std::vector<uint64> to_doom_individually_hashes;
285 283
286 // For each of the entry hashes, there are two cases: 284 // For each of the entry hashes, there are two cases:
287 // 1. The entry is either open or pending doom, and so it should be doomed 285 // 1. The entry is either open or pending doom, and so it should be doomed
288 // individually to avoid flakes. 286 // individually to avoid flakes.
289 // 2. The entry is not in use at all, so we can call 287 // 2. The entry is not in use at all, so we can call
290 // SimpleSynchronousEntry::DoomEntrySet and delete the files en masse. 288 // SimpleSynchronousEntry::DoomEntrySet and delete the files en masse.
291 for (int i = mass_doom_entry_hashes->size() - 1; i >= 0; --i) { 289 for (int i = mass_doom_entry_hashes->size() - 1; i >= 0; --i) {
292 const uint64 entry_hash = (*mass_doom_entry_hashes)[i]; 290 const uint64 entry_hash = (*mass_doom_entry_hashes)[i];
293 // TODO(ttuttle): Revert to DCHECK once http://crbug.com/317138 is fixed. 291 DCHECK(active_entries_.count(entry_hash) == 0 ||
294 CHECK(active_entries_.count(entry_hash) == 0 || 292 entries_pending_doom_.count(entry_hash) == 0);
295 entries_pending_doom_.count(entry_hash) == 0)
296 << "The entry 0x" << std::hex << entry_hash
297 << " is both active and pending doom.";
298 if (!active_entries_.count(entry_hash) && 293 if (!active_entries_.count(entry_hash) &&
299 !entries_pending_doom_.count(entry_hash)) { 294 !entries_pending_doom_.count(entry_hash)) {
300 continue; 295 continue;
301 } 296 }
302 297
303 to_doom_individually_hashes.push_back(entry_hash); 298 to_doom_individually_hashes.push_back(entry_hash);
304 299
305 (*mass_doom_entry_hashes)[i] = mass_doom_entry_hashes->back(); 300 (*mass_doom_entry_hashes)[i] = mass_doom_entry_hashes->back();
306 mass_doom_entry_hashes->resize(mass_doom_entry_hashes->size() - 1); 301 mass_doom_entry_hashes->resize(mass_doom_entry_hashes->size() - 1);
307 } 302 }
308 303
309 net::CompletionCallback barrier_callback = 304 net::CompletionCallback barrier_callback =
310 MakeBarrierCompletionCallback(to_doom_individually_hashes.size() + 1, 305 MakeBarrierCompletionCallback(to_doom_individually_hashes.size() + 1,
311 callback); 306 callback);
312 for (std::vector<uint64>::const_iterator 307 for (std::vector<uint64>::const_iterator
313 it = to_doom_individually_hashes.begin(), 308 it = to_doom_individually_hashes.begin(),
314 end = to_doom_individually_hashes.end(); it != end; ++it) { 309 end = to_doom_individually_hashes.end(); it != end; ++it) {
315 const int doom_result = DoomEntryFromHash(*it, barrier_callback); 310 const int doom_result = DoomEntryFromHash(*it, barrier_callback);
316 // TODO(ttuttle): Revert to DCHECK once http://crbug.com/317138 is fixed. 311 DCHECK_EQ(net::ERR_IO_PENDING, doom_result);
317 CHECK_EQ(net::ERR_IO_PENDING, doom_result);
318 index_->Remove(*it); 312 index_->Remove(*it);
319 } 313 }
320 314
321 for (std::vector<uint64>::const_iterator it = mass_doom_entry_hashes->begin(), 315 for (std::vector<uint64>::const_iterator it = mass_doom_entry_hashes->begin(),
322 end = mass_doom_entry_hashes->end(); 316 end = mass_doom_entry_hashes->end();
323 it != end; ++it) { 317 it != end; ++it) {
324 index_->Remove(*it); 318 index_->Remove(*it);
325 OnDoomStart(*it); 319 OnDoomStart(*it);
326 } 320 }
327 321
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 this)); 697 this));
704 callback.Run(result); 698 callback.Run(result);
705 } 699 }
706 700
707 void SimpleBackendImpl::FlushWorkerPoolForTesting() { 701 void SimpleBackendImpl::FlushWorkerPoolForTesting() {
708 if (g_sequenced_worker_pool) 702 if (g_sequenced_worker_pool)
709 g_sequenced_worker_pool->FlushForTesting(); 703 g_sequenced_worker_pool->FlushForTesting();
710 } 704 }
711 705
712 } // namespace disk_cache 706 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698