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

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

Issue 9065009: 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 | « content/browser/browser_thread_impl.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) 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 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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "base/tracked_objects.h" 13 #include "base/tracked_objects.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/browser_thread_delegate.h" 15 #include "content/public/browser/browser_thread_delegate.h"
16 16
17 #if defined(UNIT_TEST) 17 #if defined(UNIT_TEST)
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #endif // UNIT_TEST 19 #endif // UNIT_TEST
20 20
21 class MessageLoop; 21 class MessageLoop;
22 22
23 namespace base { 23 namespace base {
24 class SequencedWorkerPool;
24 class Thread; 25 class Thread;
25 } 26 }
26 27
27 namespace content { 28 namespace content {
28 29
29 class BrowserThreadImpl; 30 class BrowserThreadImpl;
30 31
31 /////////////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////////////
32 // BrowserThread 33 // BrowserThread
33 // 34 //
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 151 }
151 152
152 template <class T> 153 template <class T>
153 static bool ReleaseSoon(ID identifier, 154 static bool ReleaseSoon(ID identifier,
154 const tracked_objects::Location& from_here, 155 const tracked_objects::Location& from_here,
155 const T* object) { 156 const T* object) {
156 return GetMessageLoopProxyForThread(identifier)->ReleaseSoon( 157 return GetMessageLoopProxyForThread(identifier)->ReleaseSoon(
157 from_here, object); 158 from_here, object);
158 } 159 }
159 160
161 // Simplified wrappers for posting to the blocking thread pool. Use this
162 // for doing things like blocking I/O.
163 //
164 // The first variant will run the task in the pool with no sequencing
165 // semantics, so may get run in parallel with other posted tasks. The
166 // second variant provides sequencing between tasks with the same
167 // sequence token name.
168 //
169 // These tasks are guaranteed to run before shutdown.
170 //
171 // If you need to provide different shutdown semantics (like you have
172 // something slow and noncritical that doesn't need to block shutdown),
173 // or you want to manually provide a sequence token (which saves a map
174 // lookup and is guaranteed unique without you having to come up with a
175 // unique string), you can access the sequenced worker pool directly via
176 // GetBlockingPool().
177 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
178 const base::Closure& task);
179 static bool PostBlockingPoolSequencedTask(
180 const std::string& sequence_token_name,
181 const tracked_objects::Location& from_here,
182 const base::Closure& task);
183
184 // Returns the thread pool used for blocking file I/O. Use this object to
185 // perform random blocking operations such as file writes or querying the
186 // Windows registry.
187 static base::SequencedWorkerPool* GetBlockingPool();
188
160 // Callable on any thread. Returns whether the given ID corresponds to a well 189 // Callable on any thread. Returns whether the given ID corresponds to a well
161 // known thread. 190 // known thread.
162 static bool IsWellKnownThread(ID identifier); 191 static bool IsWellKnownThread(ID identifier);
163 192
164 // Callable on any thread. Returns whether you're currently on a particular 193 // Callable on any thread. Returns whether you're currently on a particular
165 // thread. 194 // thread.
166 static bool CurrentlyOn(ID identifier); 195 static bool CurrentlyOn(ID identifier);
167 196
168 // Callable on any thread. Returns whether the threads message loop is valid. 197 // Callable on any thread. Returns whether the threads message loop is valid.
169 // If this returns false it means the thread is in the process of shutting 198 // If this returns false it means the thread is in the process of shutting
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 private: 273 private:
245 friend class BrowserThreadImpl; 274 friend class BrowserThreadImpl;
246 275
247 BrowserThread() {} 276 BrowserThread() {}
248 DISALLOW_COPY_AND_ASSIGN(BrowserThread); 277 DISALLOW_COPY_AND_ASSIGN(BrowserThread);
249 }; 278 };
250 279
251 } // namespace content 280 } // namespace content
252 281
253 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 282 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_
OLDNEW
« no previous file with comments | « content/browser/browser_thread_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698