From d17ea114e5ef69ad5d5d7413280a13e6428098aa Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 15 May 2018 10:20:33 +0200 Subject: BASELINE: Update Chromium to 67.0.3396.47 Change-Id: Idcb1341782e417561a2473eeecc82642dafda5b7 Reviewed-by: Michal Klocek --- chromium/net/disk_cache/blockfile/entry_impl.cc | 4 ++++ chromium/net/disk_cache/blockfile/entry_impl.h | 1 + chromium/net/disk_cache/blockfile/file_win.cc | 13 +++++++------ chromium/net/disk_cache/blockfile/mapped_file.h | 2 +- chromium/net/disk_cache/disk_cache.h | 11 ++++++++++- chromium/net/disk_cache/entry_unittest.cc | 9 --------- chromium/net/disk_cache/memory/mem_entry_impl.cc | 4 ++++ chromium/net/disk_cache/memory/mem_entry_impl.h | 1 + chromium/net/disk_cache/simple/simple_entry_impl.cc | 7 +++++++ chromium/net/disk_cache/simple/simple_entry_impl.h | 1 + chromium/net/disk_cache/simple/simple_index.cc | 7 +++++++ chromium/net/disk_cache/simple/simple_index.h | 2 ++ 12 files changed, 45 insertions(+), 17 deletions(-) (limited to 'chromium/net/disk_cache') diff --git a/chromium/net/disk_cache/blockfile/entry_impl.cc b/chromium/net/disk_cache/blockfile/entry_impl.cc index 16e49b9787e..489b2ccc8e9 100644 --- a/chromium/net/disk_cache/blockfile/entry_impl.cc +++ b/chromium/net/disk_cache/blockfile/entry_impl.cc @@ -925,6 +925,10 @@ int EntryImpl::ReadyForSparseIO(const CompletionCallback& callback) { return net::ERR_IO_PENDING; } +void EntryImpl::SetLastUsedTimeForTest(base::Time time) { + SetTimes(time, time); +} + // When an entry is deleted from the cache, we clean up all the data associated // with it for two reasons: to simplify the reuse of the block (we know that any // unused block is filled with zeros), and to simplify the handling of write / diff --git a/chromium/net/disk_cache/blockfile/entry_impl.h b/chromium/net/disk_cache/blockfile/entry_impl.h index f3f63cf5d76..a7c8d7cc1b8 100644 --- a/chromium/net/disk_cache/blockfile/entry_impl.h +++ b/chromium/net/disk_cache/blockfile/entry_impl.h @@ -193,6 +193,7 @@ class NET_EXPORT_PRIVATE EntryImpl bool CouldBeSparse() const override; void CancelSparseIO() override; int ReadyForSparseIO(const CompletionCallback& callback) override; + void SetLastUsedTimeForTest(base::Time time) override; private: enum { diff --git a/chromium/net/disk_cache/blockfile/file_win.cc b/chromium/net/disk_cache/blockfile/file_win.cc index e2ea893a219..036d2ce6d7a 100644 --- a/chromium/net/disk_cache/blockfile/file_win.cc +++ b/chromium/net/disk_cache/blockfile/file_win.cc @@ -10,6 +10,7 @@ #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/message_loop/message_loop.h" +#include "base/message_loop/message_pump_for_io.h" #include "net/base/net_errors.h" #include "net/disk_cache/disk_cache.h" @@ -25,7 +26,7 @@ struct MyOverlapped { return &context_.overlapped; } - base::MessageLoopForIO::IOContext context_; + base::MessagePumpForIO::IOContext context_; scoped_refptr file_; scoped_refptr completion_handler_; disk_cache::FileIOCallback* callback_; @@ -35,7 +36,7 @@ static_assert(offsetof(MyOverlapped, context_) == 0, "should start with overlapped"); // Helper class to handle the IO completion notifications from the message loop. -class CompletionHandler : public base::MessageLoopForIO::IOHandler, +class CompletionHandler : public base::MessagePumpForIO::IOHandler, public base::RefCounted { public: CompletionHandler() = default; @@ -45,8 +46,8 @@ class CompletionHandler : public base::MessageLoopForIO::IOHandler, friend class base::RefCounted; ~CompletionHandler() override {} - // implement base::MessageLoopForIO::IOHandler. - void OnIOCompleted(base::MessageLoopForIO::IOContext* context, + // implement base::MessagePumpForIO::IOHandler. + void OnIOCompleted(base::MessagePumpForIO::IOContext* context, DWORD actual_bytes, DWORD error) override; @@ -74,7 +75,7 @@ CompletionHandler* CompletionHandler::Get() { } void CompletionHandler::OnIOCompleted( - base::MessageLoopForIO::IOContext* context, + base::MessagePumpForIO::IOContext* context, DWORD actual_bytes, DWORD error) { MyOverlapped* data = reinterpret_cast(context); @@ -276,7 +277,7 @@ void File::WaitForPendingIO(int* num_pending_io) { while (*num_pending_io) { // Asynchronous IO operations may be in flight and the completion may end // up calling us back so let's wait for them. - base::MessageLoopForIO::IOHandler* handler = CompletionHandler::Get(); + base::MessagePumpForIO::IOHandler* handler = CompletionHandler::Get(); base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); } } diff --git a/chromium/net/disk_cache/blockfile/mapped_file.h b/chromium/net/disk_cache/blockfile/mapped_file.h index 21dd0c7c9ea..3e36c79825a 100644 --- a/chromium/net/disk_cache/blockfile/mapped_file.h +++ b/chromium/net/disk_cache/blockfile/mapped_file.h @@ -13,7 +13,7 @@ #include "net/base/net_export.h" #include "net/disk_cache/blockfile/file.h" #include "net/disk_cache/blockfile/file_block.h" -#include "net/net_features.h" +#include "net/net_buildflags.h" namespace base { class FilePath; diff --git a/chromium/net/disk_cache/disk_cache.h b/chromium/net/disk_cache/disk_cache.h index 756a04a3286..c8461f578e9 100644 --- a/chromium/net/disk_cache/disk_cache.h +++ b/chromium/net/disk_cache/disk_cache.h @@ -122,7 +122,11 @@ class NET_EXPORT Backend { // operations so the callbacks are not invoked, possibly leaving the work // half way (for instance, dooming just a few entries). Note that pending IO // for a given Entry (as opposed to the Backend) will still generate a - // callback from within this method. + // callback. + // Warning: there is some inconsistency in details between different backends + // on what will succeed and what will fail. In particular the blockfile + // backend will leak entries closed after backend deletion, while others + // handle it properly. virtual ~Backend() {} // Returns the type of this cache. @@ -382,6 +386,11 @@ class NET_EXPORT Entry { // Note: This method is deprecated. virtual int ReadyForSparseIO(const CompletionCallback& callback) = 0; + // Used in tests to set the last used time. Note that backend might have + // limited precision. Also note that this call may modify the last modified + // time. + virtual void SetLastUsedTimeForTest(base::Time time) = 0; + protected: virtual ~Entry() {} }; diff --git a/chromium/net/disk_cache/entry_unittest.cc b/chromium/net/disk_cache/entry_unittest.cc index 374a9816ff7..1bcc96fd57c 100644 --- a/chromium/net/disk_cache/entry_unittest.cc +++ b/chromium/net/disk_cache/entry_unittest.cc @@ -4883,15 +4883,6 @@ TEST_F(DiskCacheEntryTest, SimpleCacheChecksumpScrewUp) { entry->Close(); } -// TODO(morlovich): There seems to be an imperfection of leak detection, see -// https://crbug.com/811276. Please reenable this test when the bug is fixed. -TEST_F(DiskCacheEntryTest, DISABLED_UseAfterBackendDestruction) { - // InitCache uses the kNoRandom flag that check-fails on the tested scenario. - CreateBackend(0); - DisableIntegrityCheck(); - UseAfterBackendDestruction(); -} - TEST_F(DiskCacheEntryTest, SimpleUseAfterBackendDestruction) { SetSimpleCacheMode(); InitCache(); diff --git a/chromium/net/disk_cache/memory/mem_entry_impl.cc b/chromium/net/disk_cache/memory/mem_entry_impl.cc index 177416883d2..4026bd10a52 100644 --- a/chromium/net/disk_cache/memory/mem_entry_impl.cc +++ b/chromium/net/disk_cache/memory/mem_entry_impl.cc @@ -272,6 +272,10 @@ int MemEntryImpl::ReadyForSparseIO(const CompletionCallback& callback) { return net::OK; } +void MemEntryImpl::SetLastUsedTimeForTest(base::Time time) { + last_used_ = time; +} + size_t MemEntryImpl::EstimateMemoryUsage() const { // Subtlety: the entries in children_ are not double counted, as the entry // pointers won't be followed by EstimateMemoryUsage. diff --git a/chromium/net/disk_cache/memory/mem_entry_impl.h b/chromium/net/disk_cache/memory/mem_entry_impl.h index 728bec0e2e4..d500ea9e37d 100644 --- a/chromium/net/disk_cache/memory/mem_entry_impl.h +++ b/chromium/net/disk_cache/memory/mem_entry_impl.h @@ -133,6 +133,7 @@ class NET_EXPORT_PRIVATE MemEntryImpl final bool CouldBeSparse() const override; void CancelSparseIO() override {} int ReadyForSparseIO(const CompletionCallback& callback) override; + void SetLastUsedTimeForTest(base::Time time) override; size_t EstimateMemoryUsage() const; private: diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.cc b/chromium/net/disk_cache/simple/simple_entry_impl.cc index 147350d3714..594e50f6180 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.cc +++ b/chromium/net/disk_cache/simple/simple_entry_impl.cc @@ -599,6 +599,13 @@ int SimpleEntryImpl::ReadyForSparseIO(const CompletionCallback& callback) { return net::OK; } +void SimpleEntryImpl::SetLastUsedTimeForTest(base::Time time) { + // Note that we do not update |last_used_| here as it gets overwritten + // by UpdateDataFromEntryStat with the current time. It would be more involved + // to make that value stick and is not needed by the current tests. + backend_->index()->SetLastUsedTimeForTest(entry_hash_, time); +} + size_t SimpleEntryImpl::EstimateMemoryUsage() const { // TODO(xunjieli): crbug.com/669108. It'd be nice to have the rest of |entry| // measured, but the ownership of SimpleSynchronousEntry isn't straightforward diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.h b/chromium/net/disk_cache/simple/simple_entry_impl.h index 1f56b92c4df..6cae881d3cf 100644 --- a/chromium/net/disk_cache/simple/simple_entry_impl.h +++ b/chromium/net/disk_cache/simple/simple_entry_impl.h @@ -132,6 +132,7 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, bool CouldBeSparse() const override; void CancelSparseIO() override; int ReadyForSparseIO(const CompletionCallback& callback) override; + void SetLastUsedTimeForTest(base::Time time) override; // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; diff --git a/chromium/net/disk_cache/simple/simple_index.cc b/chromium/net/disk_cache/simple/simple_index.cc index 30cf9efc833..a891458d32c 100644 --- a/chromium/net/disk_cache/simple/simple_index.cc +++ b/chromium/net/disk_cache/simple/simple_index.cc @@ -278,6 +278,13 @@ size_t SimpleIndex::EstimateMemoryUsage() const { base::trace_event::EstimateMemoryUsage(removed_entries_); } +void SimpleIndex::SetLastUsedTimeForTest(uint64_t entry_hash, + const base::Time last_used) { + EntrySet::iterator it = entries_set_.find(entry_hash); + DCHECK(it != entries_set_.end()); + it->second.SetLastUsedTime(last_used); +} + void SimpleIndex::Insert(uint64_t entry_hash) { DCHECK(io_thread_checker_.CalledOnValidThread()); // Upon insert we don't know yet the size of the entry. diff --git a/chromium/net/disk_cache/simple/simple_index.h b/chromium/net/disk_cache/simple/simple_index.h index 426241e2777..0da8cd91888 100644 --- a/chromium/net/disk_cache/simple/simple_index.h +++ b/chromium/net/disk_cache/simple/simple_index.h @@ -192,6 +192,8 @@ class NET_EXPORT_PRIVATE SimpleIndex // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; + void SetLastUsedTimeForTest(uint64_t entry_hash, const base::Time last_used); + private: friend class SimpleIndexTest; FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, IndexSizeCorrectOnMerge); -- cgit v1.2.1