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

Unified Diff: skia/config/sk_ref_cnt_base_debug.h

Issue 29763002: Enable reference adoption run time checks for Blink+skia in Debug builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing SK_API Created 7 years, 2 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
« skia/config/SkUserConfig.h ('K') | « skia/config/SkUserConfig.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/config/sk_ref_cnt_base_debug.h
diff --git a/skia/config/sk_ref_cnt_base_debug.h b/skia/config/sk_ref_cnt_base_debug.h
new file mode 100644
index 0000000000000000000000000000000000000000..95669f5e369b3e362a8d080975597141e858120a
--- /dev/null
+++ b/skia/config/sk_ref_cnt_base_debug.h
@@ -0,0 +1,43 @@
+// Copyright 2013 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.
+
+#ifndef SK_REF_CNT_BASE_DEBUG_H_
+#define SK_REF_CNT_BASE_DEBUG_H_
+
+// Alternate implementation of SkRefCntBase for Chromium debug builds
+class SK_API SkRefCntBase {
+public:
+ SkRefCntBase() : flags_(0) {}
+ void aboutToRef() const { SkASSERT(flags_ != AdoptionRequired_Flag); }
+ void adopted() const { flags_ |= Adopted_Flag; }
+ void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
+private:
+ enum {
+ Adopted_Flag = 0x1,
Stephen White 2013/10/21 22:11:28 Is the spacing on these enums really Chrome-correc
+ AdoptionRequired_Flag = 0x2,
+ };
+
+ mutable int flags_;
+};
+
+// Bootstrap for Blink's WTF::RefPtr
+
+namespace WTF {
+ inline void adopted(const SkRefCntBase* object) {
+ if (!object)
+ return;
+ object->adopted();
+ }
+ inline void requireAdoption(const SkRefCntBase* object) {
+ if (!object)
+ return;
+ object->requireAdoption();
+ }
+};
+
+using WTF::adopted;
+using WTF::requireAdoption;
+
+#endif
+
« skia/config/SkUserConfig.h ('K') | « skia/config/SkUserConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698