diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 21:29:21 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 21:29:21 +0000 |
commit | 3f50ec4bb2a006f9285053b3877a7b9cd634da0a (patch) | |
tree | 38f28684bc24c9062dd81ff86a1d8b7ea9b08593 /net/disk_cache | |
parent | 4a225032c9eef31b2afbd36249f7ca949095b08e (diff) | |
download | chromium_src-3f50ec4bb2a006f9285053b3877a7b9cd634da0a.zip chromium_src-3f50ec4bb2a006f9285053b3877a7b9cd634da0a.tar.gz chromium_src-3f50ec4bb2a006f9285053b3877a7b9cd634da0a.tar.bz2 |
base::Bind: Random remaining cleanups.
BUG=none
TEST=none
R=groby,csilv,ajwong
Review URL: http://codereview.chromium.org/9035012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 22 | ||||
-rw-r--r-- | net/disk_cache/stress_cache.cc | 8 |
2 files changed, 10 insertions, 20 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index c86d9a8..a014c5a 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -87,23 +87,10 @@ FilePath GetPrefixedName(const FilePath& path, const std::string& name, return path.AppendASCII(tmp); } -// This is a simple Task to cleanup old caches. -class CleanupTask : public Task { - public: - CleanupTask(const FilePath& path, const std::string& name) - : path_(path), name_(name) {} - - virtual void Run(); - - private: - FilePath path_; - std::string name_; - DISALLOW_COPY_AND_ASSIGN(CleanupTask); -}; - -void CleanupTask::Run() { +// This is a simple callback to cleanup old caches. +void CleanupCallback(const FilePath& path, const std::string& name) { for (int i = 0; i < kMaxOldFolders; i++) { - FilePath to_delete = GetPrefixedName(path_, name_, i); + FilePath to_delete = GetPrefixedName(path, name, i); disk_cache::DeleteCache(to_delete, true); } } @@ -148,7 +135,8 @@ bool DelayedCacheCleanup(const FilePath& full_path) { return false; } - base::WorkerPool::PostTask(FROM_HERE, new CleanupTask(path, name_str), true); + base::WorkerPool::PostTask( + FROM_HERE, base::Bind(&CleanupCallback, path, name_str), true); return true; } diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc index b24aaa2..40a0143 100644 --- a/net/disk_cache/stress_cache.cc +++ b/net/disk_cache/stress_cache.cc @@ -184,9 +184,10 @@ void StressTheCache(int iteration) { // waiting for the debugger to attach. bool g_crashing = false; +// RunSoon() and CrashCallback() reference each other, unfortunately. void RunSoon(MessageLoop* target_loop); -void Crash() { +void CrashCallback() { // Keep trying to run. RunSoon(MessageLoop::current()); @@ -207,8 +208,9 @@ void Crash() { } void RunSoon(MessageLoop* target_loop) { - int task_delay = 10000; // 10 seconds - target_loop->PostDelayedTask(FROM_HERE, base::Bind(&Crash), task_delay); + const int kTaskDelay = 10000; // 10 seconds + target_loop->PostDelayedTask( + FROM_HERE, base::Bind(&CrashCallback), kTaskDelay); } // We leak everything here :) |