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

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

Issue 113930: Disk cache: Reset mask_ when the disk cache is being restarted.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 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 | « net/data/cache_tests/bad_rankings2/index ('k') | net/disk_cache/backend_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/backend_impl.h" 5 #include "net/disk_cache/backend_impl.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 781 }
782 782
783 void BackendImpl::CriticalError(int error) { 783 void BackendImpl::CriticalError(int error) {
784 LOG(ERROR) << "Critical error found " << error; 784 LOG(ERROR) << "Critical error found " << error;
785 if (disabled_) 785 if (disabled_)
786 return; 786 return;
787 787
788 LogStats(); 788 LogStats();
789 ReportError(error); 789 ReportError(error);
790 790
791 // Reset the mask_ if it was not given by the user.
792 if (mask_ == data_->header.table_len - 1)
793 mask_ = 0;
794
791 // Setting the index table length to an invalid value will force re-creation 795 // Setting the index table length to an invalid value will force re-creation
792 // of the cache files. 796 // of the cache files.
793 data_->header.table_len = 1; 797 data_->header.table_len = 1;
794 disabled_ = true; 798 disabled_ = true;
795 799
796 if (!num_refs_) 800 if (!num_refs_)
797 RestartCache(); 801 RestartCache();
798 } 802 }
799 803
800 void BackendImpl::ReportError(int error) { 804 void BackendImpl::ReportError(int error) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 980
977 // Don't call Init() if directed by the unit test: we are simulating a failure 981 // Don't call Init() if directed by the unit test: we are simulating a failure
978 // trying to re-enable the cache. 982 // trying to re-enable the cache.
979 if (unit_test_) 983 if (unit_test_)
980 init_ = true; // Let the destructor do proper cleanup. 984 init_ = true; // Let the destructor do proper cleanup.
981 else if (Init()) 985 else if (Init())
982 stats_.SetCounter(Stats::FATAL_ERROR, errors + 1); 986 stats_.SetCounter(Stats::FATAL_ERROR, errors + 1);
983 } 987 }
984 988
985 void BackendImpl::PrepareForRestart() { 989 void BackendImpl::PrepareForRestart() {
990 // Reset the mask_ if it was not given by the user.
991 if (mask_ == data_->header.table_len - 1)
992 mask_ = 0;
993
986 data_->header.crash = 0; 994 data_->header.crash = 0;
987 index_ = NULL; 995 index_ = NULL;
988 data_ = NULL; 996 data_ = NULL;
989 block_files_.CloseFiles(); 997 block_files_.CloseFiles();
990 rankings_.Reset(); 998 rankings_.Reset();
991 init_ = false; 999 init_ = false;
992 restarted_ = true; 1000 restarted_ = true;
993 } 1001 }
994 1002
995 int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) { 1003 int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) {
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1499
1492 return num_dirty; 1500 return num_dirty;
1493 } 1501 }
1494 1502
1495 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { 1503 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) {
1496 RankingsNode* rankings = cache_entry->rankings()->Data(); 1504 RankingsNode* rankings = cache_entry->rankings()->Data();
1497 return !rankings->pointer; 1505 return !rankings->pointer;
1498 } 1506 }
1499 1507
1500 } // namespace disk_cache 1508 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/data/cache_tests/bad_rankings2/index ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698