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

Unified Diff: components/prefs/testing_pref_service.h

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments 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
Index: components/prefs/testing_pref_service.h
diff --git a/components/prefs/testing_pref_service.h b/components/prefs/testing_pref_service.h
index 6f9171740bfc67eb41fc226ae636cff1dc0ebb0d..5378968d7d55d17bf5ea9afed6d3cb3f2345fcb3 100644
--- a/components/prefs/testing_pref_service.h
+++ b/components/prefs/testing_pref_service.h
@@ -6,6 +6,7 @@
#define COMPONENTS_PREFS_TESTING_PREF_SERVICE_H_
#include <memory>
+#include <utility>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
@@ -33,8 +34,9 @@ class TestingPrefServiceBase : public SuperPrefService {
const base::Value* GetManagedPref(const std::string& path) const;
// Set a preference on the managed layer and fire observers if the preference
- // changed. Assumes ownership of |value|.
- void SetManagedPref(const std::string& path, base::Value* value);
+ // changed.
+ void SetManagedPref(const std::string& path,
+ std::unique_ptr<base::Value> value);
// Clear the preference on the managed layer and fire observers if the
// preference has been defined previously.
@@ -45,17 +47,19 @@ class TestingPrefServiceBase : public SuperPrefService {
// Useful in tests that only check that a preference is overridden by an
// extension.
const base::Value* GetExtensionPref(const std::string& path) const;
- void SetExtensionPref(const std::string& path, base::Value* value);
+ void SetExtensionPref(const std::string& path,
+ std::unique_ptr<base::Value> value);
void RemoveExtensionPref(const std::string& path);
// Similar to the above, but for user preferences.
const base::Value* GetUserPref(const std::string& path) const;
- void SetUserPref(const std::string& path, base::Value* value);
+ void SetUserPref(const std::string& path, std::unique_ptr<base::Value> value);
void RemoveUserPref(const std::string& path);
// Similar to the above, but for recommended policy preferences.
const base::Value* GetRecommendedPref(const std::string& path) const;
- void SetRecommendedPref(const std::string& path, base::Value* value);
+ void SetRecommendedPref(const std::string& path,
+ std::unique_ptr<base::Value> value);
void RemoveRecommendedPref(const std::string& path);
// Do-nothing implementation for TestingPrefService.
@@ -78,7 +82,7 @@ class TestingPrefServiceBase : public SuperPrefService {
// Sets the value for |path| in |pref_store|.
void SetPref(TestingPrefStore* pref_store,
const std::string& path,
- base::Value* value);
+ std::unique_ptr<base::Value> value);
// Removes the preference identified by |path| from |pref_store|.
void RemovePref(TestingPrefStore* pref_store, const std::string& path);
@@ -133,8 +137,9 @@ const base::Value* TestingPrefServiceBase<
template <class SuperPrefService, class ConstructionPrefRegistry>
void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
- SetManagedPref(const std::string& path, base::Value* value) {
- SetPref(managed_prefs_.get(), path, value);
+ SetManagedPref(const std::string& path,
+ std::unique_ptr<base::Value> value) {
+ SetPref(managed_prefs_.get(), path, std::move(value));
}
template <class SuperPrefService, class ConstructionPrefRegistry>
@@ -152,8 +157,9 @@ const base::Value* TestingPrefServiceBase<
template <class SuperPrefService, class ConstructionPrefRegistry>
void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
- SetExtensionPref(const std::string& path, base::Value* value) {
- SetPref(extension_prefs_.get(), path, value);
+ SetExtensionPref(const std::string& path,
+ std::unique_ptr<base::Value> value) {
+ SetPref(extension_prefs_.get(), path, std::move(value));
}
template <class SuperPrefService, class ConstructionPrefRegistry>
@@ -171,8 +177,8 @@ TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::GetUserPref(
template <class SuperPrefService, class ConstructionPrefRegistry>
void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
- SetUserPref(const std::string& path, base::Value* value) {
- SetPref(user_prefs_.get(), path, value);
+ SetUserPref(const std::string& path, std::unique_ptr<base::Value> value) {
+ SetPref(user_prefs_.get(), path, std::move(value));
}
template <class SuperPrefService, class ConstructionPrefRegistry>
@@ -190,8 +196,9 @@ TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
template <class SuperPrefService, class ConstructionPrefRegistry>
void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
- SetRecommendedPref(const std::string& path, base::Value* value) {
- SetPref(recommended_prefs_.get(), path, value);
+ SetRecommendedPref(const std::string& path,
+ std::unique_ptr<base::Value> value) {
+ SetPref(recommended_prefs_.get(), path, std::move(value));
}
template <class SuperPrefService, class ConstructionPrefRegistry>
@@ -213,8 +220,8 @@ template <class SuperPrefService, class ConstructionPrefRegistry>
void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
SetPref(TestingPrefStore* pref_store,
const std::string& path,
- base::Value* value) {
- pref_store->SetValue(path, base::WrapUnique(value),
+ std::unique_ptr<base::Value> value) {
+ pref_store->SetValue(path, std::move(value),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
}
« no previous file with comments | « components/prefs/pref_service_unittest.cc ('k') | components/proxy_config/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698