Skip to content

Commit

Permalink
[Code Health] Remove uses of Value::CreateDeepCopy()
Browse files Browse the repository at this point in the history
This CL was uploaded by git cl split.

[email protected]

Bug: 1187013
Change-Id: Id2cbefc10635326c91cc545508ec8a360c74bafe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2873362
Auto-Submit: Austin Sullivan <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#881744}
  • Loading branch information
a-sully authored and Chromium LUCI CQ committed May 11, 2021
1 parent 7a6b4a0 commit 523eec1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/prefs/overlay_user_pref_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool OverlayUserPrefStore::GetMutableValue(const std::string& key,
return false;

ephemeral_user_pref_store_->SetValue(
key, persistent_value->CreateDeepCopy(),
key, base::Value::ToUniquePtrValue(persistent_value->Clone()),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
ephemeral_user_pref_store_->GetMutableValue(key, result);
return true;
Expand Down
6 changes: 4 additions & 2 deletions components/prefs/pref_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/util/values/values_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/prefs/default_pref_store.h"
#include "components/prefs/pref_notifier_impl.h"
Expand Down Expand Up @@ -563,8 +564,9 @@ base::Value* PrefService::GetMutableUserPref(const std::string& path,
const base::Value* default_value = nullptr;
pref_registry_->defaults()->GetValue(path, &default_value);
DCHECK_EQ(default_value->type(), type);
user_pref_store_->SetValueSilently(path, default_value->CreateDeepCopy(),
GetWriteFlags(pref));
user_pref_store_->SetValueSilently(
path, base::Value::ToUniquePtrValue(default_value->Clone()),
GetWriteFlags(pref));
user_pref_store_->GetMutableValue(path, &value);
return value;
}
Expand Down
3 changes: 2 additions & 1 deletion components/prefs/pref_value_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ void PrefValueMap::GetDifferingKeys(
std::unique_ptr<base::DictionaryValue> PrefValueMap::AsDictionaryValue() const {
auto dictionary = std::make_unique<base::DictionaryValue>();
for (const auto& value : prefs_)
dictionary->Set(value.first, value.second.CreateDeepCopy());
dictionary->Set(value.first,
base::Value::ToUniquePtrValue(value.second.Clone()));

return dictionary;
}
2 changes: 1 addition & 1 deletion components/prefs/segregated_pref_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::unique_ptr<base::DictionaryValue> SegregatedPrefStore::GetValues() const {
for (const auto& key : selected_preference_names_) {
const base::Value* value = nullptr;
if (selected_pref_store_values->Get(key, &value)) {
values->Set(key, value->CreateDeepCopy());
values->Set(key, base::Value::ToUniquePtrValue(value->Clone()));
} else {
values->Remove(key, nullptr);
}
Expand Down

0 comments on commit 523eec1

Please sign in to comment.