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

Unified Diff: components/policy/core/common/policy_service_impl.cc

Issue 1940153002: Use std::unique_ptr to express ownership of base::Value in PolicyMap::Entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another-fix Created 4 years, 7 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/policy/core/common/policy_service_impl.cc
diff --git a/components/policy/core/common/policy_service_impl.cc b/components/policy/core/common/policy_service_impl.cc
index c6116c7119edc3b53d89c7f245b06fbef5b87552..10f6f5ede610e62610113cf0696a318869869615 100644
--- a/components/policy/core/common/policy_service_impl.cc
+++ b/components/policy/core/common/policy_service_impl.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <algorithm>
+#include <utility>
#include "base/bind.h"
#include "base/location.h"
@@ -53,13 +54,13 @@ void FixDeprecatedPolicies(PolicyMap* policies) {
if (entry) {
if (entry->has_higher_priority_than(current_priority)) {
proxy_settings->Clear();
- current_priority = *entry;
+ current_priority = entry->DeepCopy();
if (entry->source > inherited_source) // Higher priority?
inherited_source = entry->source;
}
if (!entry->has_higher_priority_than(current_priority) &&
!current_priority.has_higher_priority_than(*entry)) {
- proxy_settings->Set(kProxyPolicies[i], entry->value->DeepCopy());
+ proxy_settings->Set(kProxyPolicies[i], entry->value->CreateDeepCopy());
}
policies->Erase(kProxyPolicies[i]);
}
@@ -69,12 +70,9 @@ void FixDeprecatedPolicies(PolicyMap* policies) {
const PolicyMap::Entry* existing = policies->Get(key::kProxySettings);
if (!proxy_settings->empty() &&
(!existing || current_priority.has_higher_priority_than(*existing))) {
- policies->Set(key::kProxySettings,
- current_priority.level,
- current_priority.scope,
- inherited_source,
- proxy_settings.release(),
- NULL);
+ policies->Set(key::kProxySettings, current_priority.level,
+ current_priority.scope, inherited_source,
+ std::move(proxy_settings), nullptr);
}
}
« no previous file with comments | « components/policy/core/common/policy_map_unittest.cc ('k') | components/policy/core/common/policy_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698