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

Unified Diff: skia/config/sk_ref_cnt_ext_debug.h

Issue 40973002: Enable reference adoption checks for Blink+skia in Debug builds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Just the Chromium changes for sanity. 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
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/config/sk_ref_cnt_ext_release.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/config/sk_ref_cnt_ext_debug.h
===================================================================
--- skia/config/sk_ref_cnt_ext_debug.h (revision 0)
+++ skia/config/sk_ref_cnt_ext_debug.h (working copy)
@@ -0,0 +1,48 @@
+// 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_EXT_DEBUG_H_
+#define SK_REF_CNT_EXT_DEBUG_H_
+
+#ifdef SK_REF_CNT_EXT_RELEASE_H_
+#error Only one SkRefCnt should be used.
+#endif
+
+// Alternate implementation of SkRefCnt for Chromium debug builds
+class SK_API SkRefCnt : public SkRefCntBase {
+public:
+ SkRefCnt() : flags_(0) {}
+ void ref() const { SkASSERT(flags_ != AdoptionRequired_Flag); SkRefCntBase::ref(); }
+ void adopted() const { flags_ |= Adopted_Flag; }
+ void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
+ void deref() const { SkRefCntBase::unref(); }
+private:
+ enum {
+ Adopted_Flag = 0x1,
+ AdoptionRequired_Flag = 0x2,
+ };
+
+ mutable int flags_;
+};
+
+// Bootstrap for Blink's WTF::RefPtr
+
+namespace WTF {
+ inline void adopted(const SkRefCnt* object) {
+ if (!object)
+ return;
+ object->adopted();
+ }
+ inline void requireAdoption(const SkRefCnt* object) {
+ if (!object)
+ return;
+ object->requireAdoption();
+ }
+};
+
+using WTF::adopted;
+using WTF::requireAdoption;
+
+#endif
+
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/config/sk_ref_cnt_ext_release.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698