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

Side by Side Diff: base/threading/sequenced_worker_pool.h

Issue 9124033: Hook up the SequencedWorkerPool to the browser thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_H_
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // 165 //
166 // The task will be guaranteed to run to completion before shutdown 166 // The task will be guaranteed to run to completion before shutdown
167 // (BLOCK_SHUTDOWN semantics). 167 // (BLOCK_SHUTDOWN semantics).
168 // 168 //
169 // Returns true if the task was posted successfully. This may fail during 169 // Returns true if the task was posted successfully. This may fail during
170 // shutdown regardless of the specified ShutdownBehavior. 170 // shutdown regardless of the specified ShutdownBehavior.
171 bool PostSequencedWorkerTask(SequenceToken sequence_token, 171 bool PostSequencedWorkerTask(SequenceToken sequence_token,
172 const tracked_objects::Location& from_here, 172 const tracked_objects::Location& from_here,
173 const base::Closure& task); 173 const base::Closure& task);
174 174
175 // Like PostSequencedWorkerTask above, but allows you to specify a named
176 // token, which saves an extra call to GetNamedSequenceToken.
177 bool PostNamedSequencedWorkerTask(const std::string& token_name,
178 const tracked_objects::Location& from_here,
179 const base::Closure& task);
180
175 // Same as PostSequencedWorkerTask but allows specification of the shutdown 181 // Same as PostSequencedWorkerTask but allows specification of the shutdown
176 // behavior. 182 // behavior.
177 bool PostSequencedWorkerTaskWithShutdownBehavior( 183 bool PostSequencedWorkerTaskWithShutdownBehavior(
178 SequenceToken sequence_token, 184 SequenceToken sequence_token,
179 const tracked_objects::Location& from_here, 185 const tracked_objects::Location& from_here,
180 const base::Closure& task, 186 const base::Closure& task,
181 WorkerShutdown shutdown_behavior); 187 WorkerShutdown shutdown_behavior);
182 188
189 // Blocks until all pending tasks are complete. This should only be called in
190 // unit tests when you want to validate something that should have happened.
191 //
192 // Note that calling this will not prevent other threads from posting work to
193 // the queue while the calling thread is waiting on Flush(). In this case,
194 // Flush will return only when there's no more work in the queue. Normally,
195 // this doesn't come up sine in a test, all the work is being posted from
196 // the main thread.
197 void FlushForTesting();
198
183 // Implements the worker pool shutdown. This should be called during app 199 // Implements the worker pool shutdown. This should be called during app
184 // shutdown, and will discard/join with appropriate tasks before returning. 200 // shutdown, and will discard/join with appropriate tasks before returning.
185 // After this call, subsequent calls to post tasks will fail. 201 // After this call, subsequent calls to post tasks will fail.
186 void Shutdown(); 202 void Shutdown();
187 203
188 // Called by tests to set the testing observer. This is NULL by default 204 // Called by tests to set the testing observer. This is NULL by default
189 // and ownership of the pointer is kept with the caller. 205 // and ownership of the pointer is kept with the caller.
190 void SetTestingObserver(TestingObserver* observer); 206 void SetTestingObserver(TestingObserver* observer);
191 207
192 private: 208 private:
193 class Inner; 209 class Inner;
194 class Worker; 210 class Worker;
195 211
196 friend class Inner; 212 friend class Inner;
197 friend class Worker; 213 friend class Worker;
198 214
199 scoped_refptr<Inner> inner_; 215 scoped_refptr<Inner> inner_;
200 216
201 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); 217 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool);
202 }; 218 };
203 219
204 } // namespace base 220 } // namespace base
205 221
206 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ 222 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698