OLD | NEW |
1 // Copyright (c) 2012 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/blockfile/rankings.h" | 5 #include "net/disk_cache/blockfile/rankings.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "net/disk_cache/blockfile/backend_impl.h" | 8 #include "net/disk_cache/blockfile/backend_impl.h" |
9 #include "net/disk_cache/blockfile/disk_format.h" | 9 #include "net/disk_cache/blockfile/disk_format.h" |
10 #include "net/disk_cache/blockfile/entry_impl.h" | 10 #include "net/disk_cache/blockfile/entry_impl.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 Rankings::ScopedRankingsBlock::ScopedRankingsBlock() : rankings_(NULL) {} | 196 Rankings::ScopedRankingsBlock::ScopedRankingsBlock() : rankings_(NULL) {} |
197 | 197 |
198 Rankings::ScopedRankingsBlock::ScopedRankingsBlock(Rankings* rankings) | 198 Rankings::ScopedRankingsBlock::ScopedRankingsBlock(Rankings* rankings) |
199 : rankings_(rankings) {} | 199 : rankings_(rankings) {} |
200 | 200 |
201 Rankings::ScopedRankingsBlock::ScopedRankingsBlock( | 201 Rankings::ScopedRankingsBlock::ScopedRankingsBlock( |
202 Rankings* rankings, CacheRankingsBlock* node) | 202 Rankings* rankings, CacheRankingsBlock* node) |
203 : scoped_ptr<CacheRankingsBlock>(node), rankings_(rankings) {} | 203 : scoped_ptr<CacheRankingsBlock>(node), rankings_(rankings) {} |
204 | 204 |
205 Rankings::Iterator::Iterator(Rankings* rankings) { | 205 Rankings::Iterator::Iterator() { |
206 memset(this, 0, sizeof(Iterator)); | 206 memset(this, 0, sizeof(Iterator)); |
207 my_rankings = rankings; | |
208 } | 207 } |
209 | 208 |
210 Rankings::Iterator::~Iterator() { | 209 void Rankings::Iterator::Reset() { |
211 for (int i = 0; i < 3; i++) | 210 if (my_rankings) { |
212 ScopedRankingsBlock(my_rankings, nodes[i]); | 211 for (int i = 0; i < 3; i++) |
| 212 ScopedRankingsBlock(my_rankings, nodes[i]); |
| 213 } |
| 214 memset(this, 0, sizeof(Iterator)); |
213 } | 215 } |
214 | 216 |
215 Rankings::Rankings() : init_(false) {} | 217 Rankings::Rankings() : init_(false) {} |
216 | 218 |
217 Rankings::~Rankings() {} | 219 Rankings::~Rankings() {} |
218 | 220 |
219 bool Rankings::Init(BackendImpl* backend, bool count_lists) { | 221 bool Rankings::Init(BackendImpl* backend, bool count_lists) { |
220 DCHECK(!init_); | 222 DCHECK(!init_); |
221 if (init_) | 223 if (init_) |
222 return false; | 224 return false; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 void Rankings::DecrementCounter(List list) { | 918 void Rankings::DecrementCounter(List list) { |
917 if (!count_lists_) | 919 if (!count_lists_) |
918 return; | 920 return; |
919 | 921 |
920 DCHECK(control_data_->sizes[list] > 0); | 922 DCHECK(control_data_->sizes[list] > 0); |
921 if (control_data_->sizes[list] > 0) | 923 if (control_data_->sizes[list] > 0) |
922 control_data_->sizes[list]--; | 924 control_data_->sizes[list]--; |
923 } | 925 } |
924 | 926 |
925 } // namespace disk_cache | 927 } // namespace disk_cache |
OLD | NEW |