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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 Time MemEntryImpl::GetLastModified() const { | 158 Time MemEntryImpl::GetLastModified() const { |
159 return last_modified_; | 159 return last_modified_; |
160 } | 160 } |
161 | 161 |
162 int32_t MemEntryImpl::GetDataSize(int index) const { | 162 int32_t MemEntryImpl::GetDataSize(int index) const { |
163 if (index < 0 || index >= kNumStreams) | 163 if (index < 0 || index >= kNumStreams) |
164 return 0; | 164 return 0; |
165 return data_[index].size(); | 165 return data_[index].size(); |
166 } | 166 } |
167 | 167 |
| 168 int64_t MemEntryImpl::GetEntrySize() const { |
| 169 int64_t size = key_.size(); |
| 170 for (int i = 0; i < kNumStreams; ++i) { |
| 171 size += GetDataSize(i); |
| 172 } |
| 173 return size; |
| 174 } |
| 175 |
168 int MemEntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, | 176 int MemEntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, |
169 const CompletionCallback& callback) { | 177 const CompletionCallback& callback) { |
170 if (net_log_.IsCapturing()) { | 178 if (net_log_.IsCapturing()) { |
171 net_log_.BeginEvent( | 179 net_log_.BeginEvent( |
172 net::NetLogEventType::ENTRY_READ_DATA, | 180 net::NetLogEventType::ENTRY_READ_DATA, |
173 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); | 181 CreateNetLogReadWriteDataCallback(index, offset, buf_len, false)); |
174 } | 182 } |
175 | 183 |
176 int result = InternalReadData(index, offset, buf, buf_len); | 184 int result = InternalReadData(index, offset, buf, buf_len); |
177 | 185 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 scanned_len += first_pos - current_child_offset; | 587 scanned_len += first_pos - current_child_offset; |
580 break; | 588 break; |
581 } | 589 } |
582 } | 590 } |
583 scanned_len += kMaxSparseEntrySize - current_child_offset; | 591 scanned_len += kMaxSparseEntrySize - current_child_offset; |
584 } | 592 } |
585 return scanned_len; | 593 return scanned_len; |
586 } | 594 } |
587 | 595 |
588 } // namespace disk_cache | 596 } // namespace disk_cache |
OLD | NEW |