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

Unified Diff: chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.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
Index: chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
diff --git a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
index 23df62a3ac1f9b82ec8210d6e2e9fa65c75dddfc..86c0a9eba17302ee90933a6862b178dac6b9706d 100644
--- a/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
+++ b/chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.cc
@@ -10,6 +10,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -44,8 +45,9 @@ DictionaryValue* FindOrCreateDictionary(DictionaryValue* parent,
const std::string& key) {
DictionaryValue* dict = nullptr;
if (!parent->GetDictionaryWithoutPathExpansion(key, &dict)) {
- dict = new DictionaryValue;
- parent->SetWithoutPathExpansion(key, dict);
+ parent->SetWithoutPathExpansion(key,
+ base::MakeUnique<base::DictionaryValue>());
+ parent->GetDictionaryWithoutPathExpansion(key, &dict);
}
return dict;
}
@@ -110,10 +112,11 @@ void SupervisedUserSharedSettingsService::SetValueInternal(
DictionaryValue* dict = nullptr;
bool has_key = update_dict->GetDictionaryWithoutPathExpansion(key, &dict);
if (!has_key) {
- dict = new DictionaryValue;
- update_dict->SetWithoutPathExpansion(key, dict);
+ update_dict->SetWithoutPathExpansion(
+ key, base::MakeUnique<base::DictionaryValue>());
+ update_dict->GetDictionaryWithoutPathExpansion(key, &dict);
}
- dict->SetWithoutPathExpansion(kValue, value.DeepCopy());
+ dict->SetWithoutPathExpansion(kValue, value.CreateDeepCopy());
dict->SetBooleanWithoutPathExpansion(kAcknowledged, acknowledged);
if (!sync_processor_)
@@ -230,7 +233,7 @@ SupervisedUserSharedSettingsService::MergeDataAndStartSyncing(
ScopedSupervisedUserSharedSettingsUpdate update(prefs_, su_id);
const std::string& key = supervised_user_shared_setting.key();
DictionaryValue* dict = FindOrCreateDictionary(update.Get(), key);
- dict->SetWithoutPathExpansion(kValue, value.release());
+ dict->SetWithoutPathExpansion(kValue, std::move(value));
// Every setting we get from the server should have the acknowledged flag
// set.
@@ -341,12 +344,13 @@ syncer::SyncError SupervisedUserSharedSettingsService::ProcessSyncChanges(
} else {
// Otherwise, it should be an add action.
DCHECK_EQ(SyncChange::ACTION_ADD, sync_change.change_type());
- dict = new DictionaryValue;
- update_dict->SetWithoutPathExpansion(key, dict);
+ update_dict->SetWithoutPathExpansion(
+ key, base::MakeUnique<base::DictionaryValue>());
+ update_dict->GetDictionaryWithoutPathExpansion(key, &dict);
}
std::unique_ptr<Value> value =
base::JSONReader::Read(supervised_user_shared_setting.value());
- dict->SetWithoutPathExpansion(kValue, value.release());
+ dict->SetWithoutPathExpansion(kValue, std::move(value));
dict->SetBooleanWithoutPathExpansion(
kAcknowledged, supervised_user_shared_setting.acknowledged());
break;

Powered by Google App Engine
This is Rietveld 408576698