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

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

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/trees/proxy.h ('k') | cc/trees/single_thread_proxy.h » ('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" 5 #include "cc/trees/proxy.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "cc/trees/blocking_task_runner.h" 9 #include "cc/trees/blocking_task_runner.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const { 13 base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const {
14 return main_task_runner_.get(); 14 return main_task_runner_.get();
15 } 15 }
16 16
17 bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); } 17 bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); }
18 18
19 base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const { 19 base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const {
20 return impl_task_runner_.get(); 20 return impl_task_runner_.get();
21 } 21 }
22 22
23 bool Proxy::IsMainThread() const { 23 bool Proxy::IsMainThread() const {
24 #if DCHECK_IS_ON 24 #if DCHECK_IS_ON()
25 if (impl_thread_is_overridden_) 25 if (impl_thread_is_overridden_)
26 return false; 26 return false;
27 27
28 bool is_main_thread = base::PlatformThread::CurrentId() == main_thread_id_; 28 bool is_main_thread = base::PlatformThread::CurrentId() == main_thread_id_;
29 if (is_main_thread && main_task_runner_.get()) { 29 if (is_main_thread && main_task_runner_.get()) {
30 DCHECK(main_task_runner_->BelongsToCurrentThread()); 30 DCHECK(main_task_runner_->BelongsToCurrentThread());
31 } 31 }
32 return is_main_thread; 32 return is_main_thread;
33 #else 33 #else
34 return true; 34 return true;
35 #endif 35 #endif
36 } 36 }
37 37
38 bool Proxy::IsImplThread() const { 38 bool Proxy::IsImplThread() const {
39 #if DCHECK_IS_ON 39 #if DCHECK_IS_ON()
40 if (impl_thread_is_overridden_) 40 if (impl_thread_is_overridden_)
41 return true; 41 return true;
42 if (!impl_task_runner_.get()) 42 if (!impl_task_runner_.get())
43 return false; 43 return false;
44 return impl_task_runner_->BelongsToCurrentThread(); 44 return impl_task_runner_->BelongsToCurrentThread();
45 #else 45 #else
46 return true; 46 return true;
47 #endif 47 #endif
48 } 48 }
49 49
50 #if DCHECK_IS_ON 50 #if DCHECK_IS_ON()
51 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread) { 51 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread) {
52 impl_thread_is_overridden_ = is_impl_thread; 52 impl_thread_is_overridden_ = is_impl_thread;
53 } 53 }
54 #endif 54 #endif
55 55
56 bool Proxy::IsMainThreadBlocked() const { 56 bool Proxy::IsMainThreadBlocked() const {
57 #if DCHECK_IS_ON 57 #if DCHECK_IS_ON()
58 return is_main_thread_blocked_; 58 return is_main_thread_blocked_;
59 #else 59 #else
60 return true; 60 return true;
61 #endif 61 #endif
62 } 62 }
63 63
64 #if DCHECK_IS_ON 64 #if DCHECK_IS_ON()
65 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) { 65 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) {
66 is_main_thread_blocked_ = is_main_thread_blocked; 66 is_main_thread_blocked_ = is_main_thread_blocked;
67 } 67 }
68 #endif 68 #endif
69 69
70 Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 70 Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
71 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) 71 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
72 #if !DCHECK_IS_ON 72 #if !DCHECK_IS_ON()
73 : main_task_runner_(main_task_runner), 73 : main_task_runner_(main_task_runner),
74 impl_task_runner_(impl_task_runner), 74 impl_task_runner_(impl_task_runner),
75 blocking_main_thread_task_runner_( 75 blocking_main_thread_task_runner_(
76 BlockingTaskRunner::Create(main_task_runner)) { 76 BlockingTaskRunner::Create(main_task_runner)) {
77 #else 77 #else
78 : main_task_runner_(main_task_runner), 78 : main_task_runner_(main_task_runner),
79 impl_task_runner_(impl_task_runner), 79 impl_task_runner_(impl_task_runner),
80 blocking_main_thread_task_runner_( 80 blocking_main_thread_task_runner_(
81 BlockingTaskRunner::Create(main_task_runner)), 81 BlockingTaskRunner::Create(main_task_runner)),
82 main_thread_id_(base::PlatformThread::CurrentId()), 82 main_thread_id_(base::PlatformThread::CurrentId()),
83 impl_thread_is_overridden_(false), 83 impl_thread_is_overridden_(false),
84 is_main_thread_blocked_(false) { 84 is_main_thread_blocked_(false) {
85 #endif 85 #endif
86 } 86 }
87 87
88 Proxy::~Proxy() { 88 Proxy::~Proxy() {
89 DCHECK(IsMainThread()); 89 DCHECK(IsMainThread());
90 } 90 }
91 91
92 } // namespace cc 92 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/proxy.h ('k') | cc/trees/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698