| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if (!my_head.is_initialized()) | 488 if (!my_head.is_initialized()) |
| 489 return NULL; | 489 return NULL; |
| 490 next.reset(new CacheRankingsBlock(backend_->File(my_head), my_head)); | 490 next.reset(new CacheRankingsBlock(backend_->File(my_head), my_head)); |
| 491 } else { | 491 } else { |
| 492 Addr& my_tail = tails_[list]; | 492 Addr& my_tail = tails_[list]; |
| 493 if (!my_tail.is_initialized()) | 493 if (!my_tail.is_initialized()) |
| 494 return NULL; | 494 return NULL; |
| 495 if (my_tail.value() == node->address().value()) | 495 if (my_tail.value() == node->address().value()) |
| 496 return NULL; | 496 return NULL; |
| 497 Addr address(node->Data()->next); | 497 Addr address(node->Data()->next); |
| 498 if (address.value() == node->address().value()) |
| 499 return NULL; // Another tail? fail it. |
| 498 next.reset(new CacheRankingsBlock(backend_->File(address), address)); | 500 next.reset(new CacheRankingsBlock(backend_->File(address), address)); |
| 499 } | 501 } |
| 500 | 502 |
| 501 TrackRankingsBlock(next.get(), true); | 503 TrackRankingsBlock(next.get(), true); |
| 502 | 504 |
| 503 if (!GetRanking(next.get())) | 505 if (!GetRanking(next.get())) |
| 504 return NULL; | 506 return NULL; |
| 505 | 507 |
| 506 if (node && !CheckSingleLink(node, next.get())) | 508 if (node && !CheckSingleLink(node, next.get())) |
| 507 return NULL; | 509 return NULL; |
| 508 | 510 |
| 509 return next.release(); | 511 return next.release(); |
| 510 } | 512 } |
| 511 | 513 |
| 512 CacheRankingsBlock* Rankings::GetPrev(CacheRankingsBlock* node, List list) { | 514 CacheRankingsBlock* Rankings::GetPrev(CacheRankingsBlock* node, List list) { |
| 513 ScopedRankingsBlock prev(this); | 515 ScopedRankingsBlock prev(this); |
| 514 if (!node) { | 516 if (!node) { |
| 515 Addr& my_tail = tails_[list]; | 517 Addr& my_tail = tails_[list]; |
| 516 if (!my_tail.is_initialized()) | 518 if (!my_tail.is_initialized()) |
| 517 return NULL; | 519 return NULL; |
| 518 prev.reset(new CacheRankingsBlock(backend_->File(my_tail), my_tail)); | 520 prev.reset(new CacheRankingsBlock(backend_->File(my_tail), my_tail)); |
| 519 } else { | 521 } else { |
| 520 Addr& my_head = heads_[list]; | 522 Addr& my_head = heads_[list]; |
| 521 if (!my_head.is_initialized()) | 523 if (!my_head.is_initialized()) |
| 522 return NULL; | 524 return NULL; |
| 523 if (my_head.value() == node->address().value()) | 525 if (my_head.value() == node->address().value()) |
| 524 return NULL; | 526 return NULL; |
| 525 Addr address(node->Data()->prev); | 527 Addr address(node->Data()->prev); |
| 528 if (address.value() == node->address().value()) |
| 529 return NULL; // Another head? fail it. |
| 526 prev.reset(new CacheRankingsBlock(backend_->File(address), address)); | 530 prev.reset(new CacheRankingsBlock(backend_->File(address), address)); |
| 527 } | 531 } |
| 528 | 532 |
| 529 TrackRankingsBlock(prev.get(), true); | 533 TrackRankingsBlock(prev.get(), true); |
| 530 | 534 |
| 531 if (!GetRanking(prev.get())) | 535 if (!GetRanking(prev.get())) |
| 532 return NULL; | 536 return NULL; |
| 533 | 537 |
| 534 if (node && !CheckSingleLink(prev.get(), node)) | 538 if (node && !CheckSingleLink(prev.get(), node)) |
| 535 return NULL; | 539 return NULL; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 ++it) { | 720 ++it) { |
| 717 if (it->first == address) { | 721 if (it->first == address) { |
| 718 CacheRankingsBlock* other = it->second; | 722 CacheRankingsBlock* other = it->second; |
| 719 other->Data()->next = node->Data()->next; | 723 other->Data()->next = node->Data()->next; |
| 720 other->Data()->prev = node->Data()->prev; | 724 other->Data()->prev = node->Data()->prev; |
| 721 } | 725 } |
| 722 } | 726 } |
| 723 } | 727 } |
| 724 | 728 |
| 725 } // namespace disk_cache | 729 } // namespace disk_cache |
| OLD | NEW |