OLD | NEW |
1 // Copyright (c) 2012 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 // Weak pointers are pointers to an object that do not affect its lifetime, | 5 // Weak pointers are pointers to an object that do not affect its lifetime, |
6 // and which may be invalidated (i.e. reset to NULL) by the object, or its | 6 // and which may be invalidated (i.e. reset to NULL) by the object, or its |
7 // owner, at any time, most commonly when the object is about to be deleted. | 7 // owner, at any time, most commonly when the object is about to be deleted. |
8 | 8 |
9 // Weak pointers are useful when an object needs to be accessed safely by one | 9 // Weak pointers are useful when an object needs to be accessed safely by one |
10 // or more objects other than its owner, and those callers can cope with the | 10 // or more objects other than its owner, and those callers can cope with the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be | 63 // unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be |
64 // destroyed, or new WeakPtr objects may be used, from a different sequence. | 64 // destroyed, or new WeakPtr objects may be used, from a different sequence. |
65 // | 65 // |
66 // Thus, at least one WeakPtr object must exist and have been dereferenced on | 66 // Thus, at least one WeakPtr object must exist and have been dereferenced on |
67 // the correct thread to enforce that other WeakPtr objects will enforce they | 67 // the correct thread to enforce that other WeakPtr objects will enforce they |
68 // are used on the desired thread. | 68 // are used on the desired thread. |
69 | 69 |
70 #ifndef BASE_MEMORY_WEAK_PTR_H_ | 70 #ifndef BASE_MEMORY_WEAK_PTR_H_ |
71 #define BASE_MEMORY_WEAK_PTR_H_ | 71 #define BASE_MEMORY_WEAK_PTR_H_ |
72 | 72 |
73 #include "base/basictypes.h" | |
74 #include "base/base_export.h" | 73 #include "base/base_export.h" |
75 #include "base/logging.h" | 74 #include "base/logging.h" |
| 75 #include "base/macros.h" |
76 #include "base/memory/ref_counted.h" | 76 #include "base/memory/ref_counted.h" |
77 #include "base/sequence_checker.h" | 77 #include "base/sequence_checker.h" |
78 #include "base/template_util.h" | 78 #include "base/template_util.h" |
79 | 79 |
80 namespace base { | 80 namespace base { |
81 | 81 |
82 template <typename T> class SupportsWeakPtr; | 82 template <typename T> class SupportsWeakPtr; |
83 template <typename T> class WeakPtr; | 83 template <typename T> class WeakPtr; |
84 | 84 |
85 namespace internal { | 85 namespace internal { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails. | 336 // base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails. |
337 | 337 |
338 template <typename Derived> | 338 template <typename Derived> |
339 WeakPtr<Derived> AsWeakPtr(Derived* t) { | 339 WeakPtr<Derived> AsWeakPtr(Derived* t) { |
340 return internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t); | 340 return internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t); |
341 } | 341 } |
342 | 342 |
343 } // namespace base | 343 } // namespace base |
344 | 344 |
345 #endif // BASE_MEMORY_WEAK_PTR_H_ | 345 #endif // BASE_MEMORY_WEAK_PTR_H_ |
OLD | NEW |