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

Unified Diff: extensions/browser/extension_prefs.cc

Issue 2843813002: Remove SetWithoutPathExpansion (Closed)
Patch Set: Fix CrOS Error Created 3 years, 8 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 | « extensions/browser/event_router.cc ('k') | ios/chrome/browser/autofill/autofill_agent.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_prefs.cc
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index 83246170e3f07ee226d9db174e559f465d206d69..ee839b0a334e935e51badeed135c6e62ceeee69d 100644
--- a/extensions/browser/extension_prefs.cc
+++ b/extensions/browser/extension_prefs.cc
@@ -199,8 +199,9 @@ class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate {
base::DictionaryValue* extension = NULL;
if (!dict->GetDictionary(extension_id_, &extension)) {
// Extension pref does not exist, create it.
- extension = new base::DictionaryValue();
- dict->SetWithoutPathExpansion(extension_id_, base::WrapUnique(extension));
+ dict->SetWithoutPathExpansion(extension_id_,
+ base::MakeUnique<base::DictionaryValue>());
+ dict->GetDictionaryWithoutPathExpansion(extension_id_, &extension);
}
return extension;
}
@@ -298,14 +299,14 @@ T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() {
base::DictionaryValue* dict = update_.Get();
base::DictionaryValue* extension = nullptr;
base::Value* key_value = nullptr;
- T* value_as_t = nullptr;
if (!dict->GetDictionary(extension_id_, &extension)) {
- extension = new base::DictionaryValue;
- dict->SetWithoutPathExpansion(extension_id_, base::WrapUnique(extension));
+ dict->SetWithoutPathExpansion(extension_id_,
+ base::MakeUnique<base::DictionaryValue>());
+ dict->GetDictionaryWithoutPathExpansion(extension_id_, &extension);
}
if (!extension->Get(key_, &key_value)) {
- value_as_t = new T;
- extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t));
+ extension->SetWithoutPathExpansion(key_, base::MakeUnique<T>());
+ extension->GetWithoutPathExpansion(key_, &key_value);
} else {
// It would be nice to CHECK that this doesn't happen, but since prefs can
// get into a mangled state, we can't really do that. Instead, handle it
@@ -315,13 +316,11 @@ T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() {
// might be useful. Remove the dumps after we analyze them.
if (key_value->GetType() != type_enum_value) {
NOTREACHED();
- value_as_t = new T();
- extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t));
- } else {
- value_as_t = static_cast<T*>(key_value);
+ extension->SetWithoutPathExpansion(key_, base::MakeUnique<T>());
+ extension->GetWithoutPathExpansion(key_, &key_value);
}
}
- return value_as_t;
+ return static_cast<T*>(key_value);
}
// Explicit instantiations for Dictionary and List value types.
« no previous file with comments | « extensions/browser/event_router.cc ('k') | ios/chrome/browser/autofill/autofill_agent.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698