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

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

Issue 9702059: Disk cache: Remove all non essential synchronization from the cache destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011 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/sparse_control.h" 5 #include "net/disk_cache/sparse_control.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Keep using the same child or open another one?. 435 // Keep using the same child or open another one?.
436 if (key == child_->GetKey()) 436 if (key == child_->GetKey())
437 return true; 437 return true;
438 CloseChild(); 438 CloseChild();
439 } 439 }
440 440
441 // See if we are tracking this child. 441 // See if we are tracking this child.
442 if (!ChildPresent()) 442 if (!ChildPresent())
443 return ContinueWithoutChild(key); 443 return ContinueWithoutChild(key);
444 444
445 if (!entry_->backend_)
446 return false;
447
445 child_ = entry_->backend_->OpenEntryImpl(key); 448 child_ = entry_->backend_->OpenEntryImpl(key);
446 if (!child_) 449 if (!child_)
447 return ContinueWithoutChild(key); 450 return ContinueWithoutChild(key);
448 451
449 EntryImpl* child = static_cast<EntryImpl*>(child_); 452 EntryImpl* child = static_cast<EntryImpl*>(child_);
450 if (!(CHILD_ENTRY & child->GetEntryFlags()) || 453 if (!(CHILD_ENTRY & child->GetEntryFlags()) ||
451 child->GetDataSize(kSparseIndex) < 454 child->GetDataSize(kSparseIndex) <
452 static_cast<int>(sizeof(child_data_))) 455 static_cast<int>(sizeof(child_data_)))
453 return KillChildAndContinue(key, false); 456 return KillChildAndContinue(key, false);
454 457
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return ContinueWithoutChild(key); 510 return ContinueWithoutChild(key);
508 } 511 }
509 512
510 // We were not able to open this child; see what we can do. 513 // We were not able to open this child; see what we can do.
511 bool SparseControl::ContinueWithoutChild(const std::string& key) { 514 bool SparseControl::ContinueWithoutChild(const std::string& key) {
512 if (kReadOperation == operation_) 515 if (kReadOperation == operation_)
513 return false; 516 return false;
514 if (kGetRangeOperation == operation_) 517 if (kGetRangeOperation == operation_)
515 return true; 518 return true;
516 519
520 if (!entry_->backend_)
521 return false;
522
517 child_ = entry_->backend_->CreateEntryImpl(key); 523 child_ = entry_->backend_->CreateEntryImpl(key);
518 if (!child_) { 524 if (!child_) {
519 child_ = NULL; 525 child_ = NULL;
520 result_ = net::ERR_CACHE_READ_FAILURE; 526 result_ = net::ERR_CACHE_READ_FAILURE;
521 return false; 527 return false;
522 } 528 }
523 // Write signature. 529 // Write signature.
524 InitChildData(); 530 InitChildData();
525 return true; 531 return true;
526 } 532 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 net::CompletionCallback cb = abort_callbacks_[i]; 869 net::CompletionCallback cb = abort_callbacks_[i];
864 if (i == abort_callbacks_.size() - 1) 870 if (i == abort_callbacks_.size() - 1)
865 abort_callbacks_.clear(); 871 abort_callbacks_.clear();
866 872
867 entry_->Release(); // Don't touch object after this line. 873 entry_->Release(); // Don't touch object after this line.
868 cb.Run(net::OK); 874 cb.Run(net::OK);
869 } 875 }
870 } 876 }
871 877
872 } // namespace disk_cache 878 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698