1 // Copyright 2018 PDFium 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 TESTING_PSEUDO_RETAINABLE_H_ 6 #define TESTING_PSEUDO_RETAINABLE_H_ 7 8 class PseudoRetainable { 9 public: 10 PseudoRetainable() = default; Retain()11 void Retain() { ++retain_count_; } Release()12 void Release() { 13 if (++release_count_ == retain_count_) 14 alive_ = false; 15 } alive()16 bool alive() const { return alive_; } retain_count()17 int retain_count() const { return retain_count_; } release_count()18 int release_count() const { return release_count_; } 19 20 private: 21 bool alive_ = true; 22 int retain_count_ = 0; 23 int release_count_ = 0; 24 }; 25 26 #endif // TESTING_PSEUDO_RETAINABLE_H_ 27