Index: chrome/common/extensions/value_set.h |
diff --git a/chrome/common/extensions/value_set.h b/chrome/common/extensions/value_set.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..90f1bc748cb29d62c3199d6ab30a5ef8c068b1f8 |
--- /dev/null |
+++ b/chrome/common/extensions/value_set.h |
@@ -0,0 +1,51 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_COMMON_EXTENSIONS_VALUE_SET_H_ |
+#define CHROME_COMMON_EXTENSIONS_VALUE_SET_H_ |
+#pragma once |
+ |
+#include "base/memory/linked_ptr.h" |
+ |
+#include <vector> |
+ |
+namespace base { |
+class Value; |
+} |
+ |
+class ValueSet { |
Matt Perry
2012/06/13 01:24:27
class comment
Matt Perry
2012/06/13 01:24:27
extensions namespace
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
+ public: |
+ ValueSet(); |
+ ~ValueSet(); |
+ |
+ // Adds |value| to the set and returns how many equal values are in the |
+ // set after. |
+ int Add(const base::Value* value); |
battre
2012/06/13 09:21:54
how is the ownership of |value| handled?
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
+ |
+ // Removes |value| from the set and returns how many equal values are in |
+ // the set after. |
+ int Remove(const base::Value* value); |
+ |
+ // Same as Add() but only performs the add if the value isn't present. |
+ int AddIfMissing(const base::Value* value); |
+ |
+ private: |
+ struct Entry { |
+ explicit Entry(const base::Value* value); |
+ ~Entry(); |
+ |
+ int Increment(); |
+ int Decrement(); |
+ |
+ linked_ptr<base::Value> value; |
+ int count; |
+ }; |
+ typedef std::vector<linked_ptr<Entry> > EntryList; |
+ |
+ int AddImpl(const base::Value* value, bool increment); |
+ |
+ EntryList entries_; |
battre
2012/06/13 09:21:54
DISALLOW_COPY_AND_ASSIGN
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
+}; |
+ |
+#endif // CHROME_COMMON_EXTENSIONS_VALUE_SET_H_ |