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

Side by Side Diff: ios/web/public/web_thread.h

Issue 2678303002: Pass Callback by value on PostTaskAndReply family (Closed)
Patch Set: rebase 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
« no previous file with comments | « content/public/browser/browser_thread.h ('k') | ios/web/web_thread_impl.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 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 #include <utility>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/task_runner_util.h" 18 #include "base/task_runner_util.h"
18 19
19 namespace base { 20 namespace base {
20 class MessageLoop; 21 class MessageLoop;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const tracked_objects::Location& from_here, 110 const tracked_objects::Location& from_here,
110 const base::Closure& task); 111 const base::Closure& task);
111 static bool PostNonNestableDelayedTask( 112 static bool PostNonNestableDelayedTask(
112 ID identifier, 113 ID identifier,
113 const tracked_objects::Location& from_here, 114 const tracked_objects::Location& from_here,
114 const base::Closure& task, 115 const base::Closure& task,
115 base::TimeDelta delay); 116 base::TimeDelta delay);
116 117
117 static bool PostTaskAndReply(ID identifier, 118 static bool PostTaskAndReply(ID identifier,
118 const tracked_objects::Location& from_here, 119 const tracked_objects::Location& from_here,
119 const base::Closure& task, 120 base::Closure task,
120 const base::Closure& reply); 121 base::Closure reply);
121 122
122 template <typename ReturnType, typename ReplyArgType> 123 template <typename ReturnType, typename ReplyArgType>
123 static bool PostTaskAndReplyWithResult( 124 static bool PostTaskAndReplyWithResult(
124 ID identifier, 125 ID identifier,
125 const tracked_objects::Location& from_here, 126 const tracked_objects::Location& from_here,
126 const base::Callback<ReturnType(void)>& task, 127 base::Callback<ReturnType()> task,
127 const base::Callback<void(ReplyArgType)>& reply) { 128 base::Callback<void(ReplyArgType)> reply) {
128 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 129 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
129 GetTaskRunnerForThread(identifier); 130 GetTaskRunnerForThread(identifier);
130 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, 131 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here,
131 reply); 132 std::move(task), std::move(reply));
132 } 133 }
133 134
134 template <class T> 135 template <class T>
135 static bool DeleteSoon(ID identifier, 136 static bool DeleteSoon(ID identifier,
136 const tracked_objects::Location& from_here, 137 const tracked_objects::Location& from_here,
137 const T* object) { 138 const T* object) {
138 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); 139 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object);
139 } 140 }
140 141
141 // Simplified wrappers for posting to the blocking thread pool. Use this 142 // 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 157 // unique string), you can access the sequenced worker pool directly via
157 // GetBlockingPool(). 158 // GetBlockingPool().
158 // 159 //
159 // If you need to PostTaskAndReplyWithResult, use 160 // If you need to PostTaskAndReplyWithResult, use
160 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task 161 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task
161 // runner. 162 // runner.
162 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, 163 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
163 const base::Closure& task); 164 const base::Closure& task);
164 static bool PostBlockingPoolTaskAndReply( 165 static bool PostBlockingPoolTaskAndReply(
165 const tracked_objects::Location& from_here, 166 const tracked_objects::Location& from_here,
166 const base::Closure& task, 167 base::Closure task,
167 const base::Closure& reply); 168 base::Closure reply);
168 static bool PostBlockingPoolSequencedTask( 169 static bool PostBlockingPoolSequencedTask(
169 const std::string& sequence_token_name, 170 const std::string& sequence_token_name,
170 const tracked_objects::Location& from_here, 171 const tracked_objects::Location& from_here,
171 const base::Closure& task); 172 const base::Closure& task);
172 173
173 // Returns the thread pool used for blocking file I/O. Use this object to 174 // Returns the thread pool used for blocking file I/O. Use this object to
174 // perform random blocking operations such as file writes. 175 // perform random blocking operations such as file writes.
175 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; 176 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT;
176 177
177 // Callable on any thread. Returns whether the given well-known thread is 178 // 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: 260 private:
260 friend class WebThreadImpl; 261 friend class WebThreadImpl;
261 262
262 WebThread() {} 263 WebThread() {}
263 DISALLOW_COPY_AND_ASSIGN(WebThread); 264 DISALLOW_COPY_AND_ASSIGN(WebThread);
264 }; 265 };
265 266
266 } // namespace web 267 } // namespace web
267 268
268 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_ 269 #endif // IOS_WEB_PUBLIC_WEB_THREAD_H_
OLDNEW
« no previous file with comments | « content/public/browser/browser_thread.h ('k') | ios/web/web_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698