| OLD | NEW |
| 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 791 // Reset the mask_ if it was not given by the user. |
| 792 if (mask_ == data_->header.table_len - 1) | 792 if (static_cast<int>(mask_) == data_->header.table_len - 1) |
| 793 mask_ = 0; | 793 mask_ = 0; |
| 794 | 794 |
| 795 // 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 |
| 796 // of the cache files. | 796 // of the cache files. |
| 797 data_->header.table_len = 1; | 797 data_->header.table_len = 1; |
| 798 disabled_ = true; | 798 disabled_ = true; |
| 799 | 799 |
| 800 if (!num_refs_) | 800 if (!num_refs_) |
| 801 RestartCache(); | 801 RestartCache(); |
| 802 } | 802 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 // 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 |
| 982 // trying to re-enable the cache. | 982 // trying to re-enable the cache. |
| 983 if (unit_test_) | 983 if (unit_test_) |
| 984 init_ = true; // Let the destructor do proper cleanup. | 984 init_ = true; // Let the destructor do proper cleanup. |
| 985 else if (Init()) | 985 else if (Init()) |
| 986 stats_.SetCounter(Stats::FATAL_ERROR, errors + 1); | 986 stats_.SetCounter(Stats::FATAL_ERROR, errors + 1); |
| 987 } | 987 } |
| 988 | 988 |
| 989 void BackendImpl::PrepareForRestart() { | 989 void BackendImpl::PrepareForRestart() { |
| 990 // Reset the mask_ if it was not given by the user. | 990 // Reset the mask_ if it was not given by the user. |
| 991 if (mask_ == data_->header.table_len - 1) | 991 if (static_cast<int>(mask_) == data_->header.table_len - 1) |
| 992 mask_ = 0; | 992 mask_ = 0; |
| 993 | 993 |
| 994 data_->header.crash = 0; | 994 data_->header.crash = 0; |
| 995 index_ = NULL; | 995 index_ = NULL; |
| 996 data_ = NULL; | 996 data_ = NULL; |
| 997 block_files_.CloseFiles(); | 997 block_files_.CloseFiles(); |
| 998 rankings_.Reset(); | 998 rankings_.Reset(); |
| 999 init_ = false; | 999 init_ = false; |
| 1000 restarted_ = true; | 1000 restarted_ = true; |
| 1001 } | 1001 } |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 | 1499 |
| 1500 return num_dirty; | 1500 return num_dirty; |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { | 1503 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { |
| 1504 RankingsNode* rankings = cache_entry->rankings()->Data(); | 1504 RankingsNode* rankings = cache_entry->rankings()->Data(); |
| 1505 return !rankings->pointer; | 1505 return !rankings->pointer; |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 } // namespace disk_cache | 1508 } // namespace disk_cache |
| OLD | NEW |