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

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

Issue 2591743002: Implement a method to get the total size of a cache entry (Closed)
Patch Set: rebase Created 3 years, 11 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/entry_impl.h ('k') | net/disk_cache/disk_cache.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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 813 }
814 814
815 int32_t EntryImpl::GetDataSize(int index) const { 815 int32_t EntryImpl::GetDataSize(int index) const {
816 if (index < 0 || index >= kNumStreams) 816 if (index < 0 || index >= kNumStreams)
817 return 0; 817 return 0;
818 818
819 CacheEntryBlock* entry = const_cast<CacheEntryBlock*>(&entry_); 819 CacheEntryBlock* entry = const_cast<CacheEntryBlock*>(&entry_);
820 return entry->Data()->data_size[index]; 820 return entry->Data()->data_size[index];
821 } 821 }
822 822
823 int64_t EntryImpl::GetEntrySize() const {
824 int64_t size = GetKey().size();
825 for (int i = 0; i < kNumStreams; ++i) {
826 size += GetDataSize(i);
827 }
828 return size;
829 }
830
823 int EntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, 831 int EntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len,
824 const CompletionCallback& callback) { 832 const CompletionCallback& callback) {
825 if (callback.is_null()) 833 if (callback.is_null())
826 return ReadDataImpl(index, offset, buf, buf_len, callback); 834 return ReadDataImpl(index, offset, buf, buf_len, callback);
827 835
828 DCHECK(node_.Data()->dirty || read_only_); 836 DCHECK(node_.Data()->dirty || read_only_);
829 if (index < 0 || index >= kNumStreams) 837 if (index < 0 || index >= kNumStreams)
830 return net::ERR_INVALID_ARGUMENT; 838 return net::ERR_INVALID_ARGUMENT;
831 839
832 int entry_size = entry_.Data()->data_size[index]; 840 int entry_size = entry_.Data()->data_size[index];
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 1570 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
1563 entry_.address().value(), node_.address().value()); 1571 entry_.address().value(), node_.address().value());
1564 1572
1565 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 1573 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
1566 entry_.Data()->data_addr[1], entry_.Data()->long_key); 1574 entry_.Data()->data_addr[1], entry_.Data()->long_key);
1567 1575
1568 Trace(" doomed: %d 0x%x", doomed_, dirty); 1576 Trace(" doomed: %d 0x%x", doomed_, dirty);
1569 } 1577 }
1570 1578
1571 } // namespace disk_cache 1579 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/entry_impl.h ('k') | net/disk_cache/disk_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698