summaryrefslogtreecommitdiffstats
path: root/extensions/common/extension_api.h
diff options
context:
space:
mode:
authorjyasskin@chromium.org <jyasskin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 23:47:26 +0000
committerjyasskin@chromium.org <jyasskin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 23:47:26 +0000
commitadf5f3543feadf581e3ba84d930efd18110ffa31 (patch)
tree0ffe74804f72f0d2c53992a5abfb86a5669cf44a /extensions/common/extension_api.h
parentc75c62e4a3f1223fd252a835d314f5da0a839d42 (diff)
downloadchromium_src-adf5f3543feadf581e3ba84d930efd18110ffa31.zip
chromium_src-adf5f3543feadf581e3ba84d930efd18110ffa31.tar.gz
chromium_src-adf5f3543feadf581e3ba84d930efd18110ffa31.tar.bz2
Optimize ExtensionAPI::IsAnyFeatureAvailableToContext from O(#features) to O(#children + log #features).
This also replaces O(N) string allocations with 1 and moves the top-level feature check to the top of the function to provide a quick exit when the context has full access. And it adds an IsAvailable() overload taking a Feature to avoid the string copies in GetFeatureDependency(). BUG=305000 Review URL: https://codereview.chromium.org/107473004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/extension_api.h')
-rw-r--r--extensions/common/extension_api.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/extensions/common/extension_api.h b/extensions/common/extension_api.h
index a6b0982..024f594 100644
--- a/extensions/common/extension_api.h
+++ b/extensions/common/extension_api.h
@@ -65,10 +65,15 @@ class ExtensionAPI {
void RegisterDependencyProvider(const std::string& name,
FeatureProvider* provider);
- // Returns true if the specified API is available. |api_full_name| can be
- // either a namespace name (like "bookmarks") or a member name (like
- // "bookmarks.create"). Returns true if the feature and all of its
- // dependencies are available to the specified context.
+ // Returns true if the specified API is available. Returns true if the feature
+ // and all of its dependencies are available to the specified context.
+ Feature::Availability IsAvailable(const Feature& api,
+ const Extension* extension,
+ Feature::Context context,
+ const GURL& url);
+ // Same as the previous overload, but takes a feature name instead of an
+ // object. |api_full_name| can be either a namespace name (like "bookmarks")
+ // or a member name (like "bookmarks.create").
Feature::Availability IsAvailable(const std::string& api_full_name,
const Extension* extension,
Feature::Context context,