Commit ad545a86 authored by avi's avatar avi Committed by Commit bot

Remove base::ScopedPtrHashMap from components/prefs/.

BUG=579229

Review-Url: https://codereview.chromium.org/2602553003
Cr-Commit-Position: refs/heads/master@{#441444}
parent 8e41e5ab
...@@ -735,11 +735,11 @@ void DeviceSettingsProvider::UpdateValuesCache( ...@@ -735,11 +735,11 @@ void DeviceSettingsProvider::UpdateValuesCache(
// cache so that if somebody actually reads the cache will be already valid. // cache so that if somebody actually reads the cache will be already valid.
std::vector<std::string> notifications; std::vector<std::string> notifications;
// Go through the new values and verify in the old ones. // Go through the new values and verify in the old ones.
PrefValueMap::iterator iter = new_values_cache.begin(); auto iter = new_values_cache.begin();
for (; iter != new_values_cache.end(); ++iter) { for (; iter != new_values_cache.end(); ++iter) {
const base::Value* old_value; const base::Value* old_value;
if (!values_cache_.GetValue(iter->first, &old_value) || if (!values_cache_.GetValue(iter->first, &old_value) ||
!old_value->Equals(iter->second)) { !old_value->Equals(iter->second.get())) {
notifications.push_back(iter->first); notifications.push_back(iter->first);
} }
} }
......
...@@ -37,7 +37,7 @@ class FirstEqualsPredicate { ...@@ -37,7 +37,7 @@ class FirstEqualsPredicate {
public: public:
explicit FirstEqualsPredicate(const std::string& expected) explicit FirstEqualsPredicate(const std::string& expected)
: expected_(expected) {} : expected_(expected) {}
bool operator()(const std::pair<std::string, base::Value*>& pair) { bool operator()(const PrefValueMap::Map::value_type& pair) {
return pair.first == expected_; return pair.first == expected_;
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/values.h" #include "base/values.h"
PrefValueMap::PrefValueMap() {} PrefValueMap::PrefValueMap() {}
...@@ -19,7 +18,11 @@ PrefValueMap::~PrefValueMap() {} ...@@ -19,7 +18,11 @@ PrefValueMap::~PrefValueMap() {}
bool PrefValueMap::GetValue(const std::string& key, bool PrefValueMap::GetValue(const std::string& key,
const base::Value** value) const { const base::Value** value) const {
const base::Value* got_value = prefs_.get(key); auto it = prefs_.find(key);
if (it == prefs_.end())
return false;
const base::Value* got_value = it->second.get();
if (value && got_value) if (value && got_value)
*value = got_value; *value = got_value;
...@@ -27,7 +30,11 @@ bool PrefValueMap::GetValue(const std::string& key, ...@@ -27,7 +30,11 @@ bool PrefValueMap::GetValue(const std::string& key,
} }
bool PrefValueMap::GetValue(const std::string& key, base::Value** value) { bool PrefValueMap::GetValue(const std::string& key, base::Value** value) {
base::Value* got_value = prefs_.get(key); auto it = prefs_.find(key);
if (it == prefs_.end())
return false;
base::Value* got_value = it->second.get();
if (value && got_value) if (value && got_value)
*value = got_value; *value = got_value;
...@@ -38,11 +45,11 @@ bool PrefValueMap::SetValue(const std::string& key, ...@@ -38,11 +45,11 @@ bool PrefValueMap::SetValue(const std::string& key,
std::unique_ptr<base::Value> value) { std::unique_ptr<base::Value> value) {
DCHECK(value); DCHECK(value);
base::Value* old_value = prefs_.get(key); std::unique_ptr<base::Value>& existing_value = prefs_[key];
if (old_value && value->Equals(old_value)) if (existing_value && value->Equals(existing_value.get()))
return false; return false;
prefs_.set(key, std::move(value)); existing_value = std::move(value);
return true; return true;
} }
...@@ -118,13 +125,16 @@ void PrefValueMap::GetDifferingKeys( ...@@ -118,13 +125,16 @@ void PrefValueMap::GetDifferingKeys(
differing_keys->clear(); differing_keys->clear();
// Put everything into ordered maps. // Put everything into ordered maps.
std::map<std::string, base::Value*> this_prefs(prefs_.begin(), prefs_.end()); std::map<std::string, base::Value*> this_prefs;
std::map<std::string, base::Value*> other_prefs(other->prefs_.begin(), std::map<std::string, base::Value*> other_prefs;
other->prefs_.end()); for (const auto& pair : prefs_)
this_prefs[pair.first] = pair.second.get();
for (const auto& pair : other->prefs_)
other_prefs[pair.first] = pair.second.get();
// Walk over the maps in lockstep, adding everything that is different. // Walk over the maps in lockstep, adding everything that is different.
auto this_pref(this_prefs.begin()); auto this_pref = this_prefs.begin();
auto other_pref(other_prefs.begin()); auto other_pref = other_prefs.begin();
while (this_pref != this_prefs.end() && other_pref != other_prefs.end()) { while (this_pref != this_prefs.end() && other_pref != other_prefs.end()) {
const int diff = this_pref->first.compare(other_pref->first); const int diff = this_pref->first.compare(other_pref->first);
if (diff == 0) { if (diff == 0) {
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/prefs/base_prefs_export.h" #include "components/prefs/base_prefs_export.h"
...@@ -20,7 +20,7 @@ class Value; ...@@ -20,7 +20,7 @@ class Value;
// A generic string to value map used by the PrefStore implementations. // A generic string to value map used by the PrefStore implementations.
class COMPONENTS_PREFS_EXPORT PrefValueMap { class COMPONENTS_PREFS_EXPORT PrefValueMap {
public: public:
using Map = base::ScopedPtrHashMap<std::string, std::unique_ptr<base::Value>>; using Map = std::unordered_map<std::string, std::unique_ptr<base::Value>>;
using iterator = Map::iterator; using iterator = Map::iterator;
using const_iterator = Map::const_iterator; using const_iterator = Map::const_iterator;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment