| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/features/base_feature_provider.h" | 5 #include "extensions/common/features/base_feature_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <stack> | 9 #include <stack> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Children of a given API are named starting with parent.name()+".", which | 175 // Children of a given API are named starting with parent.name()+".", which |
| 176 // means they'll be contiguous in the features_ std::map. | 176 // means they'll be contiguous in the features_ std::map. |
| 177 std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent) | 177 std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent) |
| 178 const { | 178 const { |
| 179 std::string prefix = parent.name() + "."; | 179 std::string prefix = parent.name() + "."; |
| 180 const FeatureMap::const_iterator first_child = features_.lower_bound(prefix); | 180 const FeatureMap::const_iterator first_child = features_.lower_bound(prefix); |
| 181 | 181 |
| 182 // All children have names before (parent.name() + ('.'+1)). | 182 // All children have names before (parent.name() + ('.'+1)). |
| 183 ++prefix[prefix.size() - 1]; | 183 ++prefix.back(); |
| 184 const FeatureMap::const_iterator after_children = | 184 const FeatureMap::const_iterator after_children = |
| 185 features_.lower_bound(prefix); | 185 features_.lower_bound(prefix); |
| 186 | 186 |
| 187 std::vector<Feature*> result; | 187 std::vector<Feature*> result; |
| 188 result.reserve(std::distance(first_child, after_children)); | 188 result.reserve(std::distance(first_child, after_children)); |
| 189 for (FeatureMap::const_iterator it = first_child; it != after_children; | 189 for (FeatureMap::const_iterator it = first_child; it != after_children; |
| 190 ++it) { | 190 ++it) { |
| 191 result.push_back(it->second.get()); | 191 result.push_back(it->second.get()); |
| 192 } | 192 } |
| 193 return result; | 193 return result; |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace extensions | 196 } // namespace extensions |
| OLD | NEW |