| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 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 IOS_WEB_WEAK_NSOBJECT_COUNTER_H_ |
| 6 #define IOS_WEB_WEAK_NSOBJECT_COUNTER_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/threading/non_thread_safe.h" |
| 12 |
| 13 namespace web { |
| 14 |
| 15 // WeakNSObjectCounter is a class to maintain a counter of all the objects |
| 16 // that are added using |Insert| that are alive. |
| 17 // This class is not thread safe and objects must be destroyed and created on |
| 18 // the same thread. |
| 19 // TODO(stuartmorgan): Remove this once ARC is supported. |
| 20 class WeakNSObjectCounter : public base::NonThreadSafe { |
| 21 public: |
| 22 WeakNSObjectCounter(); |
| 23 ~WeakNSObjectCounter(); |
| 24 // Inserts an object. |object| cannot be nil. |
| 25 void Insert(id object); |
| 26 // Returns the count of all active objects that have been inserted. |
| 27 NSUInteger Size() const; |
| 28 private: |
| 29 // The object that maintains the number of active items. |
| 30 linked_ptr<NSUInteger> counter_; |
| 31 }; |
| 32 |
| 33 } // namespace web |
| 34 |
| 35 #endif // IOS_WEB_WEAK_NSOBJECT_COUNTER_H_ |
| OLD | NEW |