| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 BASE_MESSAGE_LOOP_PROXY_H_ | 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_ |
| 6 #define BASE_MESSAGE_LOOP_PROXY_H_ | 6 #define BASE_MESSAGE_LOOP_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 T* object) { | 48 T* object) { |
| 49 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); | 49 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Factory method for creating an implementation of MessageLoopProxy | 52 // Factory method for creating an implementation of MessageLoopProxy |
| 53 // for the current thread. | 53 // for the current thread. |
| 54 static scoped_refptr<MessageLoopProxy> CreateForCurrentThread(); | 54 static scoped_refptr<MessageLoopProxy> CreateForCurrentThread(); |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 friend struct MessageLoopProxyTraits; | 57 friend struct MessageLoopProxyTraits; |
| 58 |
| 59 virtual ~MessageLoopProxy() { } |
| 60 |
| 58 // Called when the proxy is about to be deleted. Subclasses can override this | 61 // Called when the proxy is about to be deleted. Subclasses can override this |
| 59 // to provide deletion on specific threads. | 62 // to provide deletion on specific threads. |
| 60 virtual void OnDestruct() { | 63 virtual void OnDestruct() { |
| 61 delete this; | 64 delete this; |
| 62 } | 65 } |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 struct MessageLoopProxyTraits { | 68 struct MessageLoopProxyTraits { |
| 66 static void Destruct(MessageLoopProxy* proxy) { | 69 static void Destruct(MessageLoopProxy* proxy) { |
| 67 proxy->OnDestruct(); | 70 proxy->OnDestruct(); |
| 68 } | 71 } |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace base | 74 } // namespace base |
| 72 | 75 |
| 73 #endif // BASE_MESSAGE_LOOP_PROXY_H_ | 76 #endif // BASE_MESSAGE_LOOP_PROXY_H_ |
| 74 | 77 |
| OLD | NEW |