Chromium Code Reviews| Index: remoting/base/task_thread_proxy.h |
| diff --git a/remoting/base/task_thread_proxy.h b/remoting/base/task_thread_proxy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..de410000e5da6d49daee7859ec4999c01d11b8e5 |
| --- /dev/null |
| +++ b/remoting/base/task_thread_proxy.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
|
Sergey Ulanov
2011/08/02 01:08:32
year
garykac
2011/08/02 02:13:31
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_BASE_TASK_THREAD_PROXY_H_ |
| +#define REMOTING_BASE_TASK_THREAD_PROXY_H_ |
| + |
| +#include "base/bind.h" |
| + |
| +namespace remoting { |
| + |
| +class TaskThreadProxy : public base::RefCountedThreadSafe<TaskThreadProxy> { |
|
Sergey Ulanov
2011/08/02 01:08:32
Please add some comments that explain when this cl
garykac
2011/08/02 02:13:31
Done.
|
| + public: |
| + TaskThreadProxy(MessageLoop* loop) |
| + : message_loop_(loop) { |
|
Sergey Ulanov
2011/08/02 01:08:32
Move implementation to task_thread_proxy.cc, other
garykac
2011/08/02 02:13:31
Done.
|
| + } |
| + |
| + // Detach is called when the message loop is about to be destroyed. |
|
Sergey Ulanov
2011/08/02 01:08:32
This comment is not correct. This method should be
garykac
2011/08/02 02:13:31
Done.
|
| + void Detach() { |
| + message_loop_ = NULL; |
| + } |
| + |
| + void Call(const base::Closure& closure) { |
| + if (message_loop_) { |
| + message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| + this, &TaskThreadProxy::CallClosure, closure)); |
| + } |
| + } |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<TaskThreadProxy>; |
| + |
| + virtual ~TaskThreadProxy() { |
| + } |
| + |
| + void CallClosure(const base::Closure& closure) { |
| + if (message_loop_) |
| + closure.Run(); |
| + } |
| + |
| + MessageLoop* message_loop_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TaskThreadProxy); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_BASE_TASK_THREAD_PROXY_H_ |