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

Side by Side Diff: content/public/browser/browser_thread.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 | « 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) 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 #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/tracked_objects.h" 12 #include "base/tracked_objects.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_thread_delegate.h" 14 #include "content/public/browser/browser_thread_delegate.h"
15 15
16 #if defined(UNIT_TEST) 16 #if defined(UNIT_TEST)
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #endif // UNIT_TEST 18 #endif // UNIT_TEST
19 19
20 class MessageLoop; 20 class MessageLoop;
21 21
22 namespace base { 22 namespace base {
23 class SequencedWorkerPool;
23 class Thread; 24 class Thread;
24 } 25 }
25 26
26 namespace content { 27 namespace content {
27 28
28 class BrowserThreadImpl; 29 class BrowserThreadImpl;
29 30
30 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
31 // BrowserThread 32 // BrowserThread
32 // 33 //
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 131 }
131 132
132 template <class T> 133 template <class T>
133 static bool ReleaseSoon(ID identifier, 134 static bool ReleaseSoon(ID identifier,
134 const tracked_objects::Location& from_here, 135 const tracked_objects::Location& from_here,
135 const T* object) { 136 const T* object) {
136 return GetMessageLoopProxyForThread(identifier)->ReleaseSoon( 137 return GetMessageLoopProxyForThread(identifier)->ReleaseSoon(
137 from_here, object); 138 from_here, object);
138 } 139 }
139 140
141 // Simplified wrappers for posting to the blocking thread pool. Use this
142 // for doing things like blocking I/O.
143 //
144 // The first variant will run the task in the pool with no sequencing
145 // semantics, so may get run in parallel with other posted tasks. The
146 // second variant provides sequencing between tasks with the same
147 // sequence token name.
148 //
149 // These tasks are guaranteed to run before shutdown.
150 //
151 // If you need to provide different shutdown semantics (like you have
152 // something slow and noncritical that doesn't need to block shutdown),
153 // or you want to manually provide a sequence token (which saves a map
154 // lookup and is guaranteed unique without you having to come up with a
155 // unique string), you can access the sequenced worker pool directly via
156 // GetBlockingPool().
157 static bool PostBlockingPoolTask(const tracked_objects::Location& from_here,
158 const base::Closure& task);
159 static bool PostBlockingPoolSequencedTask(
160 const std::string& sequence_token_name,
161 const tracked_objects::Location& from_here,
162 const base::Closure& task);
163
164 // Returns the thread pool used for blocking file I/O. Use this object to
165 // perform random blocking operations such as file writes or querying the
166 // Windows registry.
167 static base::SequencedWorkerPool* GetBlockingPool();
168
140 // Callable on any thread. Returns whether the given ID corresponds to a well 169 // Callable on any thread. Returns whether the given ID corresponds to a well
141 // known thread. 170 // known thread.
142 static bool IsWellKnownThread(ID identifier); 171 static bool IsWellKnownThread(ID identifier);
143 172
144 // Callable on any thread. Returns whether you're currently on a particular 173 // Callable on any thread. Returns whether you're currently on a particular
145 // thread. 174 // thread.
146 static bool CurrentlyOn(ID identifier); 175 static bool CurrentlyOn(ID identifier);
147 176
148 // Callable on any thread. Returns whether the threads message loop is valid. 177 // Callable on any thread. Returns whether the threads message loop is valid.
149 // If this returns false it means the thread is in the process of shutting 178 // 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
224 private: 253 private:
225 friend class BrowserThreadImpl; 254 friend class BrowserThreadImpl;
226 255
227 BrowserThread() {} 256 BrowserThread() {}
228 DISALLOW_COPY_AND_ASSIGN(BrowserThread); 257 DISALLOW_COPY_AND_ASSIGN(BrowserThread);
229 }; 258 };
230 259
231 } // namespace content 260 } // namespace content
232 261
233 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ 262 #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