| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/glue/webthread_impl.h" | 8 #include "webkit/glue/webthread_impl.h" |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void WebThreadImplForMessageLoop::postTask(Task* task) { | 98 void WebThreadImplForMessageLoop::postTask(Task* task) { |
| 99 message_loop_->PostTask( | 99 message_loop_->PostTask( |
| 100 FROM_HERE, base::Bind(&WebKit::WebThread::Task::run, base::Owned(task))); | 100 FROM_HERE, base::Bind(&WebKit::WebThread::Task::run, base::Owned(task))); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void WebThreadImplForMessageLoop::postDelayedTask( | 103 void WebThreadImplForMessageLoop::postDelayedTask( |
| 104 Task* task, long long delay_ms) { | 104 Task* task, long long delay_ms) { |
| 105 message_loop_->PostDelayedTask( | 105 message_loop_->PostDelayedTask( |
| 106 FROM_HERE, | 106 FROM_HERE, |
| 107 base::Bind(&WebKit::WebThread::Task::run, base::Owned(task)), | 107 base::Bind(&WebKit::WebThread::Task::run, base::Owned(task)), |
| 108 delay_ms); | 108 base::TimeDelta::FromMilliseconds(delay_ms)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WebThreadImplForMessageLoop::enterRunLoop() { | 111 void WebThreadImplForMessageLoop::enterRunLoop() { |
| 112 CHECK(IsCurrentThread()); | 112 CHECK(IsCurrentThread()); |
| 113 CHECK(!MessageLoop::current()->is_running()); // We don't support nesting. | 113 CHECK(!MessageLoop::current()->is_running()); // We don't support nesting. |
| 114 MessageLoop::current()->Run(); | 114 MessageLoop::current()->Run(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void WebThreadImplForMessageLoop::exitRunLoop() { | 117 void WebThreadImplForMessageLoop::exitRunLoop() { |
| 118 CHECK(IsCurrentThread()); | 118 CHECK(IsCurrentThread()); |
| 119 CHECK(MessageLoop::current()->is_running()); | 119 CHECK(MessageLoop::current()->is_running()); |
| 120 MessageLoop::current()->Quit(); | 120 MessageLoop::current()->Quit(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool WebThreadImplForMessageLoop::IsCurrentThread() const { | 123 bool WebThreadImplForMessageLoop::IsCurrentThread() const { |
| 124 return message_loop_->BelongsToCurrentThread(); | 124 return message_loop_->BelongsToCurrentThread(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() { | 127 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() { |
| 128 } | 128 } |
| 129 | 129 |
| 130 } | 130 } |
| OLD | NEW |