LayoutTestPermissionManager: pass top level origin, not URL.
[chromium-blink-merge.git] / ios / web / weak_nsobject_counter.h
blobf5fb62fa75d493d58f0df78232fe2f661a45d59c
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.
5 #ifndef IOS_WEB_WEAK_NSOBJECT_COUNTER_H_
6 #define IOS_WEB_WEAK_NSOBJECT_COUNTER_H_
8 #import <Foundation/Foundation.h>
10 #include "base/memory/linked_ptr.h"
11 #include "base/threading/non_thread_safe.h"
13 namespace web {
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_;
33 } // namespace web
35 #endif // IOS_WEB_WEAK_NSOBJECT_COUNTER_H_