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

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

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ID_COUNT 97 ID_COUNT
98 }; 98 };
99 99
100 // These are the same methods in message_loop.h, but are guaranteed to either 100 // These are the same methods in message_loop.h, but are guaranteed to either
101 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. 101 // get posted to the MessageLoop if it's still alive, or be deleted otherwise.
102 // They return true iff the thread existed and the task was posted. Note that 102 // They return true iff the thread existed and the task was posted. Note that
103 // even if the task is posted, there's no guarantee that it will run, since 103 // even if the task is posted, there's no guarantee that it will run, since
104 // the target thread may already have a Quit message in its queue. 104 // the target thread may already have a Quit message in its queue.
105 static bool PostTask(ID identifier, 105 static bool PostTask(ID identifier,
106 const tracked_objects::Location& from_here, 106 const tracked_objects::Location& from_here,
107 const base::Closure& task); 107 base::OnceClosure task);
108 static bool PostDelayedTask(ID identifier, 108 static bool PostDelayedTask(ID identifier,
109 const tracked_objects::Location& from_here, 109 const tracked_objects::Location& from_here,
110 const base::Closure& task, 110 base::OnceClosure task,
111 base::TimeDelta delay); 111 base::TimeDelta delay);
112 static bool PostNonNestableTask(ID identifier, 112 static bool PostNonNestableTask(ID identifier,
113 const tracked_objects::Location& from_here, 113 const tracked_objects::Location& from_here,
114 const base::Closure& task); 114 base::OnceClosure task);
115 static bool PostNonNestableDelayedTask( 115 static bool PostNonNestableDelayedTask(
116 ID identifier, 116 ID identifier,
117 const tracked_objects::Location& from_here, 117 const tracked_objects::Location& from_here,
118 const base::Closure& task, 118 base::OnceClosure task,
119 base::TimeDelta delay); 119 base::TimeDelta delay);
120 120
121 static bool PostTaskAndReply( 121 static bool PostTaskAndReply(ID identifier,
122 ID identifier, 122 const tracked_objects::Location& from_here,
123 const tracked_objects::Location& from_here, 123 base::OnceClosure task,
124 const base::Closure& task, 124 base::OnceClosure reply);
125 const base::Closure& reply);
126 125
127 template <typename ReturnType, typename ReplyArgType> 126 template <typename ReturnType, typename ReplyArgType>
128 static bool PostTaskAndReplyWithResult( 127 static bool PostTaskAndReplyWithResult(
129 ID identifier, 128 ID identifier,
130 const tracked_objects::Location& from_here, 129 const tracked_objects::Location& from_here,
131 const base::Callback<ReturnType(void)>& task, 130 const base::Callback<ReturnType(void)>& task,
132 const base::Callback<void(ReplyArgType)>& reply) { 131 const base::Callback<void(ReplyArgType)>& reply) {
133 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 132 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
134 GetTaskRunnerForThread(identifier); 133 GetTaskRunnerForThread(identifier);
135 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, 134 return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task,
(...skipping 29 matching lines...) Expand all
165 // something slow and noncritical that doesn't need to block shutdown), 164 // something slow and noncritical that doesn't need to block shutdown),
166 // or you want to manually provide a sequence token (which saves a map 165 // or you want to manually provide a sequence token (which saves a map
167 // lookup and is guaranteed unique without you having to come up with a 166 // lookup and is guaranteed unique without you having to come up with a
168 // unique string), you can access the sequenced worker pool directly via 167 // unique string), you can access the sequenced worker pool directly via
169 // GetBlockingPool(). 168 // GetBlockingPool().
170 // 169 //
171 // If you need to PostTaskAndReplyWithResult, use 170 // If you need to PostTaskAndReplyWithResult, use
172 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task 171 // base::PostTaskAndReplyWithResult() with GetBlockingPool() as the task
173 // runner. 172 // runner.
174 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here, 173 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
175 const base::Closure& task); 174 base::OnceClosure task);
176 static bool PostBlockingPoolTaskAndReply( 175 static bool PostBlockingPoolTaskAndReply(
177 const tracked_objects::Location& from_here, 176 const tracked_objects::Location& from_here,
178 const base::Closure& task, 177 base::OnceClosure task,
179 const base::Closure& reply); 178 base::OnceClosure reply);
180 static bool PostBlockingPoolSequencedTask( 179 static bool PostBlockingPoolSequencedTask(
181 const std::string& sequence_token_name, 180 const std::string& sequence_token_name,
182 const tracked_objects::Location& from_here, 181 const tracked_objects::Location& from_here,
183 const base::Closure& task); 182 base::OnceClosure task);
184 183
185 // For use with scheduling non-critical tasks for execution after startup. 184 // For use with scheduling non-critical tasks for execution after startup.
186 // The order or execution of tasks posted here is unspecified even when 185 // The order or execution of tasks posted here is unspecified even when
187 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run 186 // posting to a SequencedTaskRunner and tasks are not guaranteed to be run
188 // prior to browser shutdown. 187 // prior to browser shutdown.
189 // When called after the browser startup is complete, will post |task| 188 // When called after the browser startup is complete, will post |task|
190 // to |task_runner| immediately. 189 // to |task_runner| immediately.
191 // Note: see related ContentBrowserClient::PostAfterStartupTask. 190 // Note: see related ContentBrowserClient::PostAfterStartupTask.
192 static void PostAfterStartupTask( 191 static void PostAfterStartupTask(
193 const tracked_objects::Location& from_here, 192 const tracked_objects::Location& from_here,
194 const scoped_refptr<base::TaskRunner>& task_runner, 193 const scoped_refptr<base::TaskRunner>& task_runner,
195 const base::Closure& task); 194 base::OnceClosure task);
196 195
197 // Returns the thread pool used for blocking file I/O. Use this object to 196 // Returns the thread pool used for blocking file I/O. Use this object to
198 // perform random blocking operations such as file writes or querying the 197 // perform random blocking operations such as file writes or querying the
199 // Windows registry. 198 // Windows registry.
200 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; 199 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT;
201 200
202 // Callable on any thread. Returns whether the given well-known thread is 201 // Callable on any thread. Returns whether the given well-known thread is
203 // initialized. 202 // initialized.
204 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; 203 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT;
205 204
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 private: 296 private:
298 friend class BrowserThreadImpl; 297 friend class BrowserThreadImpl;
299 298
300 BrowserThread() {} 299 BrowserThread() {}
301 DISALLOW_COPY_AND_ASSIGN(BrowserThread); 300 DISALLOW_COPY_AND_ASSIGN(BrowserThread);
302 }; 301 };
303 302
304 } // namespace content 303 } // namespace content
305 304
306 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 305 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
OLDNEW
« no previous file with comments | « content/child/worker_thread_registry.cc ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698