| Index: content/renderer/categorized_worker_pool.cc
|
| diff --git a/content/renderer/categorized_worker_pool.cc b/content/renderer/categorized_worker_pool.cc
|
| index 41814b4bcd324b2c0f2af1d20b45cc570a4afb35..5806284c0f1a40b423083f5b00acf9003e2acac1 100644
|
| --- a/content/renderer/categorized_worker_pool.cc
|
| +++ b/content/renderer/categorized_worker_pool.cc
|
| @@ -17,6 +17,8 @@
|
| namespace content {
|
| namespace {
|
|
|
| +constexpr int kHeartbeatIntervalInSeconds = 60; // 1 minute
|
| +
|
| // A thread which forwards to CategorizedWorkerPool::Run with the runnable
|
| // categories.
|
| class CategorizedWorkerPoolThread : public base::SimpleThread {
|
| @@ -239,12 +241,23 @@ void CategorizedWorkerPool::Run(
|
| break;
|
|
|
| // Wait for more tasks.
|
| - has_ready_to_run_tasks_cv->Wait();
|
| + WaitForMoreTasksWithLockAcquired(has_ready_to_run_tasks_cv);
|
| continue;
|
| }
|
| }
|
| }
|
|
|
| +void CategorizedWorkerPool::WaitForMoreTasksWithLockAcquired(
|
| + base::ConditionVariable* has_ready_to_run_tasks_cv) {
|
| + const base::TimeDelta timeout =
|
| + base::TimeDelta::FromSeconds(kHeartbeatIntervalInSeconds);
|
| + while (has_ready_to_run_tasks_cv->TimedWait(timeout)) {
|
| + TRACE_EVENT_INSTANT0(
|
| + "heartbeat", "CategorizedWorkerPool::HeartbeatDuringWaitForMoreTasks",
|
| + TRACE_EVENT_SCOPE_THREAD);
|
| + }
|
| +}
|
| +
|
| void CategorizedWorkerPool::FlushForTesting() {
|
| base::AutoLock lock(lock_);
|
|
|
|
|