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