OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/entry_impl.h" | 5 #include "net/disk_cache/entry_impl.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 if (!rankings->dirty) { | 537 if (!rankings->dirty) { |
538 rankings->dirty = backend_->GetCurrentEntryId(); | 538 rankings->dirty = backend_->GetCurrentEntryId(); |
539 if (!node_.Store()) | 539 if (!node_.Store()) |
540 return false; | 540 return false; |
541 } | 541 } |
542 return true; | 542 return true; |
543 } | 543 } |
544 | 544 |
545 void EntryImpl::SetDirtyFlag(int32 current_id) { | 545 void EntryImpl::SetDirtyFlag(int32 current_id) { |
546 DCHECK(node_.HasData()); | 546 DCHECK(node_.HasData()); |
547 // We are checking if the entry is valid or not. If there is a pointer here, | |
548 // we should not be checking the entry. | |
549 if (node_.Data()->dummy) | |
550 dirty_ = true; | |
551 | |
552 if (node_.Data()->dirty && current_id != node_.Data()->dirty) | 547 if (node_.Data()->dirty && current_id != node_.Data()->dirty) |
553 dirty_ = true; | 548 dirty_ = true; |
554 | 549 |
555 if (!current_id) | 550 if (!current_id) |
556 dirty_ = true; | 551 dirty_ = true; |
557 } | 552 } |
558 | 553 |
559 void EntryImpl::SetPointerForInvalidEntry(int32 new_id) { | 554 void EntryImpl::SetPointerForInvalidEntry(int32 new_id) { |
560 node_.Data()->dirty = new_id; | 555 node_.Data()->dirty = new_id; |
561 node_.Data()->dummy = 0; | |
562 node_.Store(); | 556 node_.Store(); |
563 } | 557 } |
564 | 558 |
565 bool EntryImpl::LeaveRankingsBehind() { | 559 bool EntryImpl::LeaveRankingsBehind() { |
566 return !node_.Data()->contents; | 560 return !node_.Data()->contents; |
567 } | 561 } |
568 | 562 |
569 // This only includes checks that relate to the first block of the entry (the | 563 // This only includes checks that relate to the first block of the entry (the |
570 // first 256 bytes), and values that should be set from the entry creation. | 564 // first 256 bytes), and values that should be set from the entry creation. |
571 // Basically, even if there is something wrong with this entry, we want to see | 565 // Basically, even if there is something wrong with this entry, we want to see |
572 // if it is possible to load the rankings node and delete them together. | 566 // if it is possible to load the rankings node and delete them together. |
573 bool EntryImpl::SanityCheck() { | 567 bool EntryImpl::SanityCheck() { |
| 568 if (!entry_.VerifyHash()) |
| 569 return false; |
| 570 |
574 EntryStore* stored = entry_.Data(); | 571 EntryStore* stored = entry_.Data(); |
575 if (!stored->rankings_node || stored->key_len <= 0) | 572 if (!stored->rankings_node || stored->key_len <= 0) |
576 return false; | 573 return false; |
577 | 574 |
578 if (stored->reuse_count < 0 || stored->refetch_count < 0) | 575 if (stored->reuse_count < 0 || stored->refetch_count < 0) |
579 return false; | 576 return false; |
580 | 577 |
581 Addr rankings_addr(stored->rankings_node); | 578 Addr rankings_addr(stored->rankings_node); |
582 if (!rankings_addr.is_initialized() || rankings_addr.is_separate_file() || | 579 if (!rankings_addr.is_initialized() || rankings_addr.is_separate_file() || |
583 rankings_addr.file_type() != RANKINGS || rankings_addr.num_blocks() != 1) | 580 rankings_addr.file_type() != RANKINGS || rankings_addr.num_blocks() != 1) |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1489 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
1493 entry_.address().value(), node_.address().value()); | 1490 entry_.address().value(), node_.address().value()); |
1494 | 1491 |
1495 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1492 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
1496 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1493 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
1497 | 1494 |
1498 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1495 Trace(" doomed: %d 0x%x", doomed_, dirty); |
1499 } | 1496 } |
1500 | 1497 |
1501 } // namespace disk_cache | 1498 } // namespace disk_cache |
OLD | NEW |