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

Side by Side Diff: remoting/host/policy_watcher.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 unified diff | Download patch
« no previous file with comments | « components/sync_driver/sync_policy_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Most of this code is copied from: 5 // Most of this code is copied from:
6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc}
7 7
8 #include "remoting/host/policy_watcher.h" 8 #include "remoting/host/policy_watcher.h"
9 9
10 #include <utility> 10 #include <utility>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 new policy::SchemaRegistry()); 83 new policy::SchemaRegistry());
84 schema_registry->RegisterComponent(GetPolicyNamespace(), schema); 84 schema_registry->RegisterComponent(GetPolicyNamespace(), schema);
85 return schema_registry; 85 return schema_registry;
86 } 86 }
87 87
88 std::unique_ptr<base::DictionaryValue> CopyChromotingPoliciesIntoDictionary( 88 std::unique_ptr<base::DictionaryValue> CopyChromotingPoliciesIntoDictionary(
89 const policy::PolicyMap& current) { 89 const policy::PolicyMap& current) {
90 const char kPolicyNameSubstring[] = "RemoteAccessHost"; 90 const char kPolicyNameSubstring[] = "RemoteAccessHost";
91 std::unique_ptr<base::DictionaryValue> policy_dict( 91 std::unique_ptr<base::DictionaryValue> policy_dict(
92 new base::DictionaryValue()); 92 new base::DictionaryValue());
93 for (auto it = current.begin(); it != current.end(); ++it) { 93 for (const auto& entry : current) {
94 const std::string& key = it->first; 94 const std::string& key = entry.first;
95 const base::Value* value = it->second.value; 95 const base::Value* value = entry.second.value.get();
96 96
97 // Copying only Chromoting-specific policies helps avoid false alarms 97 // Copying only Chromoting-specific policies helps avoid false alarms
98 // raised by NormalizePolicies below (such alarms shutdown the host). 98 // raised by NormalizePolicies below (such alarms shutdown the host).
99 // TODO(lukasza): Removing this somewhat brittle filtering will be possible 99 // TODO(lukasza): Removing this somewhat brittle filtering will be possible
100 // after having separate, Chromoting-specific schema. 100 // after having separate, Chromoting-specific schema.
101 if (key.find(kPolicyNameSubstring) != std::string::npos) { 101 if (key.find(kPolicyNameSubstring) != std::string::npos) {
102 policy_dict->Set(key, value->CreateDeepCopy()); 102 policy_dict->Set(key, value->CreateDeepCopy());
103 } 103 }
104 } 104 }
105 105
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 CreateSchemaRegistry())); 382 CreateSchemaRegistry()));
383 #else 383 #else
384 #error OS that is not yet supported by PolicyWatcher code. 384 #error OS that is not yet supported by PolicyWatcher code.
385 #endif 385 #endif
386 386
387 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader)); 387 return PolicyWatcher::CreateFromPolicyLoader(std::move(policy_loader));
388 #endif // !(OS_CHROMEOS) 388 #endif // !(OS_CHROMEOS)
389 } 389 }
390 390
391 } // namespace remoting 391 } // namespace remoting
OLDNEW
« no previous file with comments | « components/sync_driver/sync_policy_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698