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

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

Issue 1304363013: Add a size estimation mechanism to StoragePartitionHttpCacheDataRemover. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 "base/hash.h" 7 #include "base/hash.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 801 }
802 802
803 int32 EntryImpl::GetDataSize(int index) const { 803 int32 EntryImpl::GetDataSize(int index) const {
804 if (index < 0 || index >= kNumStreams) 804 if (index < 0 || index >= kNumStreams)
805 return 0; 805 return 0;
806 806
807 CacheEntryBlock* entry = const_cast<CacheEntryBlock*>(&entry_); 807 CacheEntryBlock* entry = const_cast<CacheEntryBlock*>(&entry_);
808 return entry->Data()->data_size[index]; 808 return entry->Data()->data_size[index];
809 } 809 }
810 810
811 int EntryImpl::GetEntrySize() const {
812 int result = 0;
813 for (int i = 0; i < kNumStreams; ++i) {
814 result += GetDataSize(i);
815 }
816 return result;
817 }
818
811 int EntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len, 819 int EntryImpl::ReadData(int index, int offset, IOBuffer* buf, int buf_len,
812 const CompletionCallback& callback) { 820 const CompletionCallback& callback) {
813 if (callback.is_null()) 821 if (callback.is_null())
814 return ReadDataImpl(index, offset, buf, buf_len, callback); 822 return ReadDataImpl(index, offset, buf, buf_len, callback);
815 823
816 DCHECK(node_.Data()->dirty || read_only_); 824 DCHECK(node_.Data()->dirty || read_only_);
817 if (index < 0 || index >= kNumStreams) 825 if (index < 0 || index >= kNumStreams)
818 return net::ERR_INVALID_ARGUMENT; 826 return net::ERR_INVALID_ARGUMENT;
819 827
820 int entry_size = entry_.Data()->data_size[index]; 828 int entry_size = entry_.Data()->data_size[index];
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 1552 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
1545 entry_.address().value(), node_.address().value()); 1553 entry_.address().value(), node_.address().value());
1546 1554
1547 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 1555 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
1548 entry_.Data()->data_addr[1], entry_.Data()->long_key); 1556 entry_.Data()->data_addr[1], entry_.Data()->long_key);
1549 1557
1550 Trace(" doomed: %d 0x%x", doomed_, dirty); 1558 Trace(" doomed: %d 0x%x", doomed_, dirty);
1551 } 1559 }
1552 1560
1553 } // namespace disk_cache 1561 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698