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/rankings.h" | 5 #include "net/disk_cache/rankings.h" |
6 | 6 |
7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
8 #include "net/disk_cache/backend_impl.h" | 8 #include "net/disk_cache/backend_impl.h" |
9 #include "net/disk_cache/entry_impl.h" | 9 #include "net/disk_cache/entry_impl.h" |
10 #include "net/disk_cache/errors.h" | 10 #include "net/disk_cache/errors.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 if (!rankings->Data()->pointer) { | 219 if (!rankings->Data()->pointer) { |
220 backend_->OnEvent(Stats::GET_RANKINGS); | 220 backend_->OnEvent(Stats::GET_RANKINGS); |
221 return true; | 221 return true; |
222 } | 222 } |
223 | 223 |
224 backend_->OnEvent(Stats::OPEN_RANKINGS); | 224 backend_->OnEvent(Stats::OPEN_RANKINGS); |
225 | 225 |
226 if (backend_->GetCurrentEntryId() != rankings->Data()->dirty) { | 226 if (backend_->GetCurrentEntryId() != rankings->Data()->dirty || |
| 227 !backend_->IsOpen(rankings)) { |
227 // We cannot trust this entry, but we cannot initiate a cleanup from this | 228 // We cannot trust this entry, but we cannot initiate a cleanup from this |
228 // point (we may be in the middle of a cleanup already). Just get rid of | 229 // point (we may be in the middle of a cleanup already). Just get rid of |
229 // the invalid pointer and continue; the entry will be deleted when detected | 230 // the invalid pointer and continue; the entry will be deleted when detected |
230 // from a regular open/create path. | 231 // from a regular open/create path. |
231 rankings->Data()->pointer = NULL; | 232 rankings->Data()->pointer = NULL; |
| 233 rankings->Data()->dirty = backend_->GetCurrentEntryId() - 1; |
232 if (!rankings->Data()->dirty) | 234 if (!rankings->Data()->dirty) |
233 rankings->Data()->dirty = backend_->GetCurrentEntryId() - 1; | 235 rankings->Data()->dirty--; |
234 return true; | 236 return true; |
235 } | 237 } |
236 | 238 |
237 EntryImpl* cache_entry = | 239 EntryImpl* cache_entry = |
238 reinterpret_cast<EntryImpl*>(rankings->Data()->pointer); | 240 reinterpret_cast<EntryImpl*>(rankings->Data()->pointer); |
239 rankings->SetData(cache_entry->rankings()->Data()); | 241 rankings->SetData(cache_entry->rankings()->Data()); |
240 CACHE_UMA(AGE_MS, "GetRankings", 0, start); | 242 CACHE_UMA(AGE_MS, "GetRankings", 0, start); |
241 return true; | 243 return true; |
242 } | 244 } |
243 | 245 |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 void Rankings::DecrementCounter(List list) { | 766 void Rankings::DecrementCounter(List list) { |
765 if (!count_lists_) | 767 if (!count_lists_) |
766 return; | 768 return; |
767 | 769 |
768 DCHECK(control_data_->sizes[list] > 0); | 770 DCHECK(control_data_->sizes[list] > 0); |
769 if (control_data_->sizes[list] > 0) | 771 if (control_data_->sizes[list] > 0) |
770 control_data_->sizes[list]--; | 772 control_data_->sizes[list]--; |
771 } | 773 } |
772 | 774 |
773 } // namespace disk_cache | 775 } // namespace disk_cache |
OLD | NEW |