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

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

Issue 2842493004: Add OnceCallback support to PostTaskAndReplyWithResult (Closed)
Patch Set: s/can not/cannot/ Created 3 years, 7 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 | « components/drive/drive_api_util.cc ('k') | no next file » | 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 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 #include <utility> 9 #include <utility>
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 static bool PostTaskAndReply(ID identifier, 136 static bool PostTaskAndReply(ID identifier,
137 const tracked_objects::Location& from_here, 137 const tracked_objects::Location& from_here,
138 base::OnceClosure task, 138 base::OnceClosure task,
139 base::OnceClosure reply); 139 base::OnceClosure reply);
140 140
141 template <typename ReturnType, typename ReplyArgType> 141 template <typename ReturnType, typename ReplyArgType>
142 static bool PostTaskAndReplyWithResult( 142 static bool PostTaskAndReplyWithResult(
143 ID identifier, 143 ID identifier,
144 const tracked_objects::Location& from_here, 144 const tracked_objects::Location& from_here,
145 base::Callback<ReturnType()> task, 145 base::OnceCallback<ReturnType()> task,
146 base::Callback<void(ReplyArgType)> reply) { 146 base::OnceCallback<void(ReplyArgType)> reply) {
147 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 147 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
148 GetTaskRunnerForThread(identifier); 148 GetTaskRunnerForThread(identifier);
149 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, 149 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here,
150 std::move(task), std::move(reply)); 150 std::move(task), std::move(reply));
151 } 151 }
152 152
153 // Callback version of PostTaskAndReplyWithResult above.
154 // Though RepeatingCallback is convertible to OnceCallback, we need this since
155 // we cannot use template deduction and object conversion at once on the
156 // overload resolution.
157 // TODO(crbug.com/714018): Update all callers of the Callback version to use
158 // OnceCallback.
159 template <typename ReturnType, typename ReplyArgType>
160 static bool PostTaskAndReplyWithResult(
161 ID identifier,
162 const tracked_objects::Location& from_here,
163 base::Callback<ReturnType()> task,
164 base::Callback<void(ReplyArgType)> reply) {
165 return PostTaskAndReplyWithResult(
166 identifier, from_here,
167 base::OnceCallback<ReturnType()>(std::move(task)),
168 base::OnceCallback<void(ReplyArgType)>(std::move(reply)));
169 }
170
153 template <class T> 171 template <class T>
154 static bool DeleteSoon(ID identifier, 172 static bool DeleteSoon(ID identifier,
155 const tracked_objects::Location& from_here, 173 const tracked_objects::Location& from_here,
156 const T* object) { 174 const T* object) {
157 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); 175 return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object);
158 } 176 }
159 177
160 template <class T> 178 template <class T>
161 static bool ReleaseSoon(ID identifier, 179 static bool ReleaseSoon(ID identifier,
162 const tracked_objects::Location& from_here, 180 const tracked_objects::Location& from_here,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 private: 340 private:
323 friend class BrowserThreadImpl; 341 friend class BrowserThreadImpl;
324 342
325 BrowserThread() {} 343 BrowserThread() {}
326 DISALLOW_COPY_AND_ASSIGN(BrowserThread); 344 DISALLOW_COPY_AND_ASSIGN(BrowserThread);
327 }; 345 };
328 346
329 } // namespace content 347 } // namespace content
330 348
331 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 349 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
OLDNEW
« no previous file with comments | « components/drive/drive_api_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698