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

Unified Diff: extensions/common/feature_switch.cc

Issue 2633253002: Split content script injections into multiple tasks (Closed)
Patch Set: comments addressed Created 3 years, 9 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
« no previous file with comments | « extensions/common/feature_switch.h ('k') | extensions/common/switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/feature_switch.cc
diff --git a/extensions/common/feature_switch.cc b/extensions/common/feature_switch.cc
index 10863b271a059eeb4c7a05c347de8b76710e1dfb..5868f02869bfc064bd3bc90e09f2773ee258d350 100644
--- a/extensions/common/feature_switch.cc
+++ b/extensions/common/feature_switch.cc
@@ -20,6 +20,9 @@ namespace {
const char kLoadMediaRouterComponentExtensionFlag[] =
"load-media-router-component-extension";
+const char kYieldBetweenContentScriptRunsFieldTrial[] =
+ "YieldBetweenContentScriptRuns";
+
class CommonSwitches {
public:
CommonSwitches()
@@ -54,7 +57,11 @@ class CommonSwitches {
FeatureSwitch::DEFAULT_DISABLED),
#endif // defined(GOOGLE_CHROME_BUILD)
native_crx_bindings(switches::kNativeCrxBindings,
- FeatureSwitch::DEFAULT_DISABLED) {
+ FeatureSwitch::DEFAULT_DISABLED),
+ yield_between_content_script_runs(
+ switches::kYieldBetweenContentScriptRuns,
+ kYieldBetweenContentScriptRunsFieldTrial,
+ FeatureSwitch::DEFAULT_DISABLED) {
}
FeatureSwitch force_dev_mode_highlighting;
@@ -71,6 +78,7 @@ class CommonSwitches {
FeatureSwitch trace_app_source;
FeatureSwitch load_media_router_component_extension;
FeatureSwitch native_crx_bindings;
+ FeatureSwitch yield_between_content_script_runs;
};
base::LazyInstance<CommonSwitches>::DestructorAtExit g_common_switches =
@@ -108,6 +116,9 @@ FeatureSwitch* FeatureSwitch::load_media_router_component_extension() {
FeatureSwitch* FeatureSwitch::native_crx_bindings() {
return &g_common_switches.Get().native_crx_bindings;
}
+FeatureSwitch* FeatureSwitch::yield_between_content_script_runs() {
+ return &g_common_switches.Get().yield_between_content_script_runs;
+}
FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature,
bool override_value)
@@ -153,7 +164,12 @@ FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line,
bool FeatureSwitch::IsEnabled() const {
if (override_value_ != OVERRIDE_NONE)
return override_value_ == OVERRIDE_ENABLED;
+ if (!cached_value_.has_value())
+ cached_value_ = ComputeValue();
+ return cached_value_.value();
+}
+bool FeatureSwitch::ComputeValue() const {
if (!switch_name_)
return default_value_;
« no previous file with comments | « extensions/common/feature_switch.h ('k') | extensions/common/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698