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

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

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_internal.h ('k') | mojo/edk/util/weak_ptr_unittest.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 #include "mojo/edk/util/weak_ptr_internal.h"
6
7 #include <assert.h>
8
9 namespace mojo {
10 namespace util {
11 namespace internal {
12
13 WeakPtrFlag::WeakPtrFlag() : is_valid_(true) {}
14
15 WeakPtrFlag::~WeakPtrFlag() {
16 // Should be invalidated before destruction.
17 assert(!is_valid_);
18 }
19
20 void WeakPtrFlag::Invalidate() {
21 // Invalidation should happen exactly once.
22 assert(is_valid_);
23 is_valid_ = false;
24 }
25
26 } // namespace internal
27 } // namespace util
28 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/util/weak_ptr_internal.h ('k') | mojo/edk/util/weak_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698