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

Side by Side Diff: components/policy/core/common/schema.cc

Issue 24367003: Refactored users of PolicySchema to use the new policy::Schema class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « components/policy/core/common/schema.h ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/policy/core/common/schema.h" 5 #include "components/policy/core/common/schema.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 const char* Schema::Iterator::key() const { 69 const char* Schema::Iterator::key() const {
70 return it_->key; 70 return it_->key;
71 } 71 }
72 72
73 Schema Schema::Iterator::schema() const { 73 Schema Schema::Iterator::schema() const {
74 return Schema(it_->schema); 74 return Schema(it_->schema);
75 } 75 }
76 76
77 Schema::Schema() : schema_(NULL) {}
78
77 Schema::Schema(const internal::SchemaNode* schema) : schema_(schema) {} 79 Schema::Schema(const internal::SchemaNode* schema) : schema_(schema) {}
78 80
79 Schema::Schema(const Schema& schema) : schema_(schema.schema_) {} 81 Schema::Schema(const Schema& schema) : schema_(schema.schema_) {}
80 82
81 Schema& Schema::operator=(const Schema& schema) { 83 Schema& Schema::operator=(const Schema& schema) {
82 schema_ = schema.schema_; 84 schema_ = schema.schema_;
83 return *this; 85 return *this;
84 } 86 }
85 87
86 base::Value::Type Schema::type() const { 88 base::Value::Type Schema::type() const {
(...skipping 18 matching lines...) Expand all
105 107
106 Schema Schema::GetKnownProperty(const std::string& key) const { 108 Schema Schema::GetKnownProperty(const std::string& key) const {
107 CHECK(valid()); 109 CHECK(valid());
108 CHECK_EQ(base::Value::TYPE_DICTIONARY, type()); 110 CHECK_EQ(base::Value::TYPE_DICTIONARY, type());
109 const internal::PropertiesNode* properties_node = 111 const internal::PropertiesNode* properties_node =
110 static_cast<const internal::PropertiesNode*>(schema_->extra); 112 static_cast<const internal::PropertiesNode*>(schema_->extra);
111 const internal::PropertyNode* it = std::lower_bound( 113 const internal::PropertyNode* it = std::lower_bound(
112 properties_node->begin, properties_node->end, key, CompareKeys); 114 properties_node->begin, properties_node->end, key, CompareKeys);
113 if (it != properties_node->end && it->key == key) 115 if (it != properties_node->end && it->key == key)
114 return Schema(it->schema); 116 return Schema(it->schema);
115 return Schema(NULL); 117 return Schema();
116 } 118 }
117 119
118 Schema Schema::GetAdditionalProperties() const { 120 Schema Schema::GetAdditionalProperties() const {
119 CHECK(valid()); 121 CHECK(valid());
120 CHECK_EQ(base::Value::TYPE_DICTIONARY, type()); 122 CHECK_EQ(base::Value::TYPE_DICTIONARY, type());
121 return Schema( 123 return Schema(
122 static_cast<const internal::PropertiesNode*>(schema_->extra)->additional); 124 static_cast<const internal::PropertiesNode*>(schema_->extra)->additional);
123 } 125 }
124 126
125 Schema Schema::GetProperty(const std::string& key) const { 127 Schema Schema::GetProperty(const std::string& key) const {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return NULL; 269 return NULL;
268 270
269 internal::SchemaNode* schema_node = new internal::SchemaNode; 271 internal::SchemaNode* schema_node = new internal::SchemaNode;
270 schema_node->type = base::Value::TYPE_LIST; 272 schema_node->type = base::Value::TYPE_LIST;
271 schema_node->extra = items_schema_node; 273 schema_node->extra = items_schema_node;
272 schema_nodes_.push_back(schema_node); 274 schema_nodes_.push_back(schema_node);
273 return schema_node; 275 return schema_node;
274 } 276 }
275 277
276 } // namespace policy 278 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/schema.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698