diff options
author | tbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 02:13:24 +0000 |
---|---|---|
committer | tbreisacher@chromium.org <tbreisacher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-23 02:13:24 +0000 |
commit | a6e13778ee793a89b0df5a3066004ad6c4332d42 (patch) | |
tree | 4e4499e800a8d4aa7811171d7926844cebd2957f /net | |
parent | a04da4a5984c5d7f9044708f16dbcf6e3316425a (diff) | |
download | chromium_src-a6e13778ee793a89b0df5a3066004ad6c4332d42.zip chromium_src-a6e13778ee793a89b0df5a3066004ad6c4332d42.tar.gz chromium_src-a6e13778ee793a89b0df5a3066004ad6c4332d42.tar.bz2 |
base::Bind(): stress_cache.cc
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/8962037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/stress_cache.cc | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc index 1a394c1..b24aaa2 100644 --- a/net/disk_cache/stress_cache.cc +++ b/net/disk_cache/stress_cache.cc @@ -18,6 +18,7 @@ #include <vector> #include "base/at_exit.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/debug/debugger.h" #include "base/file_path.h" @@ -183,37 +184,32 @@ void StressTheCache(int iteration) { // waiting for the debugger to attach. bool g_crashing = false; -class CrashTask : public Task { - public: - CrashTask() {} - ~CrashTask() {} +void RunSoon(MessageLoop* target_loop); - virtual void Run() { - // Keep trying to run. - RunSoon(MessageLoop::current()); +void Crash() { + // Keep trying to run. + RunSoon(MessageLoop::current()); - if (g_crashing) - return; + if (g_crashing) + return; - if (rand() % 100 > 30) { - printf("sweet death...\n"); + if (rand() % 100 > 30) { + printf("sweet death...\n"); #if defined(OS_WIN) - // Windows does more work on _exit() that we would like, so we use Kill. - base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); + // Windows does more work on _exit() that we would like, so we use Kill. + base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); #elif defined(OS_POSIX) - // On POSIX, _exit() will terminate the process with minimal cleanup, - // and it is cleaner than killing. - _exit(kExpectedCrash); + // On POSIX, _exit() will terminate the process with minimal cleanup, + // and it is cleaner than killing. + _exit(kExpectedCrash); #endif - } } +} - static void RunSoon(MessageLoop* target_loop) { - int task_delay = 10000; // 10 seconds - CrashTask* task = new CrashTask(); - target_loop->PostDelayedTask(FROM_HERE, task, task_delay); - } -}; +void RunSoon(MessageLoop* target_loop) { + int task_delay = 10000; // 10 seconds + target_loop->PostDelayedTask(FROM_HERE, base::Bind(&Crash), task_delay); +} // We leak everything here :) bool StartCrashThread() { @@ -221,7 +217,7 @@ bool StartCrashThread() { if (!thread->Start()) return false; - CrashTask::RunSoon(thread->message_loop()); + RunSoon(thread->message_loop()); return true; } |