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

Unified Diff: cc/trees/blocking_task_runner.h

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Help gn deal with it. Created 6 years, 4 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
Index: cc/trees/blocking_task_runner.h
diff --git a/cc/trees/blocking_task_runner.h b/cc/trees/blocking_task_runner.h
index 8388a881e607e6bbcf11e4c30b9d659f1dd54909..ec9cabb8511f192b4d3cd04210d750295240050b 100644
--- a/cc/trees/blocking_task_runner.h
+++ b/cc/trees/blocking_task_runner.h
@@ -25,17 +25,16 @@ namespace cc {
// to when they were posted.
//
// To use this class, post tasks to the task runner returned by
-// BlockingTaskRunner::current() on the thread you want the tasks to run.
-// Hold a reference to the BlockingTaskRunner as long as you intend to
-// post tasks to it.
+// BlockingTaskRunner::Create() with the SingleThreadTaskRunner for the thread
danakj 2014/08/28 17:10:46 i think this sentence is awkward. period after Cre
Sami 2014/08/28 18:21:16 Yah, not sure what I was going for there. Rewritte
+// you want the tasks to run.
//
-// Then, on the thread from which the BlockingTaskRunner was created, you
-// may instantiate a BlockingTaskRunner::CapturePostTasks. While this object
+// Then, on the thread that the given task runner belongs to, you may
+// instantiate a BlockingTaskRunner::CapturePostTasks. While this object
// exists, the task runner will collect any PostTasks called on it, posting
// tasks to that thread from anywhere. This CapturePostTasks object provides
// a window in time where tasks can shortcut past the MessageLoop. As soon
// as the CapturePostTasks object is destroyed (goes out of scope), all
-// tasks that had been posted to the thread during the window will be exectuted
+// tasks that had been posted to the thread during the window will be executed
// immediately.
//
// Beware of re-entrancy, make sure the CapturePostTasks object is destroyed at
@@ -43,16 +42,20 @@ namespace cc {
class CC_EXPORT BlockingTaskRunner
: public base::RefCountedThreadSafe<BlockingTaskRunner> {
public:
- // Returns the BlockingTaskRunner for the current thread, creating one if
- // necessary.
- static scoped_refptr<BlockingTaskRunner> current();
+ // Creates a BlockingTaskRunner for a given SingleThreadTaskRunner.
+ // |task_runner| will be used to run the tasks which are posted while we are
+ // not capturing. |task_runner| should belong to same the thread on which
+ // capturing is done.
+ static scoped_refptr<BlockingTaskRunner> Create(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
danakj 2014/08/28 17:10:46 I'm starting to wonder if this class needs to be r
Sami 2014/08/28 18:21:17 Great idea, the ownership is much simpler now so a
// While an object of this type is held alive on a thread, any tasks
// posted to the thread will be captured and run as soon as the object
- // is destroyed, shortcutting past the MessageLoop.
+ // is destroyed, shortcutting past the task runner.
class CC_EXPORT CapturePostTasks {
public:
- CapturePostTasks();
+ explicit CapturePostTasks(
+ scoped_refptr<BlockingTaskRunner> blocking_runner);
danakj 2014/08/28 17:10:46 make this a raw pointer
Sami 2014/08/28 18:21:16 Done.
~CapturePostTasks();
private:
@@ -68,7 +71,7 @@ class CC_EXPORT BlockingTaskRunner
// Posts a task using the contained SingleThreadTaskRunner unless |capture_|
// is true. When |capture_| is true, tasks posted will be caught and stored
// until the capturing stops. At that time the tasks will be run directly
- // instead of being posted to the SingleThreadTaskRunner.
+ // instead of being posted to the underlying task runner.
bool PostTask(const tracked_objects::Location& from_here,
const base::Closure& task);
@@ -81,7 +84,6 @@ class CC_EXPORT BlockingTaskRunner
void SetCapture(bool capture);
- base::PlatformThreadId thread_id_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
base::Lock lock_;

Powered by Google App Engine
This is Rietveld 408576698