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

Side by Side Diff: ios/web/weak_nsobject_counter.h

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698