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

Unified Diff: components/prefs/pref_registry_simple.cc

Issue 2784513002: Move PrefRegistrySimple to use unique_ptr<Value> (Closed)
Patch Set: Android Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/prefs/pref_registry_simple.h ('k') | components/prefs/pref_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/pref_registry_simple.cc
diff --git a/components/prefs/pref_registry_simple.cc b/components/prefs/pref_registry_simple.cc
index efd8cf2f9778e2e7e783cd478e4814f397598e24..ee362f14628d601850704ef15f02c798e3dafb13 100644
--- a/components/prefs/pref_registry_simple.cc
+++ b/components/prefs/pref_registry_simple.cc
@@ -4,7 +4,10 @@
#include "components/prefs/pref_registry_simple.h"
+#include <utility>
+
#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
@@ -16,144 +19,157 @@ PrefRegistrySimple::~PrefRegistrySimple() {
void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
bool default_value) {
- RegisterPrefAndNotify(path, new base::Value(default_value),
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
int default_value) {
- RegisterPrefAndNotify(path, new base::Value(default_value),
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
double default_value) {
- RegisterPrefAndNotify(path, new base::Value(default_value),
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterStringPref(const std::string& path,
const std::string& default_value) {
- RegisterPrefAndNotify(path, new base::Value(default_value),
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterFilePathPref(
const std::string& path,
const base::FilePath& default_value) {
- RegisterPrefAndNotify(path, new base::Value(default_value.value()),
+ RegisterPrefAndNotify(path,
+ base::MakeUnique<base::Value>(default_value.value()),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterListPref(const std::string& path) {
- RegisterPrefAndNotify(path, new base::ListValue(), NO_REGISTRATION_FLAGS);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::ListValue>(),
+ NO_REGISTRATION_FLAGS);
}
-void PrefRegistrySimple::RegisterListPref(const std::string& path,
- base::ListValue* default_value) {
- RegisterPrefAndNotify(path, default_value, NO_REGISTRATION_FLAGS);
+void PrefRegistrySimple::RegisterListPref(
+ const std::string& path,
+ std::unique_ptr<base::ListValue> default_value) {
+ RegisterPrefAndNotify(path, std::move(default_value), NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path) {
- RegisterPrefAndNotify(path, new base::DictionaryValue(),
+ RegisterPrefAndNotify(path, base::MakeUnique<base::DictionaryValue>(),
NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterDictionaryPref(
const std::string& path,
- base::DictionaryValue* default_value) {
- RegisterPrefAndNotify(path, default_value, NO_REGISTRATION_FLAGS);
+ std::unique_ptr<base::DictionaryValue> default_value) {
+ RegisterPrefAndNotify(path, std::move(default_value), NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterInt64Pref(const std::string& path,
int64_t default_value) {
- RegisterPrefAndNotify(path,
- new base::Value(base::Int64ToString(default_value)),
- NO_REGISTRATION_FLAGS);
+ RegisterPrefAndNotify(
+ path, base::MakeUnique<base::Value>(base::Int64ToString(default_value)),
+ NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterUint64Pref(const std::string& path,
uint64_t default_value) {
- RegisterPrefAndNotify(path,
- new base::Value(base::Uint64ToString(default_value)),
- NO_REGISTRATION_FLAGS);
+ RegisterPrefAndNotify(
+ path, base::MakeUnique<base::Value>(base::Uint64ToString(default_value)),
+ NO_REGISTRATION_FLAGS);
}
void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
bool default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::Value(default_value), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
+ flags);
}
void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
int default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::Value(default_value), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
+ flags);
}
void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
double default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::Value(default_value), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
+ flags);
}
void PrefRegistrySimple::RegisterStringPref(const std::string& path,
const std::string& default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::Value(default_value), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::Value>(default_value),
+ flags);
}
void PrefRegistrySimple::RegisterFilePathPref(
const std::string& path,
const base::FilePath& default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::Value(default_value.value()), flags);
+ RegisterPrefAndNotify(
+ path, base::MakeUnique<base::Value>(default_value.value()), flags);
}
void PrefRegistrySimple::RegisterListPref(const std::string& path,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::ListValue(), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::ListValue>(), flags);
}
-void PrefRegistrySimple::RegisterListPref(const std::string& path,
- base::ListValue* default_value,
- uint32_t flags) {
- RegisterPrefAndNotify(path, default_value, flags);
+void PrefRegistrySimple::RegisterListPref(
+ const std::string& path,
+ std::unique_ptr<base::ListValue> default_value,
+ uint32_t flags) {
+ RegisterPrefAndNotify(path, std::move(default_value), flags);
}
void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path,
uint32_t flags) {
- RegisterPrefAndNotify(path, new base::DictionaryValue(), flags);
+ RegisterPrefAndNotify(path, base::MakeUnique<base::DictionaryValue>(), flags);
}
void PrefRegistrySimple::RegisterDictionaryPref(
const std::string& path,
- base::DictionaryValue* default_value,
+ std::unique_ptr<base::DictionaryValue> default_value,
uint32_t flags) {
- RegisterPrefAndNotify(path, default_value, flags);
+ RegisterPrefAndNotify(path, std::move(default_value), flags);
}
void PrefRegistrySimple::RegisterInt64Pref(const std::string& path,
int64_t default_value,
uint32_t flags) {
RegisterPrefAndNotify(
- path, new base::Value(base::Int64ToString(default_value)), flags);
+ path, base::MakeUnique<base::Value>(base::Int64ToString(default_value)),
+ flags);
}
void PrefRegistrySimple::RegisterUint64Pref(const std::string& path,
uint64_t default_value,
uint32_t flags) {
RegisterPrefAndNotify(
- path, new base::Value(base::Uint64ToString(default_value)), flags);
+ path, base::MakeUnique<base::Value>(base::Uint64ToString(default_value)),
+ flags);
}
void PrefRegistrySimple::OnPrefRegistered(const std::string& path,
base::Value* default_value,
uint32_t flags) {}
-void PrefRegistrySimple::RegisterPrefAndNotify(const std::string& path,
- base::Value* default_value,
- uint32_t flags) {
- RegisterPreference(path, default_value, flags);
- OnPrefRegistered(path, default_value, flags);
+void PrefRegistrySimple::RegisterPrefAndNotify(
+ const std::string& path,
+ std::unique_ptr<base::Value> default_value,
+ uint32_t flags) {
+ base::Value* default_value_weak = default_value.get();
+ RegisterPreference(path, std::move(default_value), flags);
+ OnPrefRegistered(path, default_value_weak, flags);
}
« no previous file with comments | « components/prefs/pref_registry_simple.h ('k') | components/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698