summaryrefslogtreecommitdiffstats
path: root/extensions/common/one_shot_event.cc
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 18:28:07 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 18:28:07 +0000
commitb2a3c073b8b5c367e5ca9fa5b05dc59e2400f18a (patch)
tree2b98e48475f1f4a4ad2604c9d0e928b6fd39ce05 /extensions/common/one_shot_event.cc
parent5faf328f60b55df3b62a687ccf4b2660460679ae (diff)
downloadchromium_src-b2a3c073b8b5c367e5ca9fa5b05dc59e2400f18a.zip
chromium_src-b2a3c073b8b5c367e5ca9fa5b05dc59e2400f18a.tar.gz
chromium_src-b2a3c073b8b5c367e5ca9fa5b05dc59e2400f18a.tar.bz2
Remove ExtensionService Garbage-Collecting methods.
Make a new class, ExtensionGarbageCollector, which performs: - ExtensionService::GarbageCollectExtensions(), - extension_file_util::GarbageCollectExtensions() (the file-thread impl of ExtensionService::GarbageCollectExtensions()), - ExtensionService::GarbageCollectIsolatedStorage() BUG=351891 TBR=rkc@chromium.org (for c/b/chromeos/kiosk_mode - no functional changes, but the TODO has moved from ExtensionService to ExtensionGarbageCollector). Review URL: https://codereview.chromium.org/204983020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/one_shot_event.cc')
-rw-r--r--extensions/common/one_shot_event.cc45
1 files changed, 35 insertions, 10 deletions
diff --git a/extensions/common/one_shot_event.cc b/extensions/common/one_shot_event.cc
index 28f91cb..ebba0d1 100644
--- a/extensions/common/one_shot_event.cc
+++ b/extensions/common/one_shot_event.cc
@@ -5,9 +5,11 @@
#include "extensions/common/one_shot_event.h"
#include "base/callback.h"
+#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/task_runner.h"
+#include "base/time/time.h"
using base::TaskRunner;
@@ -17,13 +19,15 @@ struct OneShotEvent::TaskInfo {
TaskInfo() {}
TaskInfo(const tracked_objects::Location& from_here,
const scoped_refptr<TaskRunner>& runner,
- const base::Closure& task)
- : from_here(from_here), runner(runner), task(task) {
+ const base::Closure& task,
+ const base::TimeDelta& delay)
+ : from_here(from_here), runner(runner), task(task), delay(delay) {
CHECK(runner.get()); // Detect mistakes with a decent stack frame.
}
tracked_objects::Location from_here;
scoped_refptr<TaskRunner> runner;
base::Closure task;
+ base::TimeDelta delay;
};
OneShotEvent::OneShotEvent() : signaled_(false) {
@@ -38,19 +42,20 @@ OneShotEvent::~OneShotEvent() {}
void OneShotEvent::Post(const tracked_objects::Location& from_here,
const base::Closure& task) const {
- Post(from_here, task, base::MessageLoopProxy::current());
+ PostImpl(
+ from_here, task, base::MessageLoopProxy::current(), base::TimeDelta());
}
void OneShotEvent::Post(const tracked_objects::Location& from_here,
const base::Closure& task,
const scoped_refptr<TaskRunner>& runner) const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ PostImpl(from_here, task, runner, base::TimeDelta());
+}
- if (is_signaled()) {
- runner->PostTask(from_here, task);
- } else {
- tasks_.push_back(TaskInfo(from_here, runner, task));
- }
+void OneShotEvent::PostDelayed(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ const base::TimeDelta& delay) const {
+ PostImpl(from_here, task, base::MessageLoopProxy::current(), delay);
}
void OneShotEvent::Signal() {
@@ -66,7 +71,27 @@ void OneShotEvent::Signal() {
// We could randomize tasks_ in debug mode in order to check that
// the order doesn't matter...
for (size_t i = 0; i < tasks_.size(); ++i) {
- tasks_[i].runner->PostTask(tasks_[i].from_here, tasks_[i].task);
+ const TaskInfo& task = tasks_[i];
+ if (task.delay != base::TimeDelta())
+ task.runner->PostDelayedTask(task.from_here, task.task, task.delay);
+ else
+ task.runner->PostTask(task.from_here, task.task);
+ }
+}
+
+void OneShotEvent::PostImpl(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ const scoped_refptr<TaskRunner>& runner,
+ const base::TimeDelta& delay) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (is_signaled()) {
+ if (delay != base::TimeDelta())
+ runner->PostDelayedTask(from_here, task, delay);
+ else
+ runner->PostTask(from_here, task);
+ } else {
+ tasks_.push_back(TaskInfo(from_here, runner, task, delay));
}
}