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/entry_impl.h" | 5 #include "net/disk_cache/entry_impl.h" |
6 | 6 |
| 7 #include "base/hash.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/disk_cache/backend_impl.h" | 13 #include "net/disk_cache/backend_impl.h" |
13 #include "net/disk_cache/bitmap.h" | 14 #include "net/disk_cache/bitmap.h" |
14 #include "net/disk_cache/cache_util.h" | 15 #include "net/disk_cache/cache_util.h" |
15 #include "net/disk_cache/hash.h" | |
16 #include "net/disk_cache/histogram_macros.h" | 16 #include "net/disk_cache/histogram_macros.h" |
17 #include "net/disk_cache/net_log_parameters.h" | 17 #include "net/disk_cache/net_log_parameters.h" |
18 #include "net/disk_cache/sparse_control.h" | 18 #include "net/disk_cache/sparse_control.h" |
19 | 19 |
20 using base::Time; | 20 using base::Time; |
21 using base::TimeDelta; | 21 using base::TimeDelta; |
22 using base::TimeTicks; | 22 using base::TimeTicks; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 | 610 |
611 bool EntryImpl::DataSanityCheck() { | 611 bool EntryImpl::DataSanityCheck() { |
612 EntryStore* stored = entry_.Data(); | 612 EntryStore* stored = entry_.Data(); |
613 Addr key_addr(stored->long_key); | 613 Addr key_addr(stored->long_key); |
614 | 614 |
615 // The key must be NULL terminated. | 615 // The key must be NULL terminated. |
616 if (!key_addr.is_initialized() && stored->key[stored->key_len]) | 616 if (!key_addr.is_initialized() && stored->key[stored->key_len]) |
617 return false; | 617 return false; |
618 | 618 |
619 if (stored->hash != Hash(GetKey())) | 619 if (stored->hash != base::Hash(GetKey())) |
620 return false; | 620 return false; |
621 | 621 |
622 for (int i = 0; i < kNumStreams; i++) { | 622 for (int i = 0; i < kNumStreams; i++) { |
623 Addr data_addr(stored->data_addr[i]); | 623 Addr data_addr(stored->data_addr[i]); |
624 int data_size = stored->data_size[i]; | 624 int data_size = stored->data_size[i]; |
625 if (data_size < 0) | 625 if (data_size < 0) |
626 return false; | 626 return false; |
627 if (!data_size && data_addr.is_initialized()) | 627 if (!data_size && data_addr.is_initialized()) |
628 return false; | 628 return false; |
629 if (!data_addr.SanityCheck()) | 629 if (!data_addr.SanityCheck()) |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1538 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
1539 entry_.address().value(), node_.address().value()); | 1539 entry_.address().value(), node_.address().value()); |
1540 | 1540 |
1541 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1541 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
1542 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1542 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
1543 | 1543 |
1544 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1544 Trace(" doomed: %d 0x%x", doomed_, dirty); |
1545 } | 1545 } |
1546 | 1546 |
1547 } // namespace disk_cache | 1547 } // namespace disk_cache |
OLD | NEW |