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 #ifndef EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
6 #define EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 23 matching lines...) Expand all Loading... |
34 Feature* GetParent(Feature* feature) const override; | 34 Feature* GetParent(Feature* feature) const override; |
35 std::vector<Feature*> GetChildren(const Feature& parent) const override; | 35 std::vector<Feature*> GetChildren(const Feature& parent) const override; |
36 | 36 |
37 const FeatureMap& GetAllFeatures() const override; | 37 const FeatureMap& GetAllFeatures() const override; |
38 | 38 |
39 protected: | 39 protected: |
40 BaseFeatureProvider(); | 40 BaseFeatureProvider(); |
41 | 41 |
42 void AddFeature(base::StringPiece name, std::unique_ptr<Feature> feature); | 42 void AddFeature(base::StringPiece name, std::unique_ptr<Feature> feature); |
43 | 43 |
| 44 // Takes ownership. Used in preference to unique_ptr variant to reduce size |
| 45 // of generated code. |
| 46 void AddFeature(base::StringPiece name, Feature* feature); |
| 47 |
44 private: | 48 private: |
45 std::map<std::string, std::unique_ptr<Feature>> features_; | 49 std::map<std::string, std::unique_ptr<Feature>> features_; |
46 | 50 |
47 DISALLOW_COPY_AND_ASSIGN(BaseFeatureProvider); | 51 DISALLOW_COPY_AND_ASSIGN(BaseFeatureProvider); |
48 }; | 52 }; |
49 | 53 |
50 } // namespace extensions | 54 } // namespace extensions |
51 | 55 |
52 #endif // EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 56 #endif // EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
OLD | NEW |