| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/ios/weak_nsobject.h" | 5 #include "base/ios/weak_nsobject.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsautorelease_pool.h" | 7 #include "base/mac/scoped_nsautorelease_pool.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 // The key needed by objc_setAssociatedObject. | 11 // The key needed by objc_setAssociatedObject. |
| 12 char sentinelObserverKey_; | 12 char sentinelObserverKey_; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace base { |
| 16 |
| 17 WeakContainer::WeakContainer(id object) : object_(object) {} |
| 18 |
| 19 WeakContainer::~WeakContainer() {} |
| 20 |
| 21 } // namespace base |
| 22 |
| 15 @interface CRBWeakNSProtocolSentinel () | 23 @interface CRBWeakNSProtocolSentinel () |
| 16 // Container to notify on dealloc. | 24 // Container to notify on dealloc. |
| 17 @property(readonly, assign) scoped_refptr<base::WeakContainer> container; | 25 @property(readonly, assign) scoped_refptr<base::WeakContainer> container; |
| 18 // Designed initializer. | 26 // Designed initializer. |
| 19 - (id)initWithContainer:(scoped_refptr<base::WeakContainer>)container; | 27 - (id)initWithContainer:(scoped_refptr<base::WeakContainer>)container; |
| 20 @end | 28 @end |
| 21 | 29 |
| 22 @implementation CRBWeakNSProtocolSentinel | 30 @implementation CRBWeakNSProtocolSentinel |
| 23 | 31 |
| 24 @synthesize container = container_; | 32 @synthesize container = container_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 container_ = container; | 60 container_ = container; |
| 53 return self; | 61 return self; |
| 54 } | 62 } |
| 55 | 63 |
| 56 - (void)dealloc { | 64 - (void)dealloc { |
| 57 self.container->nullify(); | 65 self.container->nullify(); |
| 58 [super dealloc]; | 66 [super dealloc]; |
| 59 } | 67 } |
| 60 | 68 |
| 61 @end | 69 @end |
| OLD | NEW |