Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef SK_REF_CNT_BASE_DEBUG_H_ | |
| 6 #define SK_REF_CNT_BASE_DEBUG_H_ | |
| 7 | |
| 8 // Alternate implementation of SkRefCntBase for Chromium debug builds | |
| 9 class SK_API SkRefCntBase { | |
| 10 public: | |
| 11 SkRefCntBase() : flags_(0) {} | |
| 12 void aboutToRef() const { SkASSERT(flags_ != AdoptionRequired_Flag); } | |
| 13 void adopted() const { flags_ |= Adopted_Flag; } | |
| 14 void requireAdoption() const { flags_ |= AdoptionRequired_Flag; } | |
| 15 private: | |
| 16 enum { | |
| 17 Adopted_Flag = 0x1, | |
|
Stephen White
2013/10/21 22:11:28
Is the spacing on these enums really Chrome-correc
| |
| 18 AdoptionRequired_Flag = 0x2, | |
| 19 }; | |
| 20 | |
| 21 mutable int flags_; | |
| 22 }; | |
| 23 | |
| 24 // Bootstrap for Blink's WTF::RefPtr | |
| 25 | |
| 26 namespace WTF { | |
| 27 inline void adopted(const SkRefCntBase* object) { | |
| 28 if (!object) | |
| 29 return; | |
| 30 object->adopted(); | |
| 31 } | |
| 32 inline void requireAdoption(const SkRefCntBase* object) { | |
| 33 if (!object) | |
| 34 return; | |
| 35 object->requireAdoption(); | |
| 36 } | |
| 37 }; | |
| 38 | |
| 39 using WTF::adopted; | |
| 40 using WTF::requireAdoption; | |
| 41 | |
| 42 #endif | |
| 43 | |
| OLD | NEW |