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

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

Issue 2053503004: Replace forward declarations with includes in TaskRunner APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-review Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_THREAD_TASK_RUNNER_HANDLE_H_ 5 #ifndef BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_
6 #define BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ 6 #define BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/single_thread_task_runner.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 class SingleThreadTaskRunner;
15
16 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner 15 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner
17 // in thread-local storage. Callers can then retrieve the TaskRunner 16 // in thread-local storage. Callers can then retrieve the TaskRunner
18 // for the current thread by calling ThreadTaskRunnerHandle::Get(). 17 // for the current thread by calling ThreadTaskRunnerHandle::Get().
19 // At most one TaskRunner may be bound to each thread at a time. 18 // At most one TaskRunner may be bound to each thread at a time.
20 // Prefer SequenceTaskRunnerHandle to this unless thread affinity is required. 19 // Prefer SequenceTaskRunnerHandle to this unless thread affinity is required.
21 class BASE_EXPORT ThreadTaskRunnerHandle { 20 class BASE_EXPORT ThreadTaskRunnerHandle {
22 public: 21 public:
23 // Gets the SingleThreadTaskRunner for the current thread. 22 // Gets the SingleThreadTaskRunner for the current thread.
24 static scoped_refptr<SingleThreadTaskRunner> Get(); 23 static scoped_refptr<SingleThreadTaskRunner> Get();
25 24
26 // Returns true if the SingleThreadTaskRunner is already created for 25 // Returns true if the SingleThreadTaskRunner is already created for
27 // the current thread. 26 // the current thread.
28 static bool IsSet(); 27 static bool IsSet();
29 28
30 // Binds |task_runner| to the current thread. |task_runner| must belong 29 // Binds |task_runner| to the current thread. |task_runner| must belong
31 // to the current thread for this to succeed. 30 // to the current thread for this to succeed.
32 explicit ThreadTaskRunnerHandle( 31 explicit ThreadTaskRunnerHandle(
33 scoped_refptr<SingleThreadTaskRunner> task_runner); 32 scoped_refptr<SingleThreadTaskRunner> task_runner);
34 ~ThreadTaskRunnerHandle(); 33 ~ThreadTaskRunnerHandle();
35 34
36 private: 35 private:
37 scoped_refptr<SingleThreadTaskRunner> task_runner_; 36 scoped_refptr<SingleThreadTaskRunner> task_runner_;
38 37
39 DISALLOW_COPY_AND_ASSIGN(ThreadTaskRunnerHandle); 38 DISALLOW_COPY_AND_ASSIGN(ThreadTaskRunnerHandle);
40 }; 39 };
41 40
42 } // namespace base 41 } // namespace base
43 42
44 #endif // BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ 43 #endif // BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_
OLDNEW
« no previous file with comments | « base/threading/sequenced_task_runner_handle.cc ('k') | base/threading/thread_task_runner_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698