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

Side by Side Diff: components/sync/base/weak_handle.h

Issue 2427803002: [Sync] Replacing NULL with nullptr in code and null in comments for components/sync/ (Closed)
Patch Set: Fixing start of sentence capitlization. Created 4 years, 2 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 handles provides a way to refer to weak pointers from another 5 // Weak handles provides a way to refer to weak pointers from another
6 // thread. This is useful because it is not safe to reference a weak 6 // thread. This is useful because it is not safe to reference a weak
7 // pointer from a thread other than the thread on which it was 7 // pointer from a thread other than the thread on which it was
8 // created. 8 // created.
9 // 9 //
10 // Weak handles can be passed across threads, so for example, you can 10 // Weak handles can be passed across threads, so for example, you can
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 : core_(new internal::WeakHandleCore<T>(ptr)) {} 151 : core_(new internal::WeakHandleCore<T>(ptr)) {}
152 152
153 // Allow conversion from WeakHandle<U> to WeakHandle<T> if U is 153 // Allow conversion from WeakHandle<U> to WeakHandle<T> if U is
154 // convertible to T, but we *must* be on |other|'s owner thread. 154 // convertible to T, but we *must* be on |other|'s owner thread.
155 // Note that this doesn't override the regular copy constructor, so 155 // Note that this doesn't override the regular copy constructor, so
156 // that one can be called on any thread. 156 // that one can be called on any thread.
157 template <typename U> 157 template <typename U>
158 WeakHandle(const WeakHandle<U>& other) // NOLINT 158 WeakHandle(const WeakHandle<U>& other) // NOLINT
159 : core_(other.IsInitialized() 159 : core_(other.IsInitialized()
160 ? new internal::WeakHandleCore<T>(other.Get()) 160 ? new internal::WeakHandleCore<T>(other.Get())
161 : NULL) {} 161 : nullptr) {}
162 162
163 // Returns true iff this WeakHandle is initialized. Note that being 163 // Returns true iff this WeakHandle is initialized. Note that being
164 // initialized isn't a guarantee that the underlying object is still 164 // initialized isn't a guarantee that the underlying object is still
165 // alive. 165 // alive.
166 bool IsInitialized() const { return core_.get() != NULL; } 166 bool IsInitialized() const { return core_.get() != nullptr; }
167 167
168 // Resets to an uninitialized WeakHandle. 168 // Resets to an uninitialized WeakHandle.
169 void Reset() { core_ = NULL; } 169 void Reset() { core_ = nullptr; }
170 170
171 // Must be called only on the underlying object's owner thread. 171 // Must be called only on the underlying object's owner thread.
172 base::WeakPtr<T> Get() const { 172 base::WeakPtr<T> Get() const {
173 CHECK(IsInitialized()); 173 CHECK(IsInitialized());
174 CHECK(core_->IsOnOwnerThread()); 174 CHECK(core_->IsOnOwnerThread());
175 return core_->Get(); 175 return core_->Get();
176 } 176 }
177 177
178 // Call(...) may be called on any thread, but all its arguments 178 // Call(...) may be called on any thread, but all its arguments
179 // should be safe to be bound and copied across threads. 179 // should be safe to be bound and copied across threads.
(...skipping 14 matching lines...) Expand all
194 194
195 // Makes a WeakHandle from a WeakPtr. 195 // Makes a WeakHandle from a WeakPtr.
196 template <typename T> 196 template <typename T>
197 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) { 197 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) {
198 return WeakHandle<T>(ptr); 198 return WeakHandle<T>(ptr);
199 } 199 }
200 200
201 } // namespace syncer 201 } // namespace syncer
202 202
203 #endif // COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_ 203 #endif // COMPONENTS_SYNC_BASE_WEAK_HANDLE_H_
OLDNEW
« no previous file with comments | « components/sync/base/sync_prefs.cc ('k') | components/sync/device_info/device_info_data_type_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698