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

Unified Diff: extensions/common/features/feature_provider.h

Issue 2669463002: [Extensions] Remove BaseFeatureProvider (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: extensions/common/features/feature_provider.h
diff --git a/extensions/common/features/feature_provider.h b/extensions/common/features/feature_provider.h
index 2159bf13f36518cf761d6a5585252bb871fccd06..0e629c554da27bc34a46733f8fd452a4e634a2d2 100644
--- a/extensions/common/features/feature_provider.h
+++ b/extensions/common/features/feature_provider.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/strings/string_piece.h"
namespace extensions {
@@ -20,12 +21,8 @@ using FeatureMap = std::map<std::string, std::unique_ptr<Feature>>;
// Implemented by classes that can vend features.
class FeatureProvider {
public:
- FeatureProvider() {}
- virtual ~FeatureProvider() {}
-
- //
- // Static helpers.
- //
+ FeatureProvider();
+ virtual ~FeatureProvider();
// Gets a FeatureProvider for a specific type, like "permission".
static const FeatureProvider* GetByName(const std::string& name);
@@ -46,21 +43,29 @@ class FeatureProvider {
static const Feature* GetPermissionFeature(const std::string& name);
static const Feature* GetBehaviorFeature(const std::string& name);
- //
- // Instance methods.
- //
-
// Returns the feature with the specified name.
- virtual Feature* GetFeature(const std::string& name) const = 0;
+ Feature* GetFeature(const std::string& name) const;
// Returns the parent feature of |feature|, or NULL if there isn't one.
- virtual Feature* GetParent(Feature* feature) const = 0;
+ Feature* GetParent(Feature* feature) const;
// Returns the features inside the |parent| namespace, recursively.
- virtual std::vector<Feature*> GetChildren(const Feature& parent) const = 0;
+ std::vector<Feature*> GetChildren(const Feature& parent) const;
// Returns a map containing all features described by this instance.
- virtual const FeatureMap& GetAllFeatures() const = 0;
+ // TODO(devlin): Rename this to be features().
+ const FeatureMap& GetAllFeatures() const;
+
+ void AddFeature(base::StringPiece name, std::unique_ptr<Feature> feature);
+
+ // Takes ownership. Used in preference to unique_ptr variant to reduce size
+ // of generated code.
+ void AddFeature(base::StringPiece name, Feature* feature);
+
+ private:
+ FeatureMap features_;
+
+ DISALLOW_COPY_AND_ASSIGN(FeatureProvider);
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698