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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/files/file_posix.cc ('k') | base/ios/weak_nsobject_unittest.mm » ('j') | 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 #ifndef BASE_IOS_WEAK_NSOBJECT_H_ 5 #ifndef BASE_IOS_WEAK_NSOBJECT_H_
6 #define BASE_IOS_WEAK_NSOBJECT_H_ 6 #define BASE_IOS_WEAK_NSOBJECT_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 #import <objc/runtime.h> 9 #import <objc/runtime.h>
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 NST get() const { 112 NST get() const {
113 DCHECK(checker_.CalledOnValidThread()); 113 DCHECK(checker_.CalledOnValidThread());
114 if (!container_.get()) 114 if (!container_.get())
115 return nil; 115 return nil;
116 return container_->object(); 116 return container_->object();
117 } 117 }
118 118
119 WeakNSProtocol& operator=(const WeakNSProtocol<NST>& that) { 119 WeakNSProtocol& operator=(const WeakNSProtocol<NST>& that) {
120 DCHECK(checker_.CalledOnValidThread()); 120 // A WeakNSProtocol object can be copied on one thread and used on
121 // another.
122 checker_.DetachFromThread();
121 container_ = that.container_; 123 container_ = that.container_;
122 return *this; 124 return *this;
123 } 125 }
124 126
125 bool operator==(NST that) const { 127 bool operator==(NST that) const {
126 DCHECK(checker_.CalledOnValidThread()); 128 DCHECK(checker_.CalledOnValidThread());
127 return get() == that; 129 return get() == that;
128 } 130 }
129 131
130 bool operator!=(NST that) const { 132 bool operator!=(NST that) const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 180
179 WeakNSObject& operator=(const WeakNSObject<id>& that) { 181 WeakNSObject& operator=(const WeakNSObject<id>& that) {
180 WeakNSProtocol<id>::operator=(that); 182 WeakNSProtocol<id>::operator=(that);
181 return *this; 183 return *this;
182 } 184 }
183 }; 185 };
184 186
185 } // namespace base 187 } // namespace base
186 188
187 #endif // BASE_IOS_WEAK_NSOBJECT_H_ 189 #endif // BASE_IOS_WEAK_NSOBJECT_H_
OLDNEW
« no previous file with comments | « base/files/file_posix.cc ('k') | base/ios/weak_nsobject_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698