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/memory/mem_entry_impl.h" | 5 #include "net/disk_cache/memory/mem_entry_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 void MemEntryImpl::Open() { | 97 void MemEntryImpl::Open() { |
98 // Only a parent entry can be opened. | 98 // Only a parent entry can be opened. |
99 DCHECK_EQ(PARENT_ENTRY, type()); | 99 DCHECK_EQ(PARENT_ENTRY, type()); |
100 ++ref_count_; | 100 ++ref_count_; |
101 DCHECK_GE(ref_count_, 1); | 101 DCHECK_GE(ref_count_, 1); |
102 DCHECK(!doomed_); | 102 DCHECK(!doomed_); |
103 } | 103 } |
104 | 104 |
105 bool MemEntryImpl::InUse() const { | 105 bool MemEntryImpl::InUse() const { |
106 if (type() == PARENT_ENTRY) { | 106 if (type() == CHILD_ENTRY) |
107 return ref_count_ > 0; | 107 return parent_->InUse(); |
108 } else { | |
109 // TODO(gavinp): Can't this just be a DCHECK? How would ref_count_ not be | |
110 // zero? | |
111 | 108 |
112 // A child entry is never in use. Thus one can always be evicted, even while | 109 return ref_count_ > 0; |
113 // its parent entry is open and in use. | |
114 return false; | |
115 } | |
116 } | 110 } |
117 | 111 |
118 int MemEntryImpl::GetStorageSize() const { | 112 int MemEntryImpl::GetStorageSize() const { |
119 int storage_size = static_cast<int32_t>(key_.size()); | 113 int storage_size = static_cast<int32_t>(key_.size()); |
120 for (const auto& i : data_) | 114 for (const auto& i : data_) |
121 storage_size += i.size(); | 115 storage_size += i.size(); |
122 return storage_size; | 116 return storage_size; |
123 } | 117 } |
124 | 118 |
125 void MemEntryImpl::UpdateStateOnUse(EntryModified modified_enum) { | 119 void MemEntryImpl::UpdateStateOnUse(EntryModified modified_enum) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 scanned_len += first_pos - current_child_offset; | 582 scanned_len += first_pos - current_child_offset; |
589 break; | 583 break; |
590 } | 584 } |
591 } | 585 } |
592 scanned_len += kMaxSparseEntrySize - current_child_offset; | 586 scanned_len += kMaxSparseEntrySize - current_child_offset; |
593 } | 587 } |
594 return scanned_len; | 588 return scanned_len; |
595 } | 589 } |
596 | 590 |
597 } // namespace disk_cache | 591 } // namespace disk_cache |
OLD | NEW |