Chromium Code Reviews| 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 #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<> | |
|
Sergey Ulanov
2012/01/03 18:49:00
This comment is still useful to explain why WeakPt
James Hawkins
2012/01/03 21:13:54
Done.
| |
| 19 // is that this class can be used safely to post tasks from different | |
| 20 // threads. | |
| 21 // It is similar to WeakHandle<> used in sync: the main difference is | 18 // It is similar to WeakHandle<> used in sync: the main difference is |
| 22 // that WeakHandle<> creates closures itself, while ScopedThreadProxy | 19 // that WeakHandle<> creates closures itself, while ScopedThreadProxy |
| 23 // accepts base::Closure instances which caller needs to create using | 20 // accepts base::Closure instances which caller needs to create using |
| 24 // base::Bind(). | 21 // base::Bind(). |
| 25 // | 22 // |
| 26 // TODO(sergeyu): Potentially we could use WeakHandle<> instead of | 23 // TODO(sergeyu): Potentially we could use WeakHandle<> instead of |
| 27 // this class. Consider migrating to WeakHandle<> when it is moved to | 24 // this class. Consider migrating to WeakHandle<> when it is moved to |
| 28 // src/base and support for delayed tasks is implemented. | 25 // src/base and support for delayed tasks is implemented. |
| 29 // | 26 // |
| 30 // Usage: | 27 // Usage: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 class Core; | 61 class Core; |
| 65 | 62 |
| 66 scoped_refptr<Core> core_; | 63 scoped_refptr<Core> core_; |
| 67 | 64 |
| 68 DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy); | 65 DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy); |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 } // namespace remoting | 68 } // namespace remoting |
| 72 | 69 |
| 73 #endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_ | 70 #endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_ |
| OLD | NEW |