OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // An implementation of WebThread in terms of base::MessageLoop and | 5 // An implementation of WebThread in terms of base::MessageLoop and |
6 // base::Thread | 6 // base::Thread |
7 | 7 |
8 #include "content/child/webthread_impl.h" | 8 #include "content/child/webthread_impl.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void WebThreadImpl::exitRunLoop() { | 81 void WebThreadImpl::exitRunLoop() { |
82 CHECK(isCurrentThread()); | 82 CHECK(isCurrentThread()); |
83 CHECK(thread_->message_loop()->is_running()); | 83 CHECK(thread_->message_loop()->is_running()); |
84 thread_->message_loop()->Quit(); | 84 thread_->message_loop()->Quit(); |
85 } | 85 } |
86 | 86 |
87 bool WebThreadImpl::isCurrentThread() const { | 87 bool WebThreadImpl::isCurrentThread() const { |
88 return thread_->thread_id() == base::PlatformThread::CurrentId(); | 88 return thread_->thread_id() == base::PlatformThread::CurrentId(); |
89 } | 89 } |
90 | 90 |
| 91 blink::PlatformThreadId WebThreadImpl::threadId() const { |
| 92 return thread_->thread_id(); |
| 93 } |
| 94 |
91 WebThreadImpl::~WebThreadImpl() { | 95 WebThreadImpl::~WebThreadImpl() { |
92 thread_->Stop(); | 96 thread_->Stop(); |
93 } | 97 } |
94 | 98 |
95 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( | 99 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( |
96 base::MessageLoopProxy* message_loop) | 100 base::MessageLoopProxy* message_loop) |
97 : message_loop_(message_loop) {} | 101 : message_loop_(message_loop), |
| 102 thread_id_(base::PlatformThread::CurrentId()) {} |
98 | 103 |
99 void WebThreadImplForMessageLoop::postTask(Task* task) { | 104 void WebThreadImplForMessageLoop::postTask(Task* task) { |
100 message_loop_->PostTask( | 105 message_loop_->PostTask( |
101 FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task))); | 106 FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task))); |
102 } | 107 } |
103 | 108 |
104 void WebThreadImplForMessageLoop::postDelayedTask(Task* task, | 109 void WebThreadImplForMessageLoop::postDelayedTask(Task* task, |
105 long long delay_ms) { | 110 long long delay_ms) { |
106 message_loop_->PostDelayedTask( | 111 message_loop_->PostDelayedTask( |
107 FROM_HERE, | 112 FROM_HERE, |
(...skipping 11 matching lines...) Expand all Loading... |
119 void WebThreadImplForMessageLoop::exitRunLoop() { | 124 void WebThreadImplForMessageLoop::exitRunLoop() { |
120 CHECK(isCurrentThread()); | 125 CHECK(isCurrentThread()); |
121 CHECK(base::MessageLoop::current()->is_running()); | 126 CHECK(base::MessageLoop::current()->is_running()); |
122 base::MessageLoop::current()->Quit(); | 127 base::MessageLoop::current()->Quit(); |
123 } | 128 } |
124 | 129 |
125 bool WebThreadImplForMessageLoop::isCurrentThread() const { | 130 bool WebThreadImplForMessageLoop::isCurrentThread() const { |
126 return message_loop_->BelongsToCurrentThread(); | 131 return message_loop_->BelongsToCurrentThread(); |
127 } | 132 } |
128 | 133 |
| 134 blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const { |
| 135 return thread_id_; |
| 136 } |
| 137 |
129 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} | 138 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} |
130 | 139 |
131 } // namespace content | 140 } // namespace content |
OLD | NEW |