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

Side by Side Diff: base/task_runner.h

Issue 1048373003: CancelableTaskTracker::PostDelayedTask() support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary base:: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/task/cancelable_task_tracker_unittest.cc ('k') | base/task_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 BASE_TASK_RUNNER_H_ 5 #ifndef BASE_TASK_RUNNER_H_
6 #define BASE_TASK_RUNNER_H_ 6 #define BASE_TASK_RUNNER_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool PostTask(const tracked_objects::Location& from_here, 66 bool PostTask(const tracked_objects::Location& from_here,
67 const Closure& task); 67 const Closure& task);
68 68
69 // Like PostTask, but tries to run the posted task only after 69 // Like PostTask, but tries to run the posted task only after
70 // |delay_ms| has passed. 70 // |delay_ms| has passed.
71 // 71 //
72 // It is valid for an implementation to ignore |delay_ms|; that is, 72 // It is valid for an implementation to ignore |delay_ms|; that is,
73 // to have PostDelayedTask behave the same as PostTask. 73 // to have PostDelayedTask behave the same as PostTask.
74 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 74 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
75 const Closure& task, 75 const Closure& task,
76 base::TimeDelta delay) = 0; 76 TimeDelta delay) = 0;
77 77
78 // Returns true if the current thread is a thread on which a task 78 // Returns true if the current thread is a thread on which a task
79 // may be run, and false if no task will be run on the current 79 // may be run, and false if no task will be run on the current
80 // thread. 80 // thread.
81 // 81 //
82 // It is valid for an implementation to always return true, or in 82 // It is valid for an implementation to always return true, or in
83 // general to use 'true' as a default value. 83 // general to use 'true' as a default value.
84 virtual bool RunsTasksOnCurrentThread() const = 0; 84 virtual bool RunsTasksOnCurrentThread() const = 0;
85 85
86 // Posts |task| on the current TaskRunner. On completion, |reply| 86 // Posts |task| on the current TaskRunner. On completion, |reply|
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // * Results of |task| are shared with |reply| by binding a shared argument 121 // * Results of |task| are shared with |reply| by binding a shared argument
122 // (a DataBuffer instance). 122 // (a DataBuffer instance).
123 // * The DataLoader object has no special thread safety. 123 // * The DataLoader object has no special thread safety.
124 // * The DataLoader object can be deleted while |task| is still running, 124 // * The DataLoader object can be deleted while |task| is still running,
125 // and the reply will cancel itself safely because it is bound to a 125 // and the reply will cancel itself safely because it is bound to a
126 // WeakPtr<>. 126 // WeakPtr<>.
127 bool PostTaskAndReply(const tracked_objects::Location& from_here, 127 bool PostTaskAndReply(const tracked_objects::Location& from_here,
128 const Closure& task, 128 const Closure& task,
129 const Closure& reply); 129 const Closure& reply);
130 130
131 bool PostDelayedTaskAndReply(const tracked_objects::Location& from_here,
132 const Closure& task,
133 const Closure& reply,
134 const TimeDelta& delay);
135
131 protected: 136 protected:
132 friend struct TaskRunnerTraits; 137 friend struct TaskRunnerTraits;
133 138
134 // Only the Windows debug build seems to need this: see 139 // Only the Windows debug build seems to need this: see
135 // http://crbug.com/112250. 140 // http://crbug.com/112250.
136 friend class RefCountedThreadSafe<TaskRunner, TaskRunnerTraits>; 141 friend class RefCountedThreadSafe<TaskRunner, TaskRunnerTraits>;
137 142
138 TaskRunner(); 143 TaskRunner();
139 virtual ~TaskRunner(); 144 virtual ~TaskRunner();
140 145
141 // Called when this object should be destroyed. By default simply 146 // Called when this object should be destroyed. By default simply
142 // deletes |this|, but can be overridden to do something else, like 147 // deletes |this|, but can be overridden to do something else, like
143 // delete on a certain thread. 148 // delete on a certain thread.
144 virtual void OnDestruct() const; 149 virtual void OnDestruct() const;
145 }; 150 };
146 151
147 struct BASE_EXPORT TaskRunnerTraits { 152 struct BASE_EXPORT TaskRunnerTraits {
148 static void Destruct(const TaskRunner* task_runner); 153 static void Destruct(const TaskRunner* task_runner);
149 }; 154 };
150 155
151 } // namespace base 156 } // namespace base
152 157
153 #endif // BASE_TASK_RUNNER_H_ 158 #endif // BASE_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « base/task/cancelable_task_tracker_unittest.cc ('k') | base/task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698