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

Unified Diff: base/threading/sequenced_worker_pool.h

Issue 9401032: Make SequencedWorkerPool a TaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/task_runner_test_template.cc ('k') | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/sequenced_worker_pool.h
diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h
index c840f07c4deac87e3d513cbdf1a901467d6db72b..de318287b3796880cabb4af0dd76cef07ceb16af 100644
--- a/base/threading/sequenced_worker_pool.h
+++ b/base/threading/sequenced_worker_pool.h
@@ -14,6 +14,7 @@
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/task_runner.h"
namespace tracked_objects {
class Location;
@@ -51,8 +52,10 @@ namespace base {
// not enforce shutdown semantics or allow us to specify how many worker
// threads to run. For the typical use case of random background work, we don't
// necessarily want to be super aggressive about creating threads.
-class BASE_EXPORT SequencedWorkerPool
- : public RefCountedThreadSafe<SequencedWorkerPool> {
+//
+// Note that SequencedWorkerPool is RefCountedThreadSafe (inherited
+// from TaskRunner).
+class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
public:
// Defines what should happen to a task posted to the worker pool on shutdown.
enum WorkerShutdown {
@@ -191,6 +194,15 @@ class BASE_EXPORT SequencedWorkerPool
const Closure& task,
WorkerShutdown shutdown_behavior);
+ // TaskRunner implementation. Forwards to PostWorkerTask().
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const Closure& task,
+ TimeDelta delay) OVERRIDE;
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
+
// Blocks until all pending tasks are complete. This should only be called in
// unit tests when you want to validate something that should have happened.
//
@@ -210,14 +222,15 @@ class BASE_EXPORT SequencedWorkerPool
// and ownership of the pointer is kept with the caller.
void SetTestingObserver(TestingObserver* observer);
+ protected:
+ virtual ~SequencedWorkerPool();
+
private:
friend class RefCountedThreadSafe<SequencedWorkerPool>;
class Inner;
class Worker;
- ~SequencedWorkerPool();
-
// Avoid pulling in too many headers by putting everything into
// |inner_|.
const scoped_ptr<Inner> inner_;
« no previous file with comments | « base/task_runner_test_template.cc ('k') | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698