Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: base/ios/weak_nsobject.mm

Issue 2943263003: Make WeakContainer safe when weak_nsobject.h is included from ARC code. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/ios/weak_nsobject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/ios/weak_nsobject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698