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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 NOTREACHED(); | 169 NOTREACHED(); |
170 return; | 170 return; |
171 } | 171 } |
172 #endif // NDEBUG | 172 #endif // NDEBUG |
173 } | 173 } |
174 | 174 |
175 } // namespace | 175 } // namespace |
176 | 176 |
177 namespace disk_cache { | 177 namespace disk_cache { |
178 | 178 |
| 179 Rankings::Iterator::Iterator(Rankings* rankings) { |
| 180 memset(this, 0, sizeof(Iterator)); |
| 181 my_rankings = rankings; |
| 182 } |
| 183 |
| 184 Rankings::Iterator::~Iterator() { |
| 185 for (int i = 0; i < 3; i++) |
| 186 ScopedRankingsBlock(my_rankings, nodes[i]); |
| 187 } |
| 188 |
| 189 Rankings::Rankings() : init_(false) {} |
| 190 |
| 191 Rankings::~Rankings() {} |
| 192 |
179 bool Rankings::Init(BackendImpl* backend, bool count_lists) { | 193 bool Rankings::Init(BackendImpl* backend, bool count_lists) { |
180 DCHECK(!init_); | 194 DCHECK(!init_); |
181 if (init_) | 195 if (init_) |
182 return false; | 196 return false; |
183 | 197 |
184 backend_ = backend; | 198 backend_ = backend; |
185 control_data_ = backend_->GetLruData(); | 199 control_data_ = backend_->GetLruData(); |
186 count_lists_ = count_lists; | 200 count_lists_ = count_lists; |
187 | 201 |
188 ReadHeads(); | 202 ReadHeads(); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 void Rankings::DecrementCounter(List list) { | 810 void Rankings::DecrementCounter(List list) { |
797 if (!count_lists_) | 811 if (!count_lists_) |
798 return; | 812 return; |
799 | 813 |
800 DCHECK(control_data_->sizes[list] > 0); | 814 DCHECK(control_data_->sizes[list] > 0); |
801 if (control_data_->sizes[list] > 0) | 815 if (control_data_->sizes[list] > 0) |
802 control_data_->sizes[list]--; | 816 control_data_->sizes[list]--; |
803 } | 817 } |
804 | 818 |
805 } // namespace disk_cache | 819 } // namespace disk_cache |
OLD | NEW |