OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TREES_BLOCKING_TASK_RUNNER_H_ | 5 #ifndef CC_TREES_BLOCKING_TASK_RUNNER_H_ |
6 #define CC_TREES_BLOCKING_TASK_RUNNER_H_ | 6 #define CC_TREES_BLOCKING_TASK_RUNNER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 // thread. | 65 // thread. |
66 bool BelongsToCurrentThread(); | 66 bool BelongsToCurrentThread(); |
67 | 67 |
68 // Posts a task using the contained SingleThreadTaskRunner unless |capture_| | 68 // Posts a task using the contained SingleThreadTaskRunner unless |capture_| |
69 // is true. When |capture_| is true, tasks posted will be caught and stored | 69 // is true. When |capture_| is true, tasks posted will be caught and stored |
70 // until the capturing stops. At that time the tasks will be run directly | 70 // until the capturing stops. At that time the tasks will be run directly |
71 // instead of being posted to the SingleThreadTaskRunner. | 71 // instead of being posted to the SingleThreadTaskRunner. |
72 bool PostTask(const tracked_objects::Location& from_here, | 72 bool PostTask(const tracked_objects::Location& from_here, |
73 const base::Closure& task); | 73 const base::Closure& task); |
74 | 74 |
75 // Forward the tasks to a specific task runner instead of the | |
danakj
2014/08/26 15:59:00
WDYT of passing this to current() and DCHECKing th
Sami
2014/08/26 16:19:17
The places[1] that call BlockingTaskRunner::curren
| |
76 // MessageLoopProxy which was current when this task runner was constructed. | |
77 // Must not be called while capturing tasks. | |
78 void SetTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
79 | |
75 private: | 80 private: |
76 friend class base::RefCountedThreadSafe<BlockingTaskRunner>; | 81 friend class base::RefCountedThreadSafe<BlockingTaskRunner>; |
77 | 82 |
78 explicit BlockingTaskRunner( | 83 explicit BlockingTaskRunner( |
79 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 84 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
80 virtual ~BlockingTaskRunner(); | 85 virtual ~BlockingTaskRunner(); |
81 | 86 |
82 void SetCapture(bool capture); | 87 void SetCapture(bool capture); |
83 | 88 |
84 base::PlatformThreadId thread_id_; | 89 base::PlatformThreadId thread_id_; |
85 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 90 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
86 | 91 |
87 base::Lock lock_; | 92 base::Lock lock_; |
88 int capture_; | 93 int capture_; |
89 std::vector<base::Closure> captured_tasks_; | 94 std::vector<base::Closure> captured_tasks_; |
90 }; | 95 }; |
91 | 96 |
92 } // namespace cc | 97 } // namespace cc |
93 | 98 |
94 #endif // CC_TREES_BLOCKING_TASK_RUNNER_H_ | 99 #endif // CC_TREES_BLOCKING_TASK_RUNNER_H_ |
OLD | NEW |