summaryrefslogtreecommitdiff
path: root/gn/base/memory/ref_counted.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gn/base/memory/ref_counted.cc')
-rw-r--r--gn/base/memory/ref_counted.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/gn/base/memory/ref_counted.cc b/gn/base/memory/ref_counted.cc
new file mode 100644
index 00000000000..79ab8535a5e
--- /dev/null
+++ b/gn/base/memory/ref_counted.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 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 "base/memory/ref_counted.h"
+
+namespace base {
+
+namespace subtle {
+
+bool RefCountedThreadSafeBase::HasOneRef() const {
+ return ref_count_.IsOne();
+}
+
+#if defined(ARCH_CPU_64_BIT)
+void RefCountedBase::AddRefImpl() const {
+ // Check if |ref_count_| overflow only on 64 bit archs since the number of
+ // objects may exceed 2^32.
+ // To avoid the binary size bloat, use non-inline function here.
+ CHECK(++ref_count_ > 0);
+}
+#endif
+
+#if !defined(ARCH_CPU_X86_FAMILY)
+bool RefCountedThreadSafeBase::Release() const {
+ return ReleaseImpl();
+}
+void RefCountedThreadSafeBase::AddRef() const {
+ AddRefImpl();
+}
+#endif
+
+} // namespace subtle
+
+} // namespace base