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

Unified 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, 11 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/util/weak_ptr_internal.cc
diff --git a/mojo/edk/util/weak_ptr_internal.cc b/mojo/edk/util/weak_ptr_internal.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f6047ae51715756f0e409f13308ca58da512c138
--- /dev/null
+++ b/mojo/edk/util/weak_ptr_internal.cc
@@ -0,0 +1,28 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/edk/util/weak_ptr_internal.h"
+
+#include <assert.h>
+
+namespace mojo {
+namespace util {
+namespace internal {
+
+WeakPtrFlag::WeakPtrFlag() : is_valid_(true) {}
+
+WeakPtrFlag::~WeakPtrFlag() {
+ // Should be invalidated before destruction.
+ assert(!is_valid_);
+}
+
+void WeakPtrFlag::Invalidate() {
+ // Invalidation should happen exactly once.
+ assert(is_valid_);
+ is_valid_ = false;
+}
+
+} // namespace internal
+} // namespace util
+} // namespace mojo
« 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