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

Side by Side Diff: ios/web/public/web_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 IOS_WEB_PUBLIC_WEB_THREAD_H_ 5 #ifndef IOS_WEB_PUBLIC_WEB_THREAD_H_
6 #define IOS_WEB_PUBLIC_WEB_THREAD_H_ 6 #define IOS_WEB_PUBLIC_WEB_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 18
19 namespace base { 19 namespace base {
20 class MessageLoop; 20 class MessageLoop;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const tracked_objects::Location& from_here, 109 const tracked_objects::Location& from_here,
110 const base::Closure& task); 110 const base::Closure& task);
111 static bool PostNonNestableDelayedTask( 111 static bool PostNonNestableDelayedTask(
112 ID identifier, 112 ID identifier,
113 const tracked_objects::Location& from_here, 113 const tracked_objects::Location& from_here,
114 const base::Closure& task, 114 const base::Closure& task,
115 base::TimeDelta delay); 115 base::TimeDelta delay);
116 116
117 static bool PostTaskAndReply(ID identifier, 117 static bool PostTaskAndReply(ID identifier,
118 const tracked_objects::Location& from_here, 118 const tracked_objects::Location& from_here,
119 const base::Closure& task, 119 base::Closure task,
120 const base::Closure& reply); 120 base::Closure reply);
121 121
122 template <typename ReturnType, typename ReplyArgType> 122 template <typename ReturnType, typename ReplyArgType>
123 static bool PostTaskAndReplyWithResult( 123 static bool PostTaskAndReplyWithResult(
124 ID identifier, 124 ID identifier,
125 const tracked_objects::Location& from_here, 125 const tracked_objects::Location& from_here,
126 const base::Callback<ReturnType(void)>& task, 126 base::Callback<ReturnType()> task,
127 const base::Callback<void(ReplyArgType)>& reply) { 127 base::Callback<void(ReplyArgType)> reply) {
128 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 128 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
129 GetTaskRunnerForThread(identifier); 129 GetTaskRunnerForThread(identifier);
130 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, 130 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here,
131 reply); 131 std::move(task), std::move(reply));
gab 2017/02/07 15:46:08 #include <utility>
tzik 2017/02/08 01:39:32 Done.
132 } 132 }
133 133
134 template <class T> 134 template <class T>
135 static bool DeleteSoon(ID identifier, 135 static bool DeleteSoon(ID identifier,
136 const tracked_objects::Location& from_here, 136 const tracked_objects::Location& from_here,
137 const T* object) { 137 const T* object) {
138 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); 138 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object);
139 } 139 }
140 140
141 // Simplified wrappers for posting to the blocking thread pool. Use this 141 // Simplified wrappers for posting to the blocking thread pool. Use this
(...skipping 14 matching lines...) Expand all
156 // unique string), you can access the sequenced worker pool directly via 156 // unique string), you can access the sequenced worker pool directly via
157 // GetBlockingPool(). 157 // GetBlockingPool().
158 // 158 //
159 // If you need to PostTaskAndReplyWithResult, use 159 // If you need to PostTaskAndReplyWithResult, use
160 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task 160 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task
161 // runner. 161 // runner.
162 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, 162 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
163 const base::Closure& task); 163 const base::Closure& task);
164 static bool PostBlockingPoolTaskAndReply( 164 static bool PostBlockingPoolTaskAndReply(
165 const tracked_objects::Location& from_here, 165 const tracked_objects::Location& from_here,
166 const base::Closure& task, 166 base::Closure task,
167 const base::Closure& reply); 167 base::Closure reply);
168 static bool PostBlockingPoolSequencedTask( 168 static bool PostBlockingPoolSequencedTask(
169 const std::string& sequence_token_name, 169 const std::string& sequence_token_name,
170 const tracked_objects::Location& from_here, 170 const tracked_objects::Location& from_here,
171 const base::Closure& task); 171 const base::Closure& task);
172 172
173 // Returns the thread pool used for blocking file I/O. Use this object to 173 // Returns the thread pool used for blocking file I/O. Use this object to
174 // perform random blocking operations such as file writes. 174 // perform random blocking operations such as file writes.
175 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; 175 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT;
176 176
177 // Callable on any thread. Returns whether the given well-known thread is 177 // Callable on any thread. Returns whether the given well-known thread is
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 private: 259 private:
260 friend class WebThreadImpl; 260 friend class WebThreadImpl;
261 261
262 WebThread() {} 262 WebThread() {}
263 DISALLOW_COPY_AND_ASSIGN(WebThread); 263 DISALLOW_COPY_AND_ASSIGN(WebThread);
264 }; 264 };
265 265
266 } // namespace web 266 } // namespace web
267 267
268 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ 268 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698