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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // point (we may be in the middle of a cleanup already). Just get rid of | 227 // point (we may be in the middle of a cleanup already). Just get rid of |
228 // the invalid pointer and continue; the entry will be deleted when detected | 228 // the invalid pointer and continue; the entry will be deleted when detected |
229 // from a regular open/create path. | 229 // from a regular open/create path. |
230 rankings->Data()->pointer = NULL; | 230 rankings->Data()->pointer = NULL; |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 EntryImpl* cache_entry = | 234 EntryImpl* cache_entry = |
235 reinterpret_cast<EntryImpl*>(rankings->Data()->pointer); | 235 reinterpret_cast<EntryImpl*>(rankings->Data()->pointer); |
236 rankings->SetData(cache_entry->rankings()->Data()); | 236 rankings->SetData(cache_entry->rankings()->Data()); |
237 UMA_HISTOGRAM_TIMES(L"DiskCache.GetRankings", Time::Now() - start); | 237 UMA_HISTOGRAM_TIMES("DiskCache.GetRankings", Time::Now() - start); |
238 return true; | 238 return true; |
239 } | 239 } |
240 | 240 |
241 void Rankings::Insert(CacheRankingsBlock* node, bool modified, List list) { | 241 void Rankings::Insert(CacheRankingsBlock* node, bool modified, List list) { |
242 Trace("Insert 0x%x", node->address().value()); | 242 Trace("Insert 0x%x", node->address().value()); |
243 DCHECK(node->HasData()); | 243 DCHECK(node->HasData()); |
244 Addr& my_head = heads_[list]; | 244 Addr& my_head = heads_[list]; |
245 Addr& my_tail = tails_[list]; | 245 Addr& my_tail = tails_[list]; |
246 Transaction lock(control_data_, node->address(), INSERT, list); | 246 Transaction lock(control_data_, node->address(), INSERT, list); |
247 CacheRankingsBlock head(backend_->File(my_head), my_head); | 247 CacheRankingsBlock head(backend_->File(my_head), my_head); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 // A crash in between Remove and Insert will lead to a dirty entry not on the | 384 // A crash in between Remove and Insert will lead to a dirty entry not on the |
385 // list. We want to avoid that case as much as we can (as while waiting for IO), | 385 // list. We want to avoid that case as much as we can (as while waiting for IO), |
386 // but the net effect is just an assert on debug when attempting to remove the | 386 // but the net effect is just an assert on debug when attempting to remove the |
387 // entry. Otherwise we'll need reentrant transactions, which is an overkill. | 387 // entry. Otherwise we'll need reentrant transactions, which is an overkill. |
388 void Rankings::UpdateRank(CacheRankingsBlock* node, bool modified, List list) { | 388 void Rankings::UpdateRank(CacheRankingsBlock* node, bool modified, List list) { |
389 Time start = Time::Now(); | 389 Time start = Time::Now(); |
390 Remove(node, list); | 390 Remove(node, list); |
391 Insert(node, modified, list); | 391 Insert(node, modified, list); |
392 UMA_HISTOGRAM_TIMES(L"DiskCache.UpdateRank", Time::Now() - start); | 392 UMA_HISTOGRAM_TIMES("DiskCache.UpdateRank", Time::Now() - start); |
393 } | 393 } |
394 | 394 |
395 void Rankings::CompleteTransaction() { | 395 void Rankings::CompleteTransaction() { |
396 Addr node_addr(static_cast<CacheAddr>(control_data_->transaction)); | 396 Addr node_addr(static_cast<CacheAddr>(control_data_->transaction)); |
397 if (!node_addr.is_initialized() || node_addr.is_separate_file()) { | 397 if (!node_addr.is_initialized() || node_addr.is_separate_file()) { |
398 NOTREACHED(); | 398 NOTREACHED(); |
399 LOG(ERROR) << "Invalid rankings info."; | 399 LOG(ERROR) << "Invalid rankings info."; |
400 return; | 400 return; |
401 } | 401 } |
402 | 402 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 ++it) { | 741 ++it) { |
742 if (it->first == address) { | 742 if (it->first == address) { |
743 CacheRankingsBlock* other = it->second; | 743 CacheRankingsBlock* other = it->second; |
744 other->Data()->next = node->Data()->next; | 744 other->Data()->next = node->Data()->next; |
745 other->Data()->prev = node->Data()->prev; | 745 other->Data()->prev = node->Data()->prev; |
746 } | 746 } |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 } // namespace disk_cache | 750 } // namespace disk_cache |
OLD | NEW |