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

Side by Side Diff: chrome/browser/policy/policy_domain_descriptor.cc

Issue 47513018: Make the internal storage of policy::Schemas ref counted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-4-new-generate
Patch Set: rebase Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/policy/policy_domain_descriptor.h" 5 #include "chrome/browser/policy/policy_domain_descriptor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/policy/policy_bundle.h" 10 #include "chrome/browser/policy/policy_bundle.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 return true; 42 return true;
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 PolicyDomainDescriptor::PolicyDomainDescriptor(PolicyDomain domain) 47 PolicyDomainDescriptor::PolicyDomainDescriptor(PolicyDomain domain)
48 : domain_(domain) {} 48 : domain_(domain) {}
49 49
50 void PolicyDomainDescriptor::RegisterComponent( 50 void PolicyDomainDescriptor::RegisterComponent(const std::string& component_id,
51 const std::string& component_id, 51 Schema schema) {
52 scoped_ptr<SchemaOwner> schema) { 52 schema_map_[component_id] = schema;
53 SchemaOwner*& entry = schema_owner_map_[component_id];
54 delete entry;
55 entry = schema.release();
56 schema_map_[component_id] = entry ? entry->schema() : Schema();
57 } 53 }
58 54
59 void PolicyDomainDescriptor::FilterBundle(PolicyBundle* bundle) const { 55 void PolicyDomainDescriptor::FilterBundle(PolicyBundle* bundle) const {
60 // Chrome policies are not filtered, so that typos appear in about:policy. 56 // Chrome policies are not filtered, so that typos appear in about:policy.
61 DCHECK_NE(POLICY_DOMAIN_CHROME, domain_); 57 DCHECK_NE(POLICY_DOMAIN_CHROME, domain_);
62 58
63 for (PolicyBundle::iterator it_bundle = bundle->begin(); 59 for (PolicyBundle::iterator it_bundle = bundle->begin();
64 it_bundle != bundle->end(); ++it_bundle) { 60 it_bundle != bundle->end(); ++it_bundle) {
65 const PolicyNamespace& ns = it_bundle->first; 61 const PolicyNamespace& ns = it_bundle->first;
66 if (ns.domain != domain_) 62 if (ns.domain != domain_)
(...skipping 20 matching lines...) Expand all
87 const std::string& policy_name = it_map->first; 83 const std::string& policy_name = it_map->first;
88 const base::Value* policy_value = it_map->second.value; 84 const base::Value* policy_value = it_map->second.value;
89 Schema policy_schema = schema.GetProperty(policy_name); 85 Schema policy_schema = schema.GetProperty(policy_name);
90 ++it_map; 86 ++it_map;
91 if (!policy_value || !Matches(policy_schema, *policy_value)) 87 if (!policy_value || !Matches(policy_schema, *policy_value))
92 map->Erase(policy_name); 88 map->Erase(policy_name);
93 } 89 }
94 } 90 }
95 } 91 }
96 92
97 PolicyDomainDescriptor::~PolicyDomainDescriptor() { 93 PolicyDomainDescriptor::~PolicyDomainDescriptor() {}
98 STLDeleteValues(&schema_owner_map_);
99 }
100 94
101 } // namespace policy 95 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_domain_descriptor.h ('k') | chrome/browser/policy/policy_domain_descriptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698