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

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

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/task_runner_provider.h ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "cc/trees/proxy.h"
6
7 #include "base/single_thread_task_runner.h" 5 #include "base/single_thread_task_runner.h"
8 #include "cc/trees/blocking_task_runner.h" 6 #include "cc/trees/blocking_task_runner.h"
7 #include "cc/trees/task_runner_provider.h"
9 8
10 namespace cc { 9 namespace cc {
11 10
12 base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const { 11 base::SingleThreadTaskRunner* TaskRunnerProvider::MainThreadTaskRunner() const {
13 return main_task_runner_.get(); 12 return main_task_runner_.get();
14 } 13 }
15 14
16 bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); } 15 bool TaskRunnerProvider::HasImplThread() const {
16 return !!impl_task_runner_.get();
17 }
17 18
18 base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const { 19 base::SingleThreadTaskRunner* TaskRunnerProvider::ImplThreadTaskRunner() const {
19 return impl_task_runner_.get(); 20 return impl_task_runner_.get();
20 } 21 }
21 22
22 bool Proxy::IsMainThread() const { 23 bool TaskRunnerProvider::IsMainThread() const {
23 #if DCHECK_IS_ON() 24 #if DCHECK_IS_ON()
24 if (impl_thread_is_overridden_) 25 if (impl_thread_is_overridden_)
25 return false; 26 return false;
26 27
27 bool is_main_thread = base::PlatformThread::CurrentId() == main_thread_id_; 28 bool is_main_thread = base::PlatformThread::CurrentId() == main_thread_id_;
28 if (is_main_thread && main_task_runner_.get()) { 29 if (is_main_thread && main_task_runner_.get()) {
29 DCHECK(main_task_runner_->BelongsToCurrentThread()); 30 DCHECK(main_task_runner_->BelongsToCurrentThread());
30 } 31 }
31 return is_main_thread; 32 return is_main_thread;
32 #else 33 #else
33 return true; 34 return true;
34 #endif 35 #endif
35 } 36 }
36 37
37 bool Proxy::IsImplThread() const { 38 bool TaskRunnerProvider::IsImplThread() const {
38 #if DCHECK_IS_ON() 39 #if DCHECK_IS_ON()
39 if (impl_thread_is_overridden_) 40 if (impl_thread_is_overridden_)
40 return true; 41 return true;
41 if (!impl_task_runner_.get()) 42 if (!impl_task_runner_.get())
42 return false; 43 return false;
43 return impl_task_runner_->BelongsToCurrentThread(); 44 return impl_task_runner_->BelongsToCurrentThread();
44 #else 45 #else
45 return true; 46 return true;
46 #endif 47 #endif
47 } 48 }
48 49
49 #if DCHECK_IS_ON() 50 #if DCHECK_IS_ON()
50 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread) { 51 void TaskRunnerProvider::SetCurrentThreadIsImplThread(bool is_impl_thread) {
51 impl_thread_is_overridden_ = is_impl_thread; 52 impl_thread_is_overridden_ = is_impl_thread;
52 } 53 }
53 #endif 54 #endif
54 55
55 bool Proxy::IsMainThreadBlocked() const { 56 bool TaskRunnerProvider::IsMainThreadBlocked() const {
56 #if DCHECK_IS_ON() 57 #if DCHECK_IS_ON()
57 return is_main_thread_blocked_; 58 return is_main_thread_blocked_;
58 #else 59 #else
59 return true; 60 return true;
60 #endif 61 #endif
61 } 62 }
62 63
63 #if DCHECK_IS_ON() 64 #if DCHECK_IS_ON()
64 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) { 65 void TaskRunnerProvider::SetMainThreadBlocked(bool is_main_thread_blocked) {
65 is_main_thread_blocked_ = is_main_thread_blocked; 66 is_main_thread_blocked_ = is_main_thread_blocked;
66 } 67 }
67 #endif 68 #endif
68 69
69 Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 70 TaskRunnerProvider::TaskRunnerProvider(
70 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) 71 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
72 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
71 #if !DCHECK_IS_ON() 73 #if !DCHECK_IS_ON()
72 : main_task_runner_(main_task_runner), 74 : main_task_runner_(main_task_runner),
73 impl_task_runner_(impl_task_runner), 75 impl_task_runner_(impl_task_runner),
74 blocking_main_thread_task_runner_( 76 blocking_main_thread_task_runner_(
75 BlockingTaskRunner::Create(main_task_runner)) { 77 BlockingTaskRunner::Create(main_task_runner)) {
76 #else 78 #else
77 : main_task_runner_(main_task_runner), 79 : main_task_runner_(main_task_runner),
78 impl_task_runner_(impl_task_runner), 80 impl_task_runner_(impl_task_runner),
79 blocking_main_thread_task_runner_( 81 blocking_main_thread_task_runner_(
80 BlockingTaskRunner::Create(main_task_runner)), 82 BlockingTaskRunner::Create(main_task_runner)),
81 main_thread_id_(base::PlatformThread::CurrentId()), 83 main_thread_id_(base::PlatformThread::CurrentId()),
82 impl_thread_is_overridden_(false), 84 impl_thread_is_overridden_(false),
83 is_main_thread_blocked_(false) { 85 is_main_thread_blocked_(false) {
84 #endif 86 #endif
85 } 87 }
86 88
87 Proxy::~Proxy() { 89 TaskRunnerProvider::~TaskRunnerProvider() {
88 DCHECK(IsMainThread()); 90 DCHECK(IsMainThread());
89 } 91 }
90 92
91 } // namespace cc 93 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/task_runner_provider.h ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698