diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-29 16:35:13 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-02-01 15:33:35 +0000 |
commit | c8c2d1901aec01e934adf561a9fdf0cc776cdef8 (patch) | |
tree | 9157c3d9815e5870799e070b113813bec53e0535 /chromium/net/disk_cache/simple/simple_entry_impl.cc | |
parent | abefd5095b41dac94ca451d784ab6e27372e981a (diff) | |
download | qtwebengine-chromium-c8c2d1901aec01e934adf561a9fdf0cc776cdef8.tar.gz |
BASELINE: Update Chromium to 64.0.3282.139
Change-Id: I1cae68fe9c94ff7608b26b8382fc19862cdb293a
Reviewed-by: Alexandru Croitor <alexandru.croitor@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 | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.cc b/chromium/net/disk_cache/simple/simple_entry_impl.cc index 29c07251391..7123aac04ab 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.cc +++ b/chromium/net/disk_cache/simple/simple_entry_impl.cc @@ -74,7 +74,7 @@ void RecordWriteResult(net::CacheType cache_type, WriteResult result) { "WriteResult2", cache_type, result, WRITE_RESULT_MAX); } -// TODO(juliatuttle): Consider removing this once we have a good handle on +// TODO(morlovich): 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) { @@ -176,7 +176,7 @@ class SimpleEntryImpl::ScopedOperationRunner { SimpleEntryImpl* const entry_; }; -SimpleEntryImpl::ActiveEntryProxy::~ActiveEntryProxy() {} +SimpleEntryImpl::ActiveEntryProxy::~ActiveEntryProxy() = default; SimpleEntryImpl::SimpleEntryImpl( net::CacheType cache_type, @@ -185,9 +185,11 @@ SimpleEntryImpl::SimpleEntryImpl( const uint64_t entry_hash, OperationsMode operations_mode, SimpleBackendImpl* backend, + SimpleFileTracker* file_tracker, net::NetLog* net_log) : cleanup_tracker_(std::move(cleanup_tracker)), backend_(backend->AsWeakPtr()), + file_tracker_(file_tracker), cache_type_(cache_type), worker_pool_(backend->worker_pool()), path_(path), @@ -199,6 +201,7 @@ SimpleEntryImpl::SimpleEntryImpl( sparse_data_size_(0), open_count_(0), doomed_(false), + optimistic_create_pending_doom_state_(CREATE_NORMAL), state_(STATE_UNINITIALIZED), synchronous_entry_(NULL), net_log_( @@ -280,6 +283,14 @@ int SimpleEntryImpl::CreateEntry(Entry** out_entry, pending_operations_.push(SimpleEntryOperation::CreateOperation( this, have_index, CompletionCallback(), static_cast<Entry**>(NULL))); ret_value = net::OK; + + // If we are optimistically returning before a preceeding doom, we need to + // wait for that IO, about which we will be notified externally. + if (optimistic_create_pending_doom_state_ != CREATE_NORMAL) { + DCHECK_EQ(CREATE_OPTIMISTIC_PENDING_DOOM, + optimistic_create_pending_doom_state_); + state_ = STATE_IO_PENDING; + } } else { pending_operations_.push(SimpleEntryOperation::CreateOperation( this, have_index, callback, out_entry)); @@ -304,13 +315,48 @@ int SimpleEntryImpl::DoomEntry(const CompletionCallback& callback) { net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_DOOM_BEGIN); MarkAsDoomed(); - if (backend_.get()) - backend_->OnDoomStart(entry_hash_); + if (backend_.get()) { + if (optimistic_create_pending_doom_state_ == CREATE_NORMAL) { + backend_->OnDoomStart(entry_hash_); + } else { + DCHECK_EQ(STATE_IO_PENDING, state_); + DCHECK_EQ(CREATE_OPTIMISTIC_PENDING_DOOM, + optimistic_create_pending_doom_state_); + // If we are in this state, we went ahead with making the entry even + // though the backend was already keeping track of a doom, so it can't + // keep track of ours. So we delay notifying it until + // NotifyDoomBeforeCreateComplete is called. Since this path is invoked + // only when the queue of post-doom callbacks was previously empty, while + // the CompletionCallback for the op is posted, + // NotifyDoomBeforeCreateComplete() will be the first thing running after + // the previous doom completes, so at that point we can immediately grab + // a spot in entries_pending_doom_. + optimistic_create_pending_doom_state_ = + CREATE_OPTIMISTIC_PENDING_DOOM_FOLLOWED_BY_DOOM; + } + } pending_operations_.push(SimpleEntryOperation::DoomOperation(this, callback)); RunNextOperationIfNeeded(); return net::ERR_IO_PENDING; } +void SimpleEntryImpl::SetCreatePendingDoom() { + DCHECK_EQ(CREATE_NORMAL, optimistic_create_pending_doom_state_); + optimistic_create_pending_doom_state_ = CREATE_OPTIMISTIC_PENDING_DOOM; +} + +void SimpleEntryImpl::NotifyDoomBeforeCreateComplete() { + DCHECK_EQ(STATE_IO_PENDING, state_); + DCHECK_NE(CREATE_NORMAL, optimistic_create_pending_doom_state_); + if (backend_.get() && optimistic_create_pending_doom_state_ == + CREATE_OPTIMISTIC_PENDING_DOOM_FOLLOWED_BY_DOOM) + backend_->OnDoomStart(entry_hash_); + + state_ = STATE_UNINITIALIZED; + optimistic_create_pending_doom_state_ = CREATE_NORMAL; + RunNextOperationIfNeeded(); +} + void SimpleEntryImpl::SetKey(const std::string& key) { key_ = key; net_log_.AddEvent(net::NetLogEventType::SIMPLE_CACHE_ENTRY_SET_KEY, @@ -458,7 +504,7 @@ int SimpleEntryImpl::WriteData(int stream_index, op_callback = callback; ret_value = net::ERR_IO_PENDING; } else { - // TODO(gavinp,pasko): For performance, don't use a copy of an IOBuffer + // TODO(morlovich,pasko): For performance, don't use a copy of an IOBuffer // here to avoid paying the price of the RefCountedThreadSafe atomic // operations. if (buf) { @@ -534,7 +580,7 @@ int SimpleEntryImpl::GetAvailableRange(int64_t offset, bool SimpleEntryImpl::CouldBeSparse() const { DCHECK(io_thread_checker_.CalledOnValidThread()); - // TODO(juliatuttle): Actually check. + // TODO(morlovich): Actually check. return true; } @@ -716,9 +762,9 @@ void SimpleEntryImpl::OpenEntryInternal(bool have_index, 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, start_time, results.get()); + Closure task = base::Bind(&SimpleSynchronousEntry::OpenEntry, cache_type_, + path_, key_, entry_hash_, have_index, start_time, + file_tracker_, results.get()); Closure reply = base::Bind(&SimpleEntryImpl::CreationOperationComplete, this, callback, start_time, base::Passed(&results), out_entry, @@ -758,9 +804,9 @@ void SimpleEntryImpl::CreateEntryInternal(bool have_index, 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_, key_, - entry_hash_, have_index, start_time, results.get()); + Closure task = base::Bind(&SimpleSynchronousEntry::CreateEntry, cache_type_, + path_, key_, entry_hash_, have_index, start_time, + file_tracker_, results.get()); Closure reply = base::Bind(&SimpleEntryImpl::CreationOperationComplete, this, callback, start_time, base::Passed(&results), out_entry, |