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 "mojo/services/html_viewer/webthread_impl.h" | 8 #include "mojo/services/html_viewer/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) {} |
98 | 102 |
99 void WebThreadImplForMessageLoop::postTask(Task* task) { | 103 void WebThreadImplForMessageLoop::postTask(Task* task) { |
100 message_loop_->PostTask( | 104 message_loop_->PostTask( |
(...skipping 18 matching lines...) Expand all Loading... |
119 void WebThreadImplForMessageLoop::exitRunLoop() { | 123 void WebThreadImplForMessageLoop::exitRunLoop() { |
120 CHECK(isCurrentThread()); | 124 CHECK(isCurrentThread()); |
121 CHECK(base::MessageLoop::current()->is_running()); | 125 CHECK(base::MessageLoop::current()->is_running()); |
122 base::MessageLoop::current()->Quit(); | 126 base::MessageLoop::current()->Quit(); |
123 } | 127 } |
124 | 128 |
125 bool WebThreadImplForMessageLoop::isCurrentThread() const { | 129 bool WebThreadImplForMessageLoop::isCurrentThread() const { |
126 return message_loop_->BelongsToCurrentThread(); | 130 return message_loop_->BelongsToCurrentThread(); |
127 } | 131 } |
128 | 132 |
| 133 blink::PlatformThreadId WebThreadImplForMessageLoop::threadId() const { |
| 134 return thread_id_; |
| 135 } |
| 136 |
129 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} | 137 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} |
130 | 138 |
131 } // namespace mojo | 139 } // namespace mojo |
OLD | NEW |