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

Side by Side Diff: net/disk_cache/simple/simple_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: Missed some spots again. 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/simple/simple_entry_impl.h" 5 #include "net/disk_cache/simple/simple_entry_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 DCHECK(io_thread_checker_.CalledOnValidThread()); 332 DCHECK(io_thread_checker_.CalledOnValidThread());
333 return last_modified_; 333 return last_modified_;
334 } 334 }
335 335
336 int32 SimpleEntryImpl::GetDataSize(int stream_index) const { 336 int32 SimpleEntryImpl::GetDataSize(int stream_index) const {
337 DCHECK(io_thread_checker_.CalledOnValidThread()); 337 DCHECK(io_thread_checker_.CalledOnValidThread());
338 DCHECK_LE(0, data_size_[stream_index]); 338 DCHECK_LE(0, data_size_[stream_index]);
339 return data_size_[stream_index]; 339 return data_size_[stream_index];
340 } 340 }
341 341
342 int SimpleEntryImpl::GetEntrySize() const {
343 DCHECK(io_thread_checker_.CalledOnValidThread());
344 int result = 0;
345 for (int i = 0; i < kSimpleEntryStreamCount; ++i)
346 result += GetDataSize(i);
347 return result;
348 }
349
342 int SimpleEntryImpl::ReadData(int stream_index, 350 int SimpleEntryImpl::ReadData(int stream_index,
343 int offset, 351 int offset,
344 net::IOBuffer* buf, 352 net::IOBuffer* buf,
345 int buf_len, 353 int buf_len,
346 const CompletionCallback& callback) { 354 const CompletionCallback& callback) {
347 DCHECK(io_thread_checker_.CalledOnValidThread()); 355 DCHECK(io_thread_checker_.CalledOnValidThread());
348 356
349 if (net_log_.IsCapturing()) { 357 if (net_log_.IsCapturing()) {
350 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_CALL, 358 net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_READ_CALL,
351 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len, 359 CreateNetLogReadWriteDataCallback(stream_index, offset, buf_len,
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 } 1526 }
1519 crc32s_end_offset_[stream_index] = offset + length; 1527 crc32s_end_offset_[stream_index] = offset + length;
1520 } else if (offset < crc32s_end_offset_[stream_index]) { 1528 } else if (offset < crc32s_end_offset_[stream_index]) {
1521 // If a range for which the crc32 was already computed is rewritten, the 1529 // If a range for which the crc32 was already computed is rewritten, the
1522 // computation of the crc32 need to start from 0 again. 1530 // computation of the crc32 need to start from 0 again.
1523 crc32s_end_offset_[stream_index] = 0; 1531 crc32s_end_offset_[stream_index] = 0;
1524 } 1532 }
1525 } 1533 }
1526 1534
1527 } // namespace disk_cache 1535 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698