| OLD | NEW |
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // The main thread in the browser. | 67 // The main thread in the browser. |
| 68 UI, | 68 UI, |
| 69 | 69 |
| 70 // This is the thread that interacts with the database. | 70 // This is the thread that interacts with the database. |
| 71 DB, | 71 DB, |
| 72 | 72 |
| 73 // This is the thread that interacts with the file system. | 73 // This is the thread that interacts with the file system. |
| 74 // DEPRECATED: prefer base/task_scheduler/post_task.h for new classes | 74 // DEPRECATED: prefer base/task_scheduler/post_task.h for new classes |
| 75 // requiring a background file I/O task runner, i.e.: | 75 // requiring a background file I/O task runner, i.e.: |
| 76 // base::CreateSequencedTaskRunnerWithTraits( | 76 // base::CreateSequencedTaskRunnerWithTraits( |
| 77 // base::TaskTraits().MayBlock() | 77 // {base::MayBlock(), base::TaskPriority::BACKGROUND}) |
| 78 // .WithPriority(base::TaskPriority::BACKGROUND)) | |
| 79 // Note: You can use base::TaskPriority::USER_VISIBLE instead of | 78 // Note: You can use base::TaskPriority::USER_VISIBLE instead of |
| 80 // base::TaskPriority::BACKGROUND if the latency of this operation | 79 // base::TaskPriority::BACKGROUND if the latency of this operation |
| 81 // is visible but non-blocking to the user. | 80 // is visible but non-blocking to the user. |
| 82 FILE, | 81 FILE, |
| 83 | 82 |
| 84 // Used for file system operations that block user interactions. | 83 // Used for file system operations that block user interactions. |
| 85 // Responsiveness of this thread affect users. | 84 // Responsiveness of this thread affect users. |
| 86 // DEPRECATED: prefer base/task_scheduler/post_task.h for new classes | 85 // DEPRECATED: prefer base/task_scheduler/post_task.h for new classes |
| 87 // requiring a user-blocking file I/O task runner, i.e.: | 86 // requiring a user-blocking file I/O task runner, i.e.: |
| 88 // base::CreateSequencedTaskRunnerWithTraits( | 87 // base::CreateSequencedTaskRunnerWithTraits( |
| 89 // base::TaskTraits().MayBlock() | 88 // {base::MayBlock(), base::TaskPriority::USER_BLOCKING}) |
| 90 // .WithPriority(base::TaskPriority::USER_BLOCKING)) | |
| 91 FILE_USER_BLOCKING, | 89 FILE_USER_BLOCKING, |
| 92 | 90 |
| 93 // Used to launch and terminate Chrome processes. | 91 // Used to launch and terminate Chrome processes. |
| 94 PROCESS_LAUNCHER, | 92 PROCESS_LAUNCHER, |
| 95 | 93 |
| 96 // This is the thread to handle slow HTTP cache operations. | 94 // This is the thread to handle slow HTTP cache operations. |
| 97 CACHE, | 95 CACHE, |
| 98 | 96 |
| 99 // This is the thread that processes non-blocking IO, i.e. IPC and network. | 97 // This is the thread that processes non-blocking IO, i.e. IPC and network. |
| 100 // Blocking IO should happen on other threads like DB, FILE, | 98 // Blocking IO should happen on other threads like DB, FILE, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 const T* object) { | 179 const T* object) { |
| 182 return GetTaskRunnerForThread(identifier)->ReleaseSoon(from_here, object); | 180 return GetTaskRunnerForThread(identifier)->ReleaseSoon(from_here, object); |
| 183 } | 181 } |
| 184 | 182 |
| 185 // Simplified wrappers for posting to the blocking thread pool. Use this | 183 // Simplified wrappers for posting to the blocking thread pool. Use this |
| 186 // for doing things like blocking I/O. | 184 // for doing things like blocking I/O. |
| 187 // | 185 // |
| 188 // DEPRECATED: use base/task_scheduler/post_task.h instead. | 186 // DEPRECATED: use base/task_scheduler/post_task.h instead. |
| 189 // * BrowserThread::PostBlockingPoolTask(AndReply)(...) => | 187 // * BrowserThread::PostBlockingPoolTask(AndReply)(...) => |
| 190 // base::PostTaskWithTraits(AndReply)( | 188 // base::PostTaskWithTraits(AndReply)( |
| 191 // FROM_HERE, base::TaskTraits().MayBlock()...) | 189 // FROM_HERE, {base::MayBlock()}) |
| 192 // * BrowserThread::PostBlockingPoolSequencedTask => | 190 // * BrowserThread::PostBlockingPoolSequencedTask => |
| 193 // Share a single SequencedTaskRunner created via | 191 // Share a single SequencedTaskRunner created via |
| 194 // base::CreateSequencedTaskRunnerWithTraits() instead of sharing a | 192 // base::CreateSequencedTaskRunnerWithTraits() instead of sharing a |
| 195 // SequenceToken (ping base/task_scheduler/OWNERS if you find a use | 193 // SequenceToken (ping base/task_scheduler/OWNERS if you find a use |
| 196 // case where that's not possible). | 194 // case where that's not possible). |
| 197 // | 195 // |
| 198 // The first variant will run the task in the pool with no sequencing | 196 // The first variant will run the task in the pool with no sequencing |
| 199 // semantics, so may get run in parallel with other posted tasks. The second | 197 // semantics, so may get run in parallel with other posted tasks. The second |
| 200 // variant will all post a task with no sequencing semantics, and will post a | 198 // variant will all post a task with no sequencing semantics, and will post a |
| 201 // reply task to the origin TaskRunner upon completion. The third variant | 199 // reply task to the origin TaskRunner upon completion. The third variant |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 236 |
| 239 // Returns the thread pool used for blocking file I/O. Use this object to | 237 // Returns the thread pool used for blocking file I/O. Use this object to |
| 240 // perform random blocking operations such as file writes. | 238 // perform random blocking operations such as file writes. |
| 241 // | 239 // |
| 242 // DEPRECATED: use an independent TaskRunner obtained from | 240 // DEPRECATED: use an independent TaskRunner obtained from |
| 243 // base/task_scheduler/post_task.h instead, e.g.: | 241 // base/task_scheduler/post_task.h instead, e.g.: |
| 244 // BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 242 // BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 245 // base::SequencedWorkerPool::GetSequenceToken()) | 243 // base::SequencedWorkerPool::GetSequenceToken()) |
| 246 // => | 244 // => |
| 247 // base::CreateSequencedTaskRunnerWithTraits( | 245 // base::CreateSequencedTaskRunnerWithTraits( |
| 248 // base::TaskTraits().MayBlock()...). | 246 // {base::MayBlock()}). |
| 249 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; | 247 static base::SequencedWorkerPool* GetBlockingPool() WARN_UNUSED_RESULT; |
| 250 | 248 |
| 251 // Callable on any thread. Returns whether the given well-known thread is | 249 // Callable on any thread. Returns whether the given well-known thread is |
| 252 // initialized. | 250 // initialized. |
| 253 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; | 251 static bool IsThreadInitialized(ID identifier) WARN_UNUSED_RESULT; |
| 254 | 252 |
| 255 // Callable on any thread. Returns whether you're currently on a particular | 253 // Callable on any thread. Returns whether you're currently on a particular |
| 256 // thread. To DCHECK this, use the DCHECK_CURRENTLY_ON() macro above. | 254 // thread. To DCHECK this, use the DCHECK_CURRENTLY_ON() macro above. |
| 257 static bool CurrentlyOn(ID identifier) WARN_UNUSED_RESULT; | 255 static bool CurrentlyOn(ID identifier) WARN_UNUSED_RESULT; |
| 258 | 256 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 private: | 338 private: |
| 341 friend class BrowserThreadImpl; | 339 friend class BrowserThreadImpl; |
| 342 | 340 |
| 343 BrowserThread() {} | 341 BrowserThread() {} |
| 344 DISALLOW_COPY_AND_ASSIGN(BrowserThread); | 342 DISALLOW_COPY_AND_ASSIGN(BrowserThread); |
| 345 }; | 343 }; |
| 346 | 344 |
| 347 } // namespace content | 345 } // namespace content |
| 348 | 346 |
| 349 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ | 347 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_THREAD_H_ |
| OLD | NEW |