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

Side by Side Diff: net/disk_cache/backend_impl.cc

Issue 2854053: Disk cache: Stop evictions while performing final cleanup.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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/backend_impl.h" 5 #include "net/disk_cache/backend_impl.h"
6 6
7 #include "base/field_trial.h" 7 #include "base/field_trial.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 explicit FinalCleanup(disk_cache::BackendImpl* backend) : backend_(backend) {} 252 explicit FinalCleanup(disk_cache::BackendImpl* backend) : backend_(backend) {}
253 ~FinalCleanup() {} 253 ~FinalCleanup() {}
254 254
255 virtual void Run(); 255 virtual void Run();
256 private: 256 private:
257 disk_cache::BackendImpl* backend_; 257 disk_cache::BackendImpl* backend_;
258 DISALLOW_EVIL_CONSTRUCTORS(FinalCleanup); 258 DISALLOW_EVIL_CONSTRUCTORS(FinalCleanup);
259 }; 259 };
260 260
261 void FinalCleanup::Run() { 261 void FinalCleanup::Run() {
262 backend_->CleanupCache(); 262 backend_->StartCleanup();
263 } 263 }
264 264
265 } // namespace 265 } // namespace
266 266
267 // ------------------------------------------------------------------------ 267 // ------------------------------------------------------------------------
268 268
269 namespace disk_cache { 269 namespace disk_cache {
270 270
271 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, 271 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes,
272 bool force, base::MessageLoopProxy* thread, 272 bool force, base::MessageLoopProxy* thread,
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 disabled_ = !rankings_.Init(this, new_eviction_); 518 disabled_ = !rankings_.Init(this, new_eviction_);
519 eviction_.Init(this); 519 eviction_.Init(this);
520 520
521 // Setup load-time data only for the main cache. 521 // Setup load-time data only for the main cache.
522 if (cache_type() == net::DISK_CACHE) 522 if (cache_type() == net::DISK_CACHE)
523 SetFieldTrialInfo(GetSizeGroup()); 523 SetFieldTrialInfo(GetSizeGroup());
524 524
525 return disabled_ ? net::ERR_FAILED : net::OK; 525 return disabled_ ? net::ERR_FAILED : net::OK;
526 } 526 }
527 527
528 void BackendImpl::StartCleanup() {
529 Trace("Backend StartCleanup");
530 eviction_.Stop();
531
532 // Give a chance for any posted evictions to be discarded.
533 MessageLoop::current()->PostTask(FROM_HERE,
534 factory_.NewRunnableMethod(&BackendImpl::CleanupCache));
535 }
536
528 void BackendImpl::CleanupCache() { 537 void BackendImpl::CleanupCache() {
529 Trace("Backend Cleanup"); 538 Trace("Backend Cleanup");
530 if (init_) { 539 if (init_) {
531 if (data_) 540 if (data_)
532 data_->header.crash = 0; 541 data_->header.crash = 0;
533 542
534 timer_.Stop(); 543 timer_.Stop();
535 File::WaitForPendingIO(&num_pending_io_); 544 File::WaitForPendingIO(&num_pending_io_);
536 DCHECK(!num_refs_); 545 DCHECK(!num_refs_);
537 } 546 }
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1865
1857 return num_dirty; 1866 return num_dirty;
1858 } 1867 }
1859 1868
1860 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { 1869 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) {
1861 RankingsNode* rankings = cache_entry->rankings()->Data(); 1870 RankingsNode* rankings = cache_entry->rankings()->Data();
1862 return !rankings->dummy; 1871 return !rankings->dummy;
1863 } 1872 }
1864 1873
1865 } // namespace disk_cache 1874 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698