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 |