| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef REMOTING_BASE_SCOPED_THREAD_PROXY_H_ | 5 #ifndef REMOTING_BASE_SCOPED_THREAD_PROXY_H_ |
| 6 #define REMOTING_BASE_SCOPED_THREAD_PROXY_H_ | 6 #define REMOTING_BASE_SCOPED_THREAD_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 | 10 |
| 11 namespace remoting { | 11 namespace remoting { |
| 12 | 12 |
| 13 // ScopedThreadProxy is proxy for message loops that cancels all | 13 // ScopedThreadProxy is proxy for message loops that cancels all |
| 14 // pending tasks when it is destroyed. It can be used to post tasks | 14 // pending tasks when it is destroyed. It can be used to post tasks |
| 15 // for a non-refcounted object. Must be deleted on the thread it | 15 // for a non-refcounted object. Must be deleted on the thread it |
| 16 // belongs to. | 16 // belongs to. |
| 17 // | 17 // |
| 18 // The main difference from WeakPtr<> and ScopedRunnableMethodFactory<> | 18 // |
| 19 // is that this class can be used safely to post tasks from different | 19 // The main difference from WeakPtr<> is that this class can be used safely to |
| 20 // threads. | 20 // post tasks from different threads. |
| 21 // It is similar to WeakHandle<> used in sync: the main difference is | 21 // It is similar to WeakHandle<> used in sync: the main difference is |
| 22 // that WeakHandle<> creates closures itself, while ScopedThreadProxy | 22 // that WeakHandle<> creates closures itself, while ScopedThreadProxy |
| 23 // accepts base::Closure instances which caller needs to create using | 23 // accepts base::Closure instances which caller needs to create using |
| 24 // base::Bind(). | 24 // base::Bind(). |
| 25 // | 25 // |
| 26 // TODO(sergeyu): Potentially we could use WeakHandle<> instead of | 26 // TODO(sergeyu): Potentially we could use WeakHandle<> instead of |
| 27 // this class. Consider migrating to WeakHandle<> when it is moved to | 27 // this class. Consider migrating to WeakHandle<> when it is moved to |
| 28 // src/base and support for delayed tasks is implemented. | 28 // src/base and support for delayed tasks is implemented. |
| 29 // | 29 // |
| 30 // Usage: | 30 // Usage: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 class Core; | 64 class Core; |
| 65 | 65 |
| 66 scoped_refptr<Core> core_; | 66 scoped_refptr<Core> core_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy); | 68 DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 } // namespace remoting | 71 } // namespace remoting |
| 72 | 72 |
| 73 #endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_ | 73 #endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_ |
| OLD | NEW |