Add hint_preload_subresources as a way of enabling preload hinting.
This commit is contained in:
@@ -147,6 +147,7 @@ class RewriteOptions {
|
||||
kFlattenCssImports,
|
||||
kFlushSubresources,
|
||||
kHandleNoscriptRedirect,
|
||||
kHintPreloadSubresources,
|
||||
kHtmlWriterFilter,
|
||||
kIncludeJsSourceMaps,
|
||||
kInlineCss,
|
||||
@@ -2989,9 +2990,7 @@ class RewriteOptions {
|
||||
|
||||
// Returns true if this configuration turns on options that may need
|
||||
// the dependencies cohort to operate.
|
||||
bool NeedsDependenciesCohort() const {
|
||||
return Enabled(kExperimentHttp2);
|
||||
}
|
||||
bool NeedsDependenciesCohort() const;
|
||||
|
||||
protected:
|
||||
// Helper class to represent an Option, whose value is held in some class T.
|
||||
|
||||
@@ -42,7 +42,7 @@ class PushPreloadFilterTest : public RewriteTestBase {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
RewriteTestBase::SetUp();
|
||||
options()->EnableFilter(RewriteOptions::kExperimentHttp2);
|
||||
options()->EnableFilter(RewriteOptions::kHintPreloadSubresources);
|
||||
|
||||
// Setup pcache.
|
||||
pcache_ = rewrite_driver()->server_context()->page_property_cache();
|
||||
|
||||
@@ -1329,7 +1329,7 @@ void RewriteDriver::AddPostRenderFilters() {
|
||||
// Remove excess whitespace in HTML.
|
||||
AddOwnedPostRenderFilter(new CollapseWhitespaceFilter(this));
|
||||
}
|
||||
if (options()->NeedsDependenciesCohort()) {
|
||||
if (options()->Enabled(RewriteOptions::kHintPreloadSubresources)) {
|
||||
AppendOwnedPreRenderFilter(new PushPreloadFilter(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ struct FilterMap {
|
||||
"fix_reflows", RewriteOptions::kFixReflows
|
||||
"flatten_css_imports", RewriteOptions::kFlattenCssImports
|
||||
"flush_subresources", RewriteOptions::kFlushSubresources
|
||||
"hint_preload_subresources", RewriteOptions::kHintPreloadSubresources
|
||||
"in_place_optimize_for_browser", RewriteOptions::kInPlaceOptimizeForBrowser
|
||||
"include_js_source_maps", RewriteOptions::kIncludeJsSourceMaps
|
||||
"inline_css", RewriteOptions::kInlineCss
|
||||
|
||||
@@ -779,6 +779,8 @@ const RewriteOptions::FilterEnumToIdAndNameEntry
|
||||
{RewriteOptions::kFlushSubresources, "fs", "Flush Subresources"},
|
||||
{RewriteOptions::kHandleNoscriptRedirect, "hn",
|
||||
"Handles Noscript Redirects"},
|
||||
{RewriteOptions::kHintPreloadSubresources, "hpsr",
|
||||
"Hint Preload of Subresources"},
|
||||
{RewriteOptions::kHtmlWriterFilter, "hw", "Flushes html"},
|
||||
{RewriteOptions::kIncludeJsSourceMaps,
|
||||
RewriteOptions::kJavascriptMinSourceMapId, "Include JS Source Maps"},
|
||||
@@ -5125,6 +5127,11 @@ HttpOptions RewriteOptions::ComputeHttpOptions() const {
|
||||
return options;
|
||||
}
|
||||
|
||||
bool RewriteOptions::NeedsDependenciesCohort() const {
|
||||
return Enabled(kExperimentHttp2) ||
|
||||
Enabled(kHintPreloadSubresources);
|
||||
}
|
||||
|
||||
bool RewriteOptions::CacheFragmentOption::SetFromString(
|
||||
StringPiece value, GoogleString* error_detail) {
|
||||
// The main thing here is that the fragment not contain '/' (the separator
|
||||
|
||||
Reference in New Issue
Block a user