Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: net/disk_cache/blockfile/entry_impl.cc

Issue 1910023002: Remove partial blockfile v3 disk_cache implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/disk_format_v3.h ('k') | net/disk_cache/blockfile/entry_impl_v3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/entry_impl.h" 5 #include "net/disk_cache/blockfile/entry_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return false; 585 return false;
586 586
587 if (stored->reuse_count < 0 || stored->refetch_count < 0) 587 if (stored->reuse_count < 0 || stored->refetch_count < 0)
588 return false; 588 return false;
589 589
590 Addr rankings_addr(stored->rankings_node); 590 Addr rankings_addr(stored->rankings_node);
591 if (!rankings_addr.SanityCheckForRankings()) 591 if (!rankings_addr.SanityCheckForRankings())
592 return false; 592 return false;
593 593
594 Addr next_addr(stored->next); 594 Addr next_addr(stored->next);
595 if (next_addr.is_initialized() && !next_addr.SanityCheckForEntryV2()) { 595 if (next_addr.is_initialized() && !next_addr.SanityCheckForEntry()) {
596 STRESS_NOTREACHED(); 596 STRESS_NOTREACHED();
597 return false; 597 return false;
598 } 598 }
599 STRESS_DCHECK(next_addr.value() != entry_.address().value()); 599 STRESS_DCHECK(next_addr.value() != entry_.address().value());
600 600
601 if (stored->state > ENTRY_DOOMED || stored->state < ENTRY_NORMAL) 601 if (stored->state > ENTRY_DOOMED || stored->state < ENTRY_NORMAL)
602 return false; 602 return false;
603 603
604 Addr key_addr(stored->long_key); 604 Addr key_addr(stored->long_key);
605 if ((stored->key_len <= kMaxInternalKeyLength && key_addr.is_initialized()) || 605 if ((stored->key_len <= kMaxInternalKeyLength && key_addr.is_initialized()) ||
606 (stored->key_len > kMaxInternalKeyLength && !key_addr.is_initialized())) 606 (stored->key_len > kMaxInternalKeyLength && !key_addr.is_initialized()))
607 return false; 607 return false;
608 608
609 if (!key_addr.SanityCheckV2()) 609 if (!key_addr.SanityCheck())
610 return false; 610 return false;
611 611
612 if (key_addr.is_initialized() && 612 if (key_addr.is_initialized() &&
613 ((stored->key_len < kMaxBlockSize && key_addr.is_separate_file()) || 613 ((stored->key_len < kMaxBlockSize && key_addr.is_separate_file()) ||
614 (stored->key_len >= kMaxBlockSize && key_addr.is_block_file()))) 614 (stored->key_len >= kMaxBlockSize && key_addr.is_block_file())))
615 return false; 615 return false;
616 616
617 int num_blocks = NumBlocksForEntry(stored->key_len); 617 int num_blocks = NumBlocksForEntry(stored->key_len);
618 if (entry_.address().num_blocks() != num_blocks) 618 if (entry_.address().num_blocks() != num_blocks)
619 return false; 619 return false;
(...skipping 12 matching lines...) Expand all
632 if (stored->hash != base::Hash(GetKey())) 632 if (stored->hash != base::Hash(GetKey()))
633 return false; 633 return false;
634 634
635 for (int i = 0; i < kNumStreams; i++) { 635 for (int i = 0; i < kNumStreams; i++) {
636 Addr data_addr(stored->data_addr[i]); 636 Addr data_addr(stored->data_addr[i]);
637 int data_size = stored->data_size[i]; 637 int data_size = stored->data_size[i];
638 if (data_size < 0) 638 if (data_size < 0)
639 return false; 639 return false;
640 if (!data_size && data_addr.is_initialized()) 640 if (!data_size && data_addr.is_initialized())
641 return false; 641 return false;
642 if (!data_addr.SanityCheckV2()) 642 if (!data_addr.SanityCheck())
643 return false; 643 return false;
644 if (!data_size) 644 if (!data_size)
645 continue; 645 continue;
646 if (data_size <= kMaxBlockSize && data_addr.is_separate_file()) 646 if (data_size <= kMaxBlockSize && data_addr.is_separate_file())
647 return false; 647 return false;
648 if (data_size > kMaxBlockSize && data_addr.is_block_file()) 648 if (data_size > kMaxBlockSize && data_addr.is_block_file())
649 return false; 649 return false;
650 } 650 }
651 return true; 651 return true;
652 } 652 }
653 653
654 void EntryImpl::FixForDelete() { 654 void EntryImpl::FixForDelete() {
655 EntryStore* stored = entry_.Data(); 655 EntryStore* stored = entry_.Data();
656 Addr key_addr(stored->long_key); 656 Addr key_addr(stored->long_key);
657 657
658 if (!key_addr.is_initialized()) 658 if (!key_addr.is_initialized())
659 stored->key[stored->key_len] = '\0'; 659 stored->key[stored->key_len] = '\0';
660 660
661 for (int i = 0; i < kNumStreams; i++) { 661 for (int i = 0; i < kNumStreams; i++) {
662 Addr data_addr(stored->data_addr[i]); 662 Addr data_addr(stored->data_addr[i]);
663 int data_size = stored->data_size[i]; 663 int data_size = stored->data_size[i];
664 if (data_addr.is_initialized()) { 664 if (data_addr.is_initialized()) {
665 if ((data_size <= kMaxBlockSize && data_addr.is_separate_file()) || 665 if ((data_size <= kMaxBlockSize && data_addr.is_separate_file()) ||
666 (data_size > kMaxBlockSize && data_addr.is_block_file()) || 666 (data_size > kMaxBlockSize && data_addr.is_block_file()) ||
667 !data_addr.SanityCheckV2()) { 667 !data_addr.SanityCheck()) {
668 STRESS_NOTREACHED(); 668 STRESS_NOTREACHED();
669 // The address is weird so don't attempt to delete it. 669 // The address is weird so don't attempt to delete it.
670 stored->data_addr[i] = 0; 670 stored->data_addr[i] = 0;
671 // In general, trust the stored size as it should be in sync with the 671 // In general, trust the stored size as it should be in sync with the
672 // total size tracked by the backend. 672 // total size tracked by the backend.
673 } 673 }
674 } 674 }
675 if (data_size < 0) 675 if (data_size < 0)
676 stored->data_size[i] = 0; 676 stored->data_size[i] = 0;
677 } 677 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 1558 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
1559 entry_.address().value(), node_.address().value()); 1559 entry_.address().value(), node_.address().value());
1560 1560
1561 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 1561 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
1562 entry_.Data()->data_addr[1], entry_.Data()->long_key); 1562 entry_.Data()->data_addr[1], entry_.Data()->long_key);
1563 1563
1564 Trace(" doomed: %d 0x%x", doomed_, dirty); 1564 Trace(" doomed: %d 0x%x", doomed_, dirty);
1565 } 1565 }
1566 1566
1567 } // namespace disk_cache 1567 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/disk_format_v3.h ('k') | net/disk_cache/blockfile/entry_impl_v3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698