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

Side by Side Diff: content/public/browser/browser_thread.h

Issue 2678303002: Pass Callback by value on PostTaskAndReply family (Closed)
Patch Set: #include Created 3 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 unified diff | Download patch
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 CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 base::TimeDelta delay); 112 base::TimeDelta delay);
113 static bool PostNonNestableTask(ID identifier, 113 static bool PostNonNestableTask(ID identifier,
114 const tracked_objects::Location& from_here, 114 const tracked_objects::Location& from_here,
115 const base::Closure& task); 115 const base::Closure& task);
116 static bool PostNonNestableDelayedTask( 116 static bool PostNonNestableDelayedTask(
117 ID identifier, 117 ID identifier,
118 const tracked_objects::Location& from_here, 118 const tracked_objects::Location& from_here,
119 const base::Closure& task, 119 const base::Closure& task,
120 base::TimeDelta delay); 120 base::TimeDelta delay);
121 121
122 static bool PostTaskAndReply( 122 static bool PostTaskAndReply(ID identifier,
123 ID identifier, 123 const tracked_objects::Location& from_here,
124 const tracked_objects::Location& from_here, 124 base::Closure task,
125 const base::Closure& task, 125 base::Closure reply);
126 const base::Closure& reply);
127 126
128 template <typename ReturnType, typename ReplyArgType> 127 template <typename ReturnType, typename ReplyArgType>
129 static bool PostTaskAndReplyWithResult( 128 static bool PostTaskAndReplyWithResult(
130 ID identifier, 129 ID identifier,
131 const tracked_objects::Location& from_here, 130 const tracked_objects::Location& from_here,
132 const base::Callback<ReturnType(void)>& task, 131 base::Callback<ReturnType()> task,
133 const base::Callback<void(ReplyArgType)>& reply) { 132 base::Callback<void(ReplyArgType)> reply) {
134 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 133 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
135 GetTaskRunnerForThread(identifier); 134 GetTaskRunnerForThread(identifier);
136 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, 135 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here,
137 reply); 136 std::move(task), std::move(reply));
gab 2017/02/07 15:46:08 #include <utility>
tzik 2017/02/08 01:39:32 Done.
138 } 137 }
139 138
140 template <class T> 139 template <class T>
141 static bool DeleteSoon(ID identifier, 140 static bool DeleteSoon(ID identifier,
142 const tracked_objects::Location& from_here, 141 const tracked_objects::Location& from_here,
143 const T* object) { 142 const T* object) {
144 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); 143 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object);
145 } 144 }
146 145
147 template <class T> 146 template <class T>
(...skipping 21 matching lines...) Expand all
169 // unique string), you can access the sequenced worker pool directly via 168 // unique string), you can access the sequenced worker pool directly via
170 // GetBlockingPool(). 169 // GetBlockingPool().
171 // 170 //
172 // If you need to PostTaskAndReplyWithResult, use 171 // If you need to PostTaskAndReplyWithResult, use
173 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task 172 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task
174 // runner. 173 // runner.
175 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, 174 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
176 const base::Closure& task); 175 const base::Closure& task);
177 static bool PostBlockingPoolTaskAndReply( 176 static bool PostBlockingPoolTaskAndReply(
178 const tracked_objects::Location& from_here, 177 const tracked_objects::Location& from_here,
179 const base::Closure& task, 178 base::Closure task,
180 const base::Closure& reply); 179 base::Closure reply);
181 static bool PostBlockingPoolSequencedTask( 180 static bool PostBlockingPoolSequencedTask(
182 const std::string& sequence_token_name, 181 const std::string& sequence_token_name,
183 const tracked_objects::Location& from_here, 182 const tracked_objects::Location& from_here,
184 const base::Closure& task); 183 const base::Closure& task);
185 184
186 // For use with scheduling non-critical tasks for execution after startup. 185 // For use with scheduling non-critical tasks for execution after startup.
187 // The order or execution of tasks posted here is unspecified even when 186 // The order or execution of tasks posted here is unspecified even when
188 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run 187 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run
189 // prior to browser shutdown. 188 // prior to browser shutdown.
190 // When called after the browser startup is complete, will post |task| 189 // When called after the browser startup is complete, will post |task|
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 private: 291 private:
293 friend class BrowserThreadImpl; 292 friend class BrowserThreadImpl;
294 293
295 BrowserThread() {} 294 BrowserThread() {}
296 DISALLOW_COPY_AND_ASSIGN(BrowserThread); 295 DISALLOW_COPY_AND_ASSIGN(BrowserThread);
297 }; 296 };
298 297
299 } // namespace content 298 } // namespace content
300 299
301 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 300 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698