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

Side by Side Diff: cc/trees/task_runner_provider.h

Issue 1411663002: cc: Split Proxy to eliminate unnecessary dependencies on the impl side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update perf tests. Created 5 years, 2 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
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/task_runner_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_TREES_TASK_RUNNER_PROVIDER_H_
6 #define CC_TREES_TASK_RUNNER_PROVIDER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h"
16 #include "base/values.h"
17 #include "cc/base/cc_export.h"
18
19 namespace base {
20 namespace trace_event {
21 class TracedValue;
22 }
23 class SingleThreadTaskRunner;
24 }
25
26 namespace cc {
27 class BlockingTaskRunner;
28
29 // Class responsible for controlling access to the main and impl task runners.
30 // Useful for assertion checks.
31 class CC_EXPORT TaskRunnerProvider {
32 public:
33 base::SingleThreadTaskRunner* MainThreadTaskRunner() const;
34 bool HasImplThread() const;
35 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const;
36
37 // Debug hooks.
38 bool IsMainThread() const;
39 bool IsImplThread() const;
40 bool IsMainThreadBlocked() const;
41 #if DCHECK_IS_ON()
42 void SetMainThreadBlocked(bool is_main_thread_blocked);
43 void SetCurrentThreadIsImplThread(bool is_impl_thread);
44 #endif
45
46 virtual ~TaskRunnerProvider();
47
48 BlockingTaskRunner* blocking_main_thread_task_runner() const {
49 return blocking_main_thread_task_runner_.get();
50 }
51
52 TaskRunnerProvider(
53 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
54 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
55
56 protected:
57 friend class DebugScopedSetImplThread;
58 friend class DebugScopedSetMainThread;
59 friend class DebugScopedSetMainThreadBlocked;
60
61 private:
62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_;
64 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_;
65
66 #if DCHECK_IS_ON()
67 const base::PlatformThreadId main_thread_id_;
68 bool impl_thread_is_overridden_;
69 bool is_main_thread_blocked_;
70 #endif
71
72 DISALLOW_COPY_AND_ASSIGN(TaskRunnerProvider);
73 };
74
75 #if DCHECK_IS_ON()
76 class DebugScopedSetMainThreadBlocked {
77 public:
78 explicit DebugScopedSetMainThreadBlocked(
79 TaskRunnerProvider* task_runner_provider)
80 : task_runner_provider_(task_runner_provider) {
81 DCHECK(!task_runner_provider_->IsMainThreadBlocked());
82 task_runner_provider_->SetMainThreadBlocked(true);
83 }
84 ~DebugScopedSetMainThreadBlocked() {
85 DCHECK(task_runner_provider_->IsMainThreadBlocked());
86 task_runner_provider_->SetMainThreadBlocked(false);
87 }
88
89 private:
90 TaskRunnerProvider* task_runner_provider_;
91 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked);
92 };
93 #else
94 class DebugScopedSetMainThreadBlocked {
95 public:
96 explicit DebugScopedSetMainThreadBlocked(
97 TaskRunnerProvider* task_runner_provider) {}
98 ~DebugScopedSetMainThreadBlocked() {}
99
100 private:
101 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked);
102 };
103 #endif
104
105 } // namespace cc
106
107 #endif // CC_TREES_TASK_RUNNER_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/task_runner_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698