OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // 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/task.h" | 10 #include "base/task.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 WebThreadImpl::WebThreadImpl(const char* name) | 25 WebThreadImpl::WebThreadImpl(const char* name) |
26 : thread_(new base::Thread(name)) { | 26 : thread_(new base::Thread(name)) { |
27 thread_->Start(); | 27 thread_->Start(); |
28 } | 28 } |
29 | 29 |
30 void WebThreadImpl::postTask(Task* task) { | 30 void WebThreadImpl::postTask(Task* task) { |
31 thread_->message_loop()->PostTask(FROM_HERE, | 31 thread_->message_loop()->PostTask(FROM_HERE, |
32 new TaskAdapter(task)); | 32 new TaskAdapter(task)); |
33 } | 33 } |
34 #ifdef WEBTHREAD_HAS_LONGLONG_CHANGE | |
35 void WebThreadImpl::postDelayedTask( | 34 void WebThreadImpl::postDelayedTask( |
36 Task* task, long long delay_ms) { | 35 Task* task, long long delay_ms) { |
37 #else | |
38 void WebThreadImpl::postDelayedTask( | |
39 Task* task, int64 delay_ms) { | |
40 #endif | |
41 thread_->message_loop()->PostDelayedTask( | 36 thread_->message_loop()->PostDelayedTask( |
42 FROM_HERE, new TaskAdapter(task), delay_ms); | 37 FROM_HERE, new TaskAdapter(task), delay_ms); |
43 } | 38 } |
44 | 39 |
45 WebThreadImpl::~WebThreadImpl() { | 40 WebThreadImpl::~WebThreadImpl() { |
46 thread_->Stop(); | 41 thread_->Stop(); |
47 } | 42 } |
48 | 43 |
| 44 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( |
| 45 base::MessageLoopProxy* message_loop) |
| 46 : message_loop_(message_loop) { |
49 } | 47 } |
| 48 |
| 49 void WebThreadImplForMessageLoop::postTask(Task* task) { |
| 50 message_loop_->PostTask(FROM_HERE, new TaskAdapter(task)); |
| 51 } |
| 52 |
| 53 void WebThreadImplForMessageLoop::postDelayedTask( |
| 54 Task* task, long long delay_ms) { |
| 55 message_loop_->PostDelayedTask(FROM_HERE, new TaskAdapter(task), delay_ms); |
| 56 } |
| 57 |
| 58 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() { |
| 59 } |
| 60 |
| 61 } |
OLD | NEW |