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

Unified Diff: chrome/browser/prefs/pref_value_map.h

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, fix up unit tests. Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/pref_value_map.h
diff --git a/chrome/browser/prefs/pref_value_map.h b/chrome/browser/prefs/pref_value_map.h
new file mode 100644
index 0000000000000000000000000000000000000000..013a74af07bb6d66474945e79bbfceca5e272c6a
--- /dev/null
+++ b/chrome/browser/prefs/pref_value_map.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2010 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_BROWSER_PREFS_PREF_VALUE_MAP_H_
+#define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
+#pragma once
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+
+class Value;
+
+// A generic string to value map used by the PrefStore implementations.
+class PrefValueMap {
+ public:
+ PrefValueMap() {}
+ ~PrefValueMap();
danno 2010/12/08 13:08:45 virtual just in case?
Mattias Nissler (ping if slow) 2010/12/09 10:20:20 Adds the vtable pointer when we really don't need
+
+ // Gets the value for |key| and stores it in |value|. Ownership remains with
+ // the map. Returns true if a value is present. If not, |value| is not
+ // touched.
+ bool GetValue(const std::string& key, Value** value) const;
+
+ // Sets a new |value| for |key|. Takes ownership of |value|. Returns true if
+ // the value changed.
battre (please use the other) 2010/12/08 12:24:15 Has value==NULL connotation of RemoveValue?
Mattias Nissler (ping if slow) 2010/12/09 10:20:20 No, it DCHECKs. Added comment to that effect.
+ bool SetValue(const std::string& key, Value* value);
+
+ // Removes the value for |key| from the map. Returns true if a value was
+ // removed.
+ bool RemoveValue(const std::string& key);
+
+ // Clears the map.
+ void Clear();
+
+ private:
+ typedef std::map<std::string, Value*> Map;
+
+ Map prefs_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrefValueMap);
+};
+
+#endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_

Powered by Google App Engine
This is Rietveld 408576698