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

Side by Side Diff: sync/internal_api/public/util/weak_handle.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
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 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "base/memory/weak_ptr.h" 61 #include "base/memory/weak_ptr.h"
62 62
63 namespace base { 63 namespace base {
64 class MessageLoopProxy; 64 class MessageLoopProxy;
65 } // namespace base 65 } // namespace base
66 66
67 namespace tracked_objects { 67 namespace tracked_objects {
68 class Location; 68 class Location;
69 } // namespace tracked_objects 69 } // namespace tracked_objects
70 70
71 namespace csync { 71 namespace syncer {
72 72
73 template <typename T> class WeakHandle; 73 template <typename T> class WeakHandle;
74 74
75 namespace internal { 75 namespace internal {
76 // These classes are part of the WeakHandle implementation. DO NOT 76 // These classes are part of the WeakHandle implementation. DO NOT
77 // USE THESE CLASSES DIRECTLY YOURSELF. 77 // USE THESE CLASSES DIRECTLY YOURSELF.
78 78
79 // Adapted from base/callback_internal.h. 79 // Adapted from base/callback_internal.h.
80 80
81 template <typename T> 81 template <typename T>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 // Creates an initialized WeakHandle from |ptr|. 280 // Creates an initialized WeakHandle from |ptr|.
281 explicit WeakHandle(const base::WeakPtr<T>& ptr) 281 explicit WeakHandle(const base::WeakPtr<T>& ptr)
282 : core_(new internal::WeakHandleCore<T>(ptr)) {} 282 : core_(new internal::WeakHandleCore<T>(ptr)) {}
283 283
284 // Allow conversion from WeakHandle<U> to WeakHandle<T> if U is 284 // Allow conversion from WeakHandle<U> to WeakHandle<T> if U is
285 // convertible to T, but we *must* be on |other|'s owner thread. 285 // convertible to T, but we *must* be on |other|'s owner thread.
286 // Note that this doesn't override the regular copy constructor, so 286 // Note that this doesn't override the regular copy constructor, so
287 // that one can be called on any thread. 287 // that one can be called on any thread.
288 template <typename U> 288 template <typename U>
289 WeakHandle(const csync::WeakHandle<U>& other) // NOLINT 289 WeakHandle(const syncer::WeakHandle<U>& other) // NOLINT
290 : core_( 290 : core_(
291 other.IsInitialized() ? 291 other.IsInitialized() ?
292 new internal::WeakHandleCore<T>(other.Get()) : 292 new internal::WeakHandleCore<T>(other.Get()) :
293 NULL) {} 293 NULL) {}
294 294
295 // Returns true iff this WeakHandle is initialized. Note that being 295 // Returns true iff this WeakHandle is initialized. Note that being
296 // initialized isn't a guarantee that the underlying object is still 296 // initialized isn't a guarantee that the underlying object is still
297 // alive. 297 // alive.
298 bool IsInitialized() const { 298 bool IsInitialized() const {
299 return core_.get() != NULL; 299 return core_.get() != NULL;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 scoped_refptr<internal::WeakHandleCore<T> > core_; 368 scoped_refptr<internal::WeakHandleCore<T> > core_;
369 }; 369 };
370 370
371 // Makes a WeakHandle from a WeakPtr. 371 // Makes a WeakHandle from a WeakPtr.
372 template <typename T> 372 template <typename T>
373 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) { 373 WeakHandle<T> MakeWeakHandle(const base::WeakPtr<T>& ptr) {
374 return WeakHandle<T>(ptr); 374 return WeakHandle<T>(ptr);
375 } 375 }
376 376
377 } // namespace csync 377 } // namespace syncer
378 378
379 #endif // SYNC_UTIL_WEAK_HANDLE_H_ 379 #endif // SYNC_UTIL_WEAK_HANDLE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/util/unrecoverable_error_info.cc ('k') | sync/internal_api/public/util/weak_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698