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

Side by Side Diff: mojo/edk/util/weak_ptr_internal.h

Issue 1646113002: Bring in a reduced/simplified version of Chromium's base::WeakPtr to //mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: review Created 4 years, 10 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 | « mojo/edk/util/weak_ptr.h ('k') | mojo/edk/util/weak_ptr_internal.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_UTIL_WEAK_PTR_INTERNAL_H_
6 #define MOJO_UTIL_WEAK_PTR_INTERNAL_H_
7
8 #include <assert.h>
9
10 #include "mojo/edk/util/ref_counted.h"
11 #include "mojo/public/cpp/system/macros.h"
12
13 namespace mojo {
14 namespace util {
15 namespace internal {
16
17 // |WeakPtr<T>|s have a reference to a |WeakPtrFlag| to determine whether they
18 // are valid (non-null) or not. We do not store a |T*| in this object since
19 // there may also be |WeakPtr<U>|s to the same object, where |U| is a superclass
20 // of |T|.
21 //
22 // This class in not thread-safe, though references may be released on any
23 // thread (allowing weak pointers to be destroyed/reset/reassigned on any
24 // thread).
25 class WeakPtrFlag : public RefCountedThreadSafe<WeakPtrFlag> {
26 public:
27 WeakPtrFlag();
28 ~WeakPtrFlag();
29
30 bool is_valid() const { return is_valid_; }
31
32 void Invalidate();
33
34 private:
35 bool is_valid_;
36
37 MOJO_DISALLOW_COPY_AND_ASSIGN(WeakPtrFlag);
38 };
39
40 } // namespace internal
41 } // namespace util
42 } // namespace mojo
43
44 #endif // MOJO_UTIL_WEAK_PTR_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/weak_ptr.h ('k') | mojo/edk/util/weak_ptr_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698