diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-14 17:41:05 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:37:36 +0000 |
commit | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch) | |
tree | 6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/net/disk_cache/simple/simple_entry_impl.cc | |
parent | 7366110654eec46f21b6824f302356426f48cd74 (diff) | |
download | qtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz |
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/disk_cache/simple/simple_entry_impl.cc')
-rw-r--r-- | chromium/net/disk_cache/simple/simple_entry_impl.cc | 116 |
1 files changed, 54 insertions, 62 deletions
diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.cc b/chromium/net/disk_cache/simple/simple_entry_impl.cc index 68f1b9e709a..8169b05a6b1 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.cc +++ b/chromium/net/disk_cache/simple/simple_entry_impl.cc @@ -18,7 +18,7 @@ #include "base/single_thread_task_runner.h" #include "base/task_runner.h" #include "base/task_runner_util.h" -#include "base/thread_task_runner_handle.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -81,8 +81,8 @@ void RecordWriteResult(net::CacheType cache_type, WriteResult result) { "WriteResult2", cache_type, result, WRITE_RESULT_MAX); } -// TODO(ttuttle): Consider removing this once we have a good handle on header -// size changes. +// TODO(juliatuttle): Consider removing this once we have a good handle on +// header size changes. void RecordHeaderSizeChange(net::CacheType cache_type, int old_size, int new_size) { HeaderSizeChange size_change; @@ -200,7 +200,7 @@ SimpleEntryImpl::SimpleEntryImpl(net::CacheType cache_type, } void SimpleEntryImpl::SetActiveEntryProxy( - scoped_ptr<ActiveEntryProxy> active_entry_proxy) { + std::unique_ptr<ActiveEntryProxy> active_entry_proxy) { DCHECK(!active_entry_proxy_); active_entry_proxy_.reset(active_entry_proxy.release()); } @@ -521,7 +521,7 @@ int SimpleEntryImpl::GetAvailableRange(int64_t offset, bool SimpleEntryImpl::CouldBeSparse() const { DCHECK(io_thread_checker_.CalledOnValidThread()); - // TODO(ttuttle): Actually check. + // TODO(juliatuttle): Actually check. return true; } @@ -600,7 +600,7 @@ void SimpleEntryImpl::RunNextOperationIfNeeded() { "EntryOperationsPending", cache_type_, pending_operations_.size(), 0, 100, 20); if (!pending_operations_.empty() && state_ != STATE_IO_PENDING) { - scoped_ptr<SimpleEntryOperation> operation( + std::unique_ptr<SimpleEntryOperation> operation( new SimpleEntryOperation(pending_operations_.front())); pending_operations_.pop(); switch (operation->type()) { @@ -693,23 +693,16 @@ void SimpleEntryImpl::OpenEntryInternal(bool have_index, DCHECK(!synchronous_entry_); state_ = STATE_IO_PENDING; const base::TimeTicks start_time = base::TimeTicks::Now(); - scoped_ptr<SimpleEntryCreationResults> results( - new SimpleEntryCreationResults( - SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_))); - Closure task = base::Bind(&SimpleSynchronousEntry::OpenEntry, - cache_type_, - path_, - entry_hash_, - have_index, - results.get()); - Closure reply = base::Bind(&SimpleEntryImpl::CreationOperationComplete, - this, - callback, - start_time, - base::Passed(&results), - out_entry, - net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END); + std::unique_ptr<SimpleEntryCreationResults> results( + new SimpleEntryCreationResults(SimpleEntryStat( + last_used_, last_modified_, data_size_, sparse_data_size_))); + Closure task = + base::Bind(&SimpleSynchronousEntry::OpenEntry, cache_type_, path_, key_, + entry_hash_, have_index, results.get()); + Closure reply = + base::Bind(&SimpleEntryImpl::CreationOperationComplete, this, callback, + start_time, base::Passed(&results), out_entry, + net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END); worker_pool_->PostTaskAndReply(FROM_HERE, task, reply); } @@ -742,10 +735,9 @@ void SimpleEntryImpl::CreateEntryInternal(bool have_index, have_written_[i] = true; const base::TimeTicks start_time = base::TimeTicks::Now(); - scoped_ptr<SimpleEntryCreationResults> results( - new SimpleEntryCreationResults( - SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_))); + std::unique_ptr<SimpleEntryCreationResults> results( + new SimpleEntryCreationResults(SimpleEntryStat( + last_used_, last_modified_, data_size_, sparse_data_size_))); Closure task = base::Bind(&SimpleSynchronousEntry::CreateEntry, cache_type_, path_, @@ -766,8 +758,8 @@ void SimpleEntryImpl::CreateEntryInternal(bool have_index, void SimpleEntryImpl::CloseInternal() { DCHECK(io_thread_checker_.CalledOnValidThread()); typedef SimpleSynchronousEntry::CRCRecord CRCRecord; - scoped_ptr<std::vector<CRCRecord> > - crc32s_to_write(new std::vector<CRCRecord>()); + std::unique_ptr<std::vector<CRCRecord>> crc32s_to_write( + new std::vector<CRCRecord>()); net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CLOSE_BEGIN); @@ -868,11 +860,10 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index, if (!doomed_ && backend_.get()) backend_->index()->UseIfExists(entry_hash_); - scoped_ptr<uint32_t> read_crc32(new uint32_t()); - scoped_ptr<int> result(new int()); - scoped_ptr<SimpleEntryStat> entry_stat( - new SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_)); + std::unique_ptr<uint32_t> read_crc32(new uint32_t()); + std::unique_ptr<int> result(new int()); + std::unique_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( + last_used_, last_modified_, data_size_, sparse_data_size_)); Closure task = base::Bind( &SimpleSynchronousEntry::ReadData, base::Unretained(synchronous_entry_), SimpleSynchronousEntry::EntryOperationData(stream_index, offset, buf_len), @@ -950,9 +941,8 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, AdvanceCrc(buf, offset, buf_len, stream_index); // |entry_stat| needs to be initialized before modifying |data_size_|. - scoped_ptr<SimpleEntryStat> entry_stat( - new SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_)); + std::unique_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( + last_used_, last_modified_, data_size_, sparse_data_size_)); if (truncate) { data_size_[stream_index] = offset + buf_len; } else { @@ -970,7 +960,7 @@ void SimpleEntryImpl::WriteDataInternal(int stream_index, if (stream_index == 1) have_written_[0] = true; - scoped_ptr<int> result(new int()); + std::unique_ptr<int> result(new int()); Closure task = base::Bind( &SimpleSynchronousEntry::WriteData, base::Unretained(synchronous_entry_), SimpleSynchronousEntry::EntryOperationData(stream_index, offset, buf_len, @@ -1002,8 +992,8 @@ void SimpleEntryImpl::ReadSparseDataInternal( DCHECK_EQ(STATE_READY, state_); state_ = STATE_IO_PENDING; - scoped_ptr<int> result(new int()); - scoped_ptr<base::Time> last_used(new base::Time()); + std::unique_ptr<int> result(new int()); + std::unique_ptr<base::Time> last_used(new base::Time()); Closure task = base::Bind( &SimpleSynchronousEntry::ReadSparseData, base::Unretained(synchronous_entry_), @@ -1040,13 +1030,12 @@ void SimpleEntryImpl::WriteSparseDataInternal( max_sparse_data_size = max_cache_size / kMaxSparseDataSizeDivisor; } - scoped_ptr<SimpleEntryStat> entry_stat( - new SimpleEntryStat(last_used_, last_modified_, data_size_, - sparse_data_size_)); + std::unique_ptr<SimpleEntryStat> entry_stat(new SimpleEntryStat( + last_used_, last_modified_, data_size_, sparse_data_size_)); last_used_ = last_modified_ = base::Time::Now(); - scoped_ptr<int> result(new int()); + std::unique_ptr<int> result(new int()); Closure task = base::Bind( &SimpleSynchronousEntry::WriteSparseData, base::Unretained(synchronous_entry_), @@ -1072,7 +1061,7 @@ void SimpleEntryImpl::GetAvailableRangeInternal( DCHECK_EQ(STATE_READY, state_); state_ = STATE_IO_PENDING; - scoped_ptr<int> result(new int()); + std::unique_ptr<int> result(new int()); Closure task = base::Bind(&SimpleSynchronousEntry::GetAvailableRange, base::Unretained(synchronous_entry_), SimpleSynchronousEntry::EntryOperationData( @@ -1119,7 +1108,7 @@ void SimpleEntryImpl::DoomEntryInternal(const CompletionCallback& callback) { void SimpleEntryImpl::CreationOperationComplete( const CompletionCallback& completion_callback, const base::TimeTicks& start_time, - scoped_ptr<SimpleEntryCreationResults> in_results, + std::unique_ptr<SimpleEntryCreationResults> in_results, Entry** out_entry, net::NetLog::EventType end_event_type) { DCHECK(io_thread_checker_.CalledOnValidThread()); @@ -1152,11 +1141,14 @@ void SimpleEntryImpl::CreationOperationComplete( crc32s_[0] = in_results->stream_0_crc32; crc32s_end_offset_[0] = in_results->entry_stat.data_size(0); } + // If this entry was opened by hash, key_ could still be empty. If so, update + // it with the key read from the synchronous entry. if (key_.empty()) { SetKey(synchronous_entry_->key()); } else { - // This should only be triggered when creating an entry. The key check in - // the open case is handled in SimpleBackendImpl. + // This should only be triggered when creating an entry. In the open case + // the key is either copied from the arguments to open, or checked + // in the synchronous entry. DCHECK_EQ(key_, synchronous_entry_->key()); } UpdateDataFromEntryStat(in_results->entry_stat); @@ -1172,7 +1164,7 @@ void SimpleEntryImpl::CreationOperationComplete( void SimpleEntryImpl::EntryOperationComplete( const CompletionCallback& completion_callback, const SimpleEntryStat& entry_stat, - scoped_ptr<int> result) { + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK_EQ(STATE_IO_PENDING, state_); @@ -1196,9 +1188,9 @@ void SimpleEntryImpl::ReadOperationComplete( int stream_index, int offset, const CompletionCallback& completion_callback, - scoped_ptr<uint32_t> read_crc32, - scoped_ptr<SimpleEntryStat> entry_stat, - scoped_ptr<int> result) { + std::unique_ptr<uint32_t> read_crc32, + std::unique_ptr<SimpleEntryStat> entry_stat, + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK_EQ(STATE_IO_PENDING, state_); @@ -1224,7 +1216,7 @@ void SimpleEntryImpl::ReadOperationComplete( net_log_.AddEvent(net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_CHECKSUM_BEGIN); - scoped_ptr<int> new_result(new int()); + std::unique_ptr<int> new_result(new int()); Closure task = base::Bind(&SimpleSynchronousEntry::CheckEOFRecord, base::Unretained(synchronous_entry_), stream_index, @@ -1266,8 +1258,8 @@ void SimpleEntryImpl::ReadOperationComplete( void SimpleEntryImpl::WriteOperationComplete( int stream_index, const CompletionCallback& completion_callback, - scoped_ptr<SimpleEntryStat> entry_stat, - scoped_ptr<int> result) { + std::unique_ptr<SimpleEntryStat> entry_stat, + std::unique_ptr<int> result) { if (*result >= 0) RecordWriteResult(cache_type_, WRITE_RESULT_SUCCESS); else @@ -1286,8 +1278,8 @@ void SimpleEntryImpl::WriteOperationComplete( void SimpleEntryImpl::ReadSparseOperationComplete( const CompletionCallback& completion_callback, - scoped_ptr<base::Time> last_used, - scoped_ptr<int> result) { + std::unique_ptr<base::Time> last_used, + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK(result); @@ -1304,8 +1296,8 @@ void SimpleEntryImpl::ReadSparseOperationComplete( void SimpleEntryImpl::WriteSparseOperationComplete( const CompletionCallback& completion_callback, - scoped_ptr<SimpleEntryStat> entry_stat, - scoped_ptr<int> result) { + std::unique_ptr<SimpleEntryStat> entry_stat, + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK(result); @@ -1320,7 +1312,7 @@ void SimpleEntryImpl::WriteSparseOperationComplete( void SimpleEntryImpl::GetAvailableRangeOperationComplete( const CompletionCallback& completion_callback, - scoped_ptr<int> result) { + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK(result); @@ -1346,7 +1338,7 @@ void SimpleEntryImpl::ChecksumOperationComplete( int orig_result, int stream_index, const CompletionCallback& completion_callback, - scoped_ptr<int> result) { + std::unique_ptr<int> result) { DCHECK(io_thread_checker_.CalledOnValidThread()); DCHECK(synchronous_entry_); DCHECK_EQ(STATE_IO_PENDING, state_); @@ -1408,7 +1400,7 @@ int64_t SimpleEntryImpl::GetDiskUsage() const { int64_t file_size = 0; for (int i = 0; i < kSimpleEntryStreamCount; ++i) { file_size += - simple_util::GetFileSizeFromKeyAndDataSize(key_, data_size_[i]); + simple_util::GetFileSizeFromDataSize(key_.size(), data_size_[i]); } file_size += sparse_data_size_; return file_size; |