Page Speed Optimization Libraries  1.12.34.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
net_instaweb::RewriteOptions Class Reference

#include "rewrite_options.h"

Inheritance diagram for net_instaweb::RewriteOptions:
net_instaweb::SystemRewriteOptions net_instaweb::ApacheConfig

Classes

class  AllowVaryOn
 
struct  BeaconUrl
 
struct  Color
 
class  DeprecatedProperty
 
struct  ElementAttributeCategory
 Represents the content type of user-defined url-valued attributes. More...
 
class  ExperimentSpec
 
struct  FilterEnumToIdAndNameEntry
 Maps a filter's enum (kAddHead) to its id ("ah") and name ("Add Head"). More...
 
struct  MobTheme
 
struct  NameValue
 
class  Option
 
class  OptionBase
 
class  OptionTemplateBase
 
class  Properties
 
class  Property
 
class  PropertyBase
 
class  PropertyLeaf
 
class  ResponsiveDensities
 

Public Types

enum  Filter {
  kAddBaseTag, kAddHead, kAddIds, kAddInstrumentation,
  kComputeStatistics, kCachePartialHtmlDeprecated, kCanonicalizeJavascriptLibraries, kCollapseWhitespace,
  kCombineCss, kCombineHeads, kCombineJavascript, kComputeCriticalCss,
  kComputeVisibleTextDeprecated, kConvertGifToPng, kConvertJpegToProgressive, kConvertJpegToWebp,
  kConvertMetaTags, kConvertPngToJpeg, kConvertToWebpAnimated, kConvertToWebpLossless,
  kDebug, kDecodeRewrittenUrls, kDedupInlinedImages, kDeferIframe,
  kDeferJavascript, kDelayImages, kDeterministicJs, kDisableJavascript,
  kDivStructure, kElideAttributes, kExperimentCollectMobImageInfo, kExperimentHttp2,
  kExplicitCloseTags, kExtendCacheCss, kExtendCacheImages, kExtendCachePdfs,
  kExtendCacheScripts, kFallbackRewriteCssUrls, kFixReflows, kFlattenCssImports,
  kFlushSubresources, kHandleNoscriptRedirect, kHintPreloadSubresources, kHtmlWriterFilter,
  kIncludeJsSourceMaps, kInlineCss, kInlineGoogleFontCss, kInlineImages,
  kInlineImportToLink, kInlineJavascript, kInPlaceOptimizeForBrowser, kInsertAmpLink,
  kInsertDnsPrefetch, kInsertGA, kInsertImageDimensions, kJpegSubsampling,
  kLazyloadImages, kLeftTrimUrls, kLocalStorageCache, kMakeGoogleAnalyticsAsync,
  kMakeShowAdsAsync, kMobilize, kMobilizePrecompute, kMoveCssAboveScripts,
  kMoveCssToHead, kOutlineCss, kOutlineJavascript, kPedantic,
  kPrioritizeCriticalCss, kRecompressJpeg, kRecompressPng, kRecompressWebp,
  kRemoveComments, kRemoveQuotes, kResizeImages, kResizeMobileImages,
  kResizeToRenderedImageDimensions, kResponsiveImages, kResponsiveImagesZoom, kRewriteCss,
  kRewriteDomains, kRewriteJavascriptExternal, kRewriteJavascriptInline, kRewriteStyleAttributes,
  kRewriteStyleAttributesWithUrl, kServeDeprecationNotice, kSplitHtml, kSplitHtmlHelper,
  kSpriteImages, kStripImageColorProfile, kStripImageMetaData, kStripScripts,
  kEndOfFilters
}
 
enum  EnabledEnum { kEnabledOff, kEnabledOn, kEnabledUnplugged }
 
enum  OptionScope {
  kQueryScope, kDirectoryScope, kServerScope, kLegacyProcessScope,
  kProcessScopeStrict
}
 
enum  RewriteLevel {
  kPassThrough, kOptimizeForBandwidth, kCoreFilters, kMobilizeFilters,
  kTestingCoreFilters, kAllFilters
}
 
enum  OptionSettingResult { kOptionOk, kOptionNameUnknown, kOptionValueInvalid }
 Used for return value of SetOptionFromName.
 
typedef EnumSet< Filter,
kEndOfFilters > 
FilterSet
 
typedef std::vector< FilterFilterVector
 
typedef std::set< GoogleStringFilterIdSet
 Convenience name for a set of rewrite filter ids.
 
typedef std::pair
< GoogleString, GoogleString
OptionStringPair
 
typedef std::set
< OptionStringPair
OptionSet
 
typedef std::vector
< PropertyBase * > 
PropertyVector
 
typedef std::vector< OptionBase * > OptionBaseVector
 Convenience name for a set of rewrite options.
 
typedef std::set
< semantic_type::Category > 
ResourceCategorySet
 

Public Member Functions

bool AllowVaryOnAuto () const
 
bool AllowVaryOnAccept () const
 
bool AllowVaryOnSaveData () const
 
bool AllowVaryOnUserAgent () const
 
GoogleString AllowVaryOnToString () const
 
bool SupportSaveData () const
 
void set_allow_vary_on (const AllowVaryOn &x)
 
int64 ImageJpegQuality () const
 Image qualities and parameters, after applying the inheritance rules.
 
int64 ImageJpegQualityForSmallScreen () const
 
int64 ImageJpegQualityForSaveData () const
 
int64 ImageWebpQuality () const
 
int64 ImageWebpQualityForSmallScreen () const
 
int64 ImageWebpQualityForSaveData () const
 
int64 ImageWebpAnimatedQuality () const
 
int64 ImageJpegNumProgressiveScansForSmallScreen () const
 
bool HasValidSmallScreenQualities () const
 
bool HasValidSaveDataQualities () const
 
bool ImageOptimizationEnabled () const
 
 RewriteOptions (ThreadSystem *thread_system)
 
bool ModificationOK () const
 
bool MergeOK () const
 
void InitializeOptions (const Properties *properties)
 
bool modified () const
 
void SetDefaultRewriteLevel (RewriteLevel level)
 
void SetRewriteLevel (RewriteLevel level)
 
bool ValidateConfiguredHttpHeader (const GoogleString &name, const GoogleString &value, GoogleString *error_message)
 
bool ValidateAndAddResourceHeader (const StringPiece &name, const StringPiece &value, GoogleString *error_message)
 
void AddResourceHeader (const StringPiece &name, const StringPiece &value)
 
const NameValueresource_header (int i) const
 
int num_resource_headers () const
 
void AddCustomFetchHeader (const StringPiece &name, const StringPiece &value)
 Specify a header to insert when fetching subresources.
 
const NameValuecustom_fetch_header (int i) const
 
int num_custom_fetch_headers () const
 
ExperimentSpecGetExperimentSpec (int id) const
 
bool AvailableExperimentId (int id)
 
virtual ExperimentSpecAddExperimentSpec (const StringPiece &spec, MessageHandler *handler)
 
virtual bool SetExperimentState (int id)
 
void SetExperimentStateStr (const StringPiece &experiment_index)
 
int experiment_id () const
 
int experiment_spec_id (int i) const
 
GoogleString GetExperimentStateStr () const
 
ExperimentSpecexperiment_spec (int i) const
 
int num_experiments () const
 
bool enroll_experiment () const
 
void AddUrlValuedAttribute (const StringPiece &element, const StringPiece &attribute, semantic_type::Category category)
 
void UrlValuedAttribute (int index, StringPiece *element, StringPiece *attribute, semantic_type::Category *category) const
 
int num_url_valued_attributes () const
 
void AddInlineUnauthorizedResourceType (semantic_type::Category category)
 
bool HasInlineUnauthorizedResourceType (semantic_type::Category category) const
 
void ClearInlineUnauthorizedResourceTypes ()
 
void set_inline_unauthorized_resource_types (ResourceCategorySet x)
 
bool RegisterLibrary (uint64 bytes, StringPiece md5_hash, StringPiece canonical_url)
 Store size, md5 hash and canonical url for library recognition.
 
const
JavascriptLibraryIdentification
javascript_library_identification () const
 
RewriteLevel level () const
 
bool AdjustFiltersByCommaSeparatedList (const StringPiece &filters, MessageHandler *handler)
 
bool EnableFiltersByCommaSeparatedList (const StringPiece &filters, MessageHandler *handler)
 
bool DisableFiltersByCommaSeparatedList (const StringPiece &filters, MessageHandler *handler)
 
bool ForbidFiltersByCommaSeparatedList (const StringPiece &filters, MessageHandler *handler)
 
void DisableAllFilters ()
 Set rewrite level to kPassThrough and explicitly disable all filters.
 
void DisableAllFiltersNotExplicitlyEnabled ()
 
void EnableFilter (Filter filter)
 
void ForceEnableFilter (Filter filter)
 
void DisableFilter (Filter filter)
 
void DisableIfNotExplictlyEnabled (Filter filter)
 
void ForbidFilter (Filter filter)
 
void EnableFilters (const FilterSet &filter_set)
 
void DisableFilters (const FilterSet &filter_set)
 
void ForbidFilters (const FilterSet &filter_set)
 
void ClearFilters ()
 
void SoftEnableFilterForTesting (Filter filter)
 
void EnableExtendCacheFilters ()
 
bool Enabled (Filter filter) const
 
bool Forbidden (Filter filter) const
 
bool Forbidden (StringPiece filter_id) const
 
void GetEnabledFiltersRequiringScriptExecution (FilterVector *filters) const
 Returns the set of enabled filters that require JavaScript for execution.
 
void DisableFiltersRequiringScriptExecution ()
 Disables all filters that depend on executing custom javascript.
 
void DisableFiltersThatCantRunInAjax ()
 Disables all filters that cannot be run in an Ajax call.
 
bool RequiresAddHead () const
 
bool UsePerOriginPropertyCachePage () const
 
OptionSettingResult SetOptionFromName (StringPiece name, StringPiece value, GoogleString *msg)
 
OptionSettingResult SetOptionFromName (StringPiece name, StringPiece value)
 Like above, but doesn't bother formatting the error message.
 
OptionSettingResult SetOptionFromQuery (StringPiece name, StringPiece value)
 
OptionSettingResult SetOptionFromRemoteConfig (StringPiece name, StringPiece value)
 
GoogleString ScopeEnumToString (OptionScope scope)
 
virtual OptionSettingResult ParseAndSetOptionFromName1 (StringPiece name, StringPiece arg, GoogleString *msg, MessageHandler *handler)
 
OptionSettingResult ParseAndSetOptionFromNameWithScope (StringPiece name, StringPiece arg, OptionScope max_scope, GoogleString *msg, MessageHandler *handler)
 
virtual OptionSettingResult ParseAndSetOptionFromName2 (StringPiece name, StringPiece arg1, StringPiece arg2, GoogleString *msg, MessageHandler *handler)
 
virtual OptionSettingResult ParseAndSetOptionFromName3 (StringPiece name, StringPiece arg1, StringPiece arg2, StringPiece arg3, GoogleString *msg, MessageHandler *handler)
 
bool OptionValue (StringPiece option_name, const char **id, bool *was_set, GoogleString *value) const
 
bool SetOptionsFromName (const OptionSet &option_set, MessageHandler *handler)
 
bool SetOptionFromNameAndLog (StringPiece name, StringPiece value, MessageHandler *handler)
 
int64 css_outline_min_bytes () const
 
void set_css_outline_min_bytes (int64 x)
 
const GoogleStringga_id () const
 
void set_ga_id (const GoogleString &id)
 
void set_content_experiment_id (const GoogleString &s)
 
const GoogleStringcontent_experiment_id () const
 
void set_content_experiment_variant_id (const GoogleString &s)
 
const GoogleStringcontent_experiment_variant_id () const
 
bool is_content_experiment () const
 
bool use_analytics_js () const
 
void set_use_analytics_js (bool x)
 
bool increase_speed_tracking () const
 
void set_increase_speed_tracking (bool x)
 
int64 js_outline_min_bytes () const
 
void set_js_outline_min_bytes (int64 x)
 
int64 progressive_jpeg_min_bytes () const
 
void set_progressive_jpeg_min_bytes (int64 x)
 
int64 css_flatten_max_bytes () const
 
void set_css_flatten_max_bytes (int64 x)
 
bool cache_small_images_unrewritten () const
 
void set_cache_small_images_unrewritten (bool x)
 
int64 image_resolution_limit_bytes () const
 
void set_image_resolution_limit_bytes (int64 x)
 
int64 ImageInlineMaxBytes () const
 Retrieve the image inlining threshold, but return 0 if it's disabled.
 
void set_image_inline_max_bytes (int64 x)
 
int64 CssImageInlineMaxBytes () const
 Retrieve the css image inlining threshold, but return 0 if it's disabled.
 
void set_css_image_inline_max_bytes (int64 x)
 
int64 MaxImageInlineMaxBytes () const
 The larger of ImageInlineMaxBytes and CssImageInlineMaxBytes.
 
int64 css_inline_max_bytes () const
 
void set_css_inline_max_bytes (int64 x)
 
int64 google_font_css_inline_max_bytes () const
 
void set_google_font_css_inline_max_bytes (int64 x)
 
int64 js_inline_max_bytes () const
 
void set_js_inline_max_bytes (int64 x)
 
int64 max_html_cache_time_ms () const
 
void set_max_html_cache_time_ms (int64 x)
 
int64 max_html_parse_bytes () const
 
void set_max_html_parse_bytes (int64 x)
 
int64 max_cacheable_response_content_length () const
 
void set_max_cacheable_response_content_length (int64 x)
 
int64 min_resource_cache_time_to_rewrite_ms () const
 
void set_min_resource_cache_time_to_rewrite_ms (int64 x)
 
bool need_to_store_experiment_data () const
 
void set_need_to_store_experiment_data (bool x)
 
int64 blocking_fetch_timeout_ms () const
 
void set_blocking_fetch_timeout_ms (int64 x)
 
bool override_ie_document_mode () const
 
void set_override_ie_document_mode (bool x)
 
bool preserve_subresource_hints () const
 
void set_preserve_subresource_hints (bool x)
 
bool preserve_url_relativity () const
 
void set_preserve_url_relativity (bool x)
 
bool IsUrlCacheValid (StringPiece url, int64 time_ms, bool search_wildcards) const
 
void AddUrlCacheInvalidationEntry (StringPiece url_pattern, int64 timestamp_ms, bool ignores_metadata_and_pcache)
 
void PurgeUrl (StringPiece url, int64 timestamp_ms)
 Purge a cache entry for an exact URL, not a wildcard.
 
bool IsUrlCacheInvalidationEntriesSorted () const
 
void set_cache_invalidation_timestamp_mutex (ThreadSystem::RWLock *lock)
 
int64 cache_invalidation_timestamp () const
 
bool has_cache_invalidation_timestamp_ms () const
 
bool UpdateCacheInvalidationTimestampMs (int64 timestamp_ms) LOCKS_EXCLUDED(cache_purge_mutex_.get())
 
bool UpdateCachePurgeSet (const CopyOnWrite< PurgeSet > &purge_set) LOCKS_EXCLUDED(cache_purge_mutex_.get())
 
GoogleString PurgeSetString () const
 
int64 idle_flush_time_ms () const
 
void set_idle_flush_time_ms (int64 x)
 
int64 flush_buffer_limit_bytes () const
 How much accumulated HTML will result in PSA introducing a flush.
 
void set_flush_buffer_limit_bytes (int64 x)
 
int max_url_segment_size () const
 
void set_max_url_segment_size (int x)
 
int image_max_rewrites_at_once () const
 
void set_image_max_rewrites_at_once (int x)
 
int max_url_size () const
 The maximum size of the entire URL. If '0', this is left unlimited.
 
void set_max_url_size (int x)
 
int rewrite_deadline_ms () const
 
void set_rewrite_deadline_ms (int x)
 
bool test_instant_fetch_rewrite_deadline () const
 
void set_test_instant_fetch_rewrite_deadline (bool x)
 
void set_test_only_prioritize_critical_css_dont_apply_original_css (bool x)
 
bool test_only_prioritize_critical_css_dont_apply_original_css () const
 
int domain_shard_count () const
 
void set_domain_shard_count (int64 x)
 
void set_enabled (EnabledEnum x)
 
bool enabled () const
 
bool unplugged () const
 
void set_add_options_to_urls (bool x)
 
bool add_options_to_urls () const
 
void set_publicly_cache_mismatched_hashes_experimental (bool x)
 
bool publicly_cache_mismatched_hashes_experimental () const
 
void set_oblivious_pagespeed_urls (bool x)
 
bool oblivious_pagespeed_urls () const
 
void set_in_place_rewriting_enabled (bool x)
 
bool in_place_rewriting_enabled () const
 
void set_in_place_wait_for_optimized (bool x)
 
bool in_place_wait_for_optimized () const
 
void set_in_place_rewrite_deadline_ms (int x)
 
int in_place_rewrite_deadline_ms () const
 
void set_in_place_s_maxage_sec (int x)
 
int in_place_s_maxage_sec () const
 
int EffectiveInPlaceSMaxAgeSec () const
 
void set_in_place_preemptive_rewrite_css (bool x)
 
bool in_place_preemptive_rewrite_css () const
 
void set_in_place_preemptive_rewrite_css_images (bool x)
 
bool in_place_preemptive_rewrite_css_images () const
 
void set_in_place_preemptive_rewrite_images (bool x)
 
bool in_place_preemptive_rewrite_images () const
 
void set_in_place_preemptive_rewrite_javascript (bool x)
 
bool in_place_preemptive_rewrite_javascript () const
 
void set_private_not_vary_for_ie (bool x)
 
bool private_not_vary_for_ie () const
 
void set_combine_across_paths (bool x)
 
bool combine_across_paths () const
 
void set_log_background_rewrites (bool x)
 
bool log_background_rewrites () const
 
void set_log_mobilization_samples (bool x)
 
bool log_mobilization_samples () const
 
void set_log_rewrite_timing (bool x)
 
bool log_rewrite_timing () const
 
void set_log_url_indices (bool x)
 
bool log_url_indices () const
 
void set_lowercase_html_names (bool x)
 
bool lowercase_html_names () const
 
void set_always_rewrite_css (bool x)
 
bool always_rewrite_css () const
 
void set_respect_vary (bool x)
 
bool respect_vary () const
 
void set_respect_x_forwarded_proto (bool x)
 
bool respect_x_forwarded_proto () const
 
void set_flush_html (bool x)
 
bool flush_html () const
 
void set_serve_stale_if_fetch_error (bool x)
 
bool serve_stale_if_fetch_error () const
 
void set_serve_xhr_access_control_headers (bool x)
 
bool serve_xhr_access_control_headers () const
 
void set_proactively_freshen_user_facing_request (bool x)
 
bool proactively_freshen_user_facing_request () const
 
void set_serve_stale_while_revalidate_threshold_sec (int64 x)
 
int64 serve_stale_while_revalidate_threshold_sec () const
 
void set_default_cache_html (bool x)
 
bool default_cache_html () const
 
void set_modify_caching_headers (bool x)
 
bool modify_caching_headers () const
 
void set_inline_only_critical_images (bool x)
 
bool inline_only_critical_images () const
 
void set_critical_images_beacon_enabled (bool x)
 
bool critical_images_beacon_enabled () const
 
void set_beacon_reinstrument_time_sec (int x)
 
int beacon_reinstrument_time_sec () const
 
void set_accept_invalid_signatures (bool x)
 
bool accept_invalid_signatures () const
 
void set_remote_configuration_timeout_ms (int64 x)
 
int64 remote_configuration_timeout_ms () const
 
void set_remote_configuration_url (StringPiece p)
 
const GoogleStringremote_configuration_url () const
 
void set_http_cache_compression_level (int x)
 
int http_cache_compression_level () const
 
void set_request_option_override (StringPiece p)
 
const GoogleStringrequest_option_override () const
 
void set_url_signing_key (StringPiece p)
 
const GoogleStringurl_signing_key () const
 
void set_lazyload_images_after_onload (bool x)
 
bool lazyload_images_after_onload () const
 
void set_lazyload_images_blank_url (StringPiece p)
 
const GoogleStringlazyload_images_blank_url () const
 
void set_max_inlined_preview_images_index (int x)
 
int max_inlined_preview_images_index () const
 
void set_use_blank_image_for_inline_preview (bool x)
 
bool use_blank_image_for_inline_preview () const
 
void set_min_image_size_low_resolution_bytes (int64 x)
 
int64 min_image_size_low_resolution_bytes () const
 
void set_max_image_size_low_resolution_bytes (int64 x)
 
int64 max_image_size_low_resolution_bytes () const
 
void set_experiment_cookie_duration_ms (int64 x)
 
int64 experiment_cookie_duration_ms () const
 
void set_finder_properties_cache_expiration_time_ms (int64 x)
 
int64 finder_properties_cache_expiration_time_ms () const
 
void set_finder_properties_cache_refresh_time_ms (int64 x)
 
int64 finder_properties_cache_refresh_time_ms () const
 
void set_rewrite_random_drop_percentage (int x)
 
int rewrite_random_drop_percentage () const
 
bool css_preserve_urls () const
 
void set_css_preserve_urls (bool x)
 
bool image_preserve_urls () const
 
void set_image_preserve_urls (bool x)
 
bool js_preserve_urls () const
 
void set_js_preserve_urls (bool x)
 
void set_metadata_cache_staleness_threshold_ms (int64 x)
 
int64 metadata_cache_staleness_threshold_ms () const
 
void set_metadata_input_errors_cache_ttl_ms (int64 x)
 
int64 metadata_input_errors_cache_ttl_ms () const
 
const GoogleStringdownstream_cache_purge_method () const
 
void set_downstream_cache_purge_method (StringPiece p)
 
const GoogleStringdownstream_cache_purge_location_prefix () const
 
void set_downstream_cache_purge_location_prefix (StringPiece p)
 
bool IsDownstreamCacheIntegrationEnabled () const
 
void set_downstream_cache_rebeaconing_key (StringPiece p)
 
const GoogleStringdownstream_cache_rebeaconing_key () const
 
bool IsDownstreamCacheRebeaconingKeyConfigured () const
 
bool MatchesDownstreamCacheRebeaconingKey (StringPiece key) const
 
void set_downstream_cache_rewritten_percentage_threshold (int64 x)
 
int64 downstream_cache_rewritten_percentage_threshold () const
 
const BeaconUrlbeacon_url () const
 
void set_beacon_url (const GoogleString &beacon_url)
 
virtual bool trim_urls_in_css () const
 Return false in a subclass if you want to disallow all URL trimming in CSS.
 
void set_image_jpeg_recompress_quality (int64 x)
 
void set_image_jpeg_recompress_quality_for_small_screens (int64 x)
 
void set_image_jpeg_quality_for_save_data (int64 x)
 
int64 image_recompress_quality () const
 
void set_image_recompress_quality (int64 x)
 
int image_limit_optimized_percent () const
 
void set_image_limit_optimized_percent (int x)
 
int image_limit_resize_area_percent () const
 
void set_image_limit_resize_area_percent (int x)
 
int image_limit_rendered_area_percent () const
 
void set_image_limit_rendered_area_percent (int x)
 
int64 image_jpeg_num_progressive_scans () const
 
void set_image_jpeg_num_progressive_scans (int64 x)
 
void set_image_jpeg_num_progressive_scans_for_small_screens (int64 x)
 
void set_image_webp_recompress_quality (int64 x)
 
void set_image_webp_recompress_quality_for_small_screens (int64 x)
 
void set_image_webp_animated_recompress_quality (int64 x)
 
void set_image_webp_quality_for_save_data (int64 x)
 
int64 image_webp_timeout_ms () const
 
void set_image_webp_timeout_ms (int64 x)
 
bool domain_rewrite_hyperlinks () const
 
void set_domain_rewrite_hyperlinks (bool x)
 
bool domain_rewrite_cookies () const
 
void set_domain_rewrite_cookies (bool x)
 
bool client_domain_rewrite () const
 
void set_client_domain_rewrite (bool x)
 
void set_follow_flushes (bool x)
 
bool follow_flushes () const
 
void set_enable_defer_js_experimental (bool x)
 
bool enable_defer_js_experimental () const
 
void set_disable_rewrite_on_no_transform (bool x)
 
bool disable_rewrite_on_no_transform () const
 
void set_disable_background_fetches_for_bots (bool x)
 
bool disable_background_fetches_for_bots () const
 
void set_enable_cache_purge (bool x)
 
bool enable_cache_purge () const
 
void set_proactive_resource_freshening (bool x)
 
bool proactive_resource_freshening () const
 
void set_lazyload_highres_images (bool x)
 
bool lazyload_highres_images () const
 
void set_use_fallback_property_cache_values (bool x)
 
bool use_fallback_property_cache_values () const
 
void set_await_pcache_lookup (bool x)
 
bool await_pcache_lookup () const
 
void set_enable_prioritizing_scripts (bool x)
 
bool enable_prioritizing_scripts () const
 
const GoogleStringblocking_rewrite_key () const
 
void set_blocking_rewrite_key (StringPiece p)
 
void EnableBlockingRewriteForRefererUrlPattern (StringPiece url_pattern)
 
bool IsBlockingRewriteEnabledForReferer (StringPiece url) const
 
bool IsBlockingRewriteRefererUrlPatternPresent () const
 
bool rewrite_uncacheable_resources () const
 
void set_rewrite_uncacheable_resources (bool x)
 
void set_running_experiment (bool x)
 
bool running_experiment () const
 
void set_experiment_ga_slot (int x)
 x should be between 1 and 5 inclusive.
 
int experiment_ga_slot () const
 
void set_enroll_experiment_id (int x)
 
int enroll_experiment_id () const
 
void set_report_unload_time (bool x)
 
bool report_unload_time () const
 
void set_implicit_cache_ttl_ms (int64 x)
 
int64 implicit_cache_ttl_ms () const
 
void set_load_from_file_cache_ttl_ms (int64 x)
 
int64 load_from_file_cache_ttl_ms () const
 
bool load_from_file_cache_ttl_ms_was_set () const
 
void set_x_header_value (StringPiece p)
 
const GoogleStringx_header_value () const
 
void set_avoid_renaming_introspective_javascript (bool x)
 
bool avoid_renaming_introspective_javascript () const
 
void set_forbid_all_disabled_filters (bool x)
 
bool forbid_all_disabled_filters () const
 
bool reject_blacklisted () const
 
void set_reject_blacklisted (bool x)
 
HttpStatus::Code reject_blacklisted_status_code () const
 
void set_reject_blacklisted_status_code (HttpStatus::Code x)
 
bool support_noscript_enabled () const
 
void set_support_noscript_enabled (bool x)
 
bool enable_extended_instrumentation () const
 
void set_enable_extended_instrumentation (bool x)
 
bool use_experimental_js_minifier () const
 
void set_use_experimental_js_minifier (bool x)
 
void set_max_combined_css_bytes (int64 x)
 
int64 max_combined_css_bytes () const
 
void set_max_combined_js_bytes (int64 x)
 
int64 max_combined_js_bytes () const
 
void set_pre_connect_url (StringPiece p)
 
const GoogleStringpre_connect_url () const
 
void set_property_cache_http_status_stability_threshold (int x)
 
int property_cache_http_status_stability_threshold () const
 
void set_max_rewrite_info_log_size (int x)
 
int max_rewrite_info_log_size () const
 
void set_enable_aggressive_rewriters_for_mobile (bool x)
 
bool enable_aggressive_rewriters_for_mobile () const
 
void set_allow_logging_urls_in_log_record (bool x)
 
bool allow_logging_urls_in_log_record () const
 
void set_allow_options_to_be_set_by_cookies (bool x)
 
bool allow_options_to_be_set_by_cookies () const
 
void set_non_cacheables_for_cache_partial_html (StringPiece p)
 
const GoogleStringnon_cacheables_for_cache_partial_html () const
 
void set_no_transform_optimized_images (bool x)
 
bool no_transform_optimized_images () const
 
void set_access_control_allow_origins (StringPiece p)
 
const GoogleStringaccess_control_allow_origins () const
 
void set_hide_referer_using_meta (bool x)
 
bool hide_referer_using_meta () const
 
void set_max_low_res_image_size_bytes (int64 x)
 
int64 max_low_res_image_size_bytes () const
 
void set_max_low_res_to_full_res_image_size_percentage (int x)
 
int max_low_res_to_full_res_image_size_percentage () const
 
void set_serve_rewritten_webp_urls_to_any_agent (bool x)
 
bool serve_rewritten_webp_urls_to_any_agent () const
 
void set_cache_fragment (StringPiece p)
 
const GoogleStringcache_fragment () const
 
void set_sticky_query_parameters (StringPiece p)
 
const GoogleStringsticky_query_parameters () const
 
void set_option_cookies_duration_ms (int64 x)
 
int64 option_cookies_duration_ms () const
 
void set_responsive_image_densities (const ResponsiveDensities &x)
 
const ResponsiveDensitiesresponsive_image_densities () const
 
const GoogleStringamp_link_pattern () const
 
void set_amp_link_pattern (const GoogleString &id)
 
virtual bool DisableDomainRewrite () const
 
virtual void Merge (const RewriteOptions &src)
 
void MergeOnlyProcessScopeOptions (const RewriteOptions &src)
 
void Allow (StringPiece wildcard_pattern)
 
void Disallow (StringPiece wildcard_pattern)
 
void AllowWhenInlining (StringPiece wildcard_pattern)
 Like Allow(). See IsAllowedWhenInlining().
 
void AllowOnlyWhenInlining (StringPiece wildcard_pattern)
 
void DisallowWhenInlining (StringPiece wildcard_pattern)
 Like Disallow(). See IsAllowedWhenInlining().
 
virtual void DisallowTroublesomeResources ()
 
virtual void DisallowResourcesForProxy ()
 
const DomainLawyerdomain_lawyer () const
 
DomainLawyerWriteableDomainLawyer ()
 
FileLoadPolicyfile_load_policy ()
 
const FileLoadPolicyfile_load_policy () const
 
bool IsAllowed (StringPiece url) const
 
bool IsAllowedWhenInlining (StringPiece url) const
 
void RetainComment (StringPiece comment)
 Adds a new comment wildcard pattern to be retained.
 
bool IsRetainedComment (StringPiece comment) const
 
void DisableLazyloadForClassName (StringPiece class_name)
 Adds a new class name for which lazyload should be disabled.
 
bool IsLazyloadEnabledForClassName (StringPiece class_name) const
 Checks if lazyload images is enabled for the specified class.
 
void AddCssCombiningWildcard (StringPiece id_wildcard)
 Adds a new comment wildcard pattern to be retained.
 
bool IsAllowedIdForCssCombining (StringPiece id) const
 
bool CssCombiningMayPermitIds () const
 
void set_override_caching_ttl_ms (int64 x)
 
int64 override_caching_ttl_ms () const
 
void AddOverrideCacheTtl (StringPiece wildcard)
 
bool IsCacheTtlOverridden (StringPiece url) const
 Is the cache TTL overridden for the given url?
 
void AddRejectedUrlWildcard (const GoogleString &wildcard)
 
void AddRejectedHeaderWildcard (StringPiece header_name, const GoogleString &wildcard)
 
bool IsRequestDeclined (const GoogleString &url, const RequestHeaders *request_headers) const
 
virtual RewriteOptionsClone () const
 
virtual RewriteOptionsNewOptions () const
 Make an empty options object of the same type as this.
 
void ComputeSignature () LOCKS_EXCLUDED(cache_purge_mutex_.get())
 
void ComputeSignatureLockHeld () SHARED_LOCKS_REQUIRED(cache_purge_mutex_)
 
virtual GoogleString SubclassSignatureLockHeld ()
 
void Freeze ()
 
bool ClearSignatureWithCaution ()
 
bool frozen () const
 
bool ClearSignatureForTesting ()
 
const GoogleStringsignature () const
 Returns the computed signature. More...
 
virtual GoogleString OptionsToString () const
 
GoogleString FilterSetToString (const FilterSet &filter_set) const
 
GoogleString EnabledFiltersToString () const
 
GoogleString SafeEnabledOptionsToString () const
 
virtual GoogleString ToExperimentString () const
 
virtual GoogleString ToExperimentDebugString () const
 
const OptionBaseVectorall_options () const
 
bool IsEqual (const RewriteOptions &that) const
 
const Hasherhasher () const
 Returns the hasher used for signatures and URLs to purge.
 
const SHA1Signaturesha1signature () const
 
ThreadSystemthread_system () const
 
HttpOptions ComputeHttpOptions () const
 
bool NeedsDependenciesCohort () const
 

Static Public Member Functions

static const char * FilterName (Filter filter)
 
static const char * FilterId (Filter filter)
 
static int NumFilterIds ()
 
static bool AddByNameToFilterSet (const StringPiece &option, FilterSet *set, MessageHandler *handler)
 
static bool ParseRewriteLevel (const StringPiece &in, RewriteLevel *out)
 
static bool ParseInlineUnauthorizedResourceType (const StringPiece &in, ResourceCategorySet *resource_types)
 
static bool ParseBeaconUrl (const StringPiece &in, BeaconUrl *out)
 
static bool Initialize ()
 
static bool Terminate ()
 
static bool AddCommaSeparatedListToOptionSet (const StringPiece &options, OptionSet *set, MessageHandler *handler)
 
static bool ParseFromString (StringPiece value_string, bool *value)
 
static bool ParseFromString (StringPiece value_string, EnabledEnum *value)
 
static bool ParseFromString (StringPiece value_string, int *value)
 
static bool ParseFromString (StringPiece value_string, int64 *value)
 
static bool ParseFromString (StringPiece value_string, double *value)
 
static bool ParseFromString (StringPiece value_string, GoogleString *value)
 
static bool ParseFromString (StringPiece value_string, RewriteLevel *value)
 
static bool ParseFromString (StringPiece value_string, ResourceCategorySet *value)
 
static bool ParseFromString (StringPiece value_string, BeaconUrl *value)
 
static bool ParseFromString (StringPiece value_string, Color *color)
 
static bool ParseFromString (StringPiece value_string, MobTheme *theme)
 
static bool ParseFromString (StringPiece value_string, ResponsiveDensities *value)
 
static bool ParseFromString (StringPiece value_string, protobuf::MessageLite *proto)
 
static bool ParseFromString (StringPiece value_string, AllowVaryOn *allow_vary_on)
 
static Filter LookupFilterById (const StringPiece &filter_id)
 
static Filter LookupFilter (const StringPiece &filter_name)
 Convert the filter name to a Filter.
 
static const PropertyBaseLookupOptionById (StringPiece option_id)
 
static const PropertyBaseLookupOptionByName (StringPiece option_name)
 
static const StringPiece LookupOptionNameById (StringPiece option_id)
 
static bool IsValidOptionName (StringPiece name)
 Determine if the given option name is valid/known.
 
static bool IsDeprecatedOptionName (StringPiece option_name)
 
static const Propertiesdeprecated_properties ()
 

Static Public Attributes

static const char kAcceptInvalidSignatures []
 
static const char kAccessControlAllowOrigins []
 
static const char kAddOptionsToUrls []
 
static const char kAllowLoggingUrlsInLogRecord []
 
static const char kAllowOptionsToBeSetByCookies []
 
static const char kAllowVaryOn []
 
static const char kAlwaysRewriteCss []
 
static const char kAmpLinkPattern []
 
static const char kAnalyticsID []
 
static const char kAvoidRenamingIntrospectiveJavascript []
 
static const char kAwaitPcacheLookup []
 
static const char kBeaconReinstrumentTimeSec []
 
static const char kBeaconUrl []
 
static const char kCacheFragment []
 
static const char kCacheSmallImagesUnrewritten []
 
static const char kClientDomainRewrite []
 
static const char kCombineAcrossPaths []
 
static const char kContentExperimentID []
 
static const char kContentExperimentVariantID []
 
static const char kCriticalImagesBeaconEnabled []
 
static const char kCssFlattenMaxBytes []
 
static const char kCssImageInlineMaxBytes []
 
static const char kCssInlineMaxBytes []
 
static const char kCssOutlineMinBytes []
 
static const char kCssPreserveURLs []
 
static const char kDefaultCacheHtml []
 
static const char kDisableBackgroundFetchesForBots []
 
static const char kDisableRewriteOnNoTransform []
 
static const char kDomainRewriteCookies []
 
static const char kDomainRewriteHyperlinks []
 
static const char kDomainShardCount []
 
static const char kDownstreamCachePurgeMethod []
 
static const char kDownstreamCacheRebeaconingKey []
 
static const char kDownstreamCacheRewrittenPercentageThreshold []
 
static const char kEnableAggressiveRewritersForMobile []
 
static const char kEnableCachePurge []
 
static const char kEnableDeferJsExperimental []
 
static const char kEnableExtendedInstrumentation []
 
static const char kEnableLazyLoadHighResImages []
 
static const char kEnablePrioritizingScripts []
 
static const char kEnabled []
 
static const char kEnrollExperiment []
 
static const char kExperimentCookieDurationMs []
 
static const char kExperimentSlot []
 
static const char kFetcherTimeOutMs []
 
static const char kFinderPropertiesCacheExpirationTimeMs []
 
static const char kFinderPropertiesCacheRefreshTimeMs []
 
static const char kFlushBufferLimitBytes []
 
static const char kFlushHtml []
 
static const char kFollowFlushes []
 
static const char kGoogleFontCssInlineMaxBytes []
 
static const char kForbidAllDisabledFilters []
 
static const char kHideRefererUsingMeta []
 
static const char kHttpCacheCompressionLevel []
 
static const char kIdleFlushTimeMs []
 
static const char kImageInlineMaxBytes []
 
static const char kImageJpegNumProgressiveScans []
 
static const char kImageJpegNumProgressiveScansForSmallScreens []
 
static const char kImageJpegQualityForSaveData []
 
static const char kImageJpegRecompressionQuality []
 
static const char kImageJpegRecompressionQualityForSmallScreens []
 
static const char kImageLimitOptimizedPercent []
 
static const char kImageLimitRenderedAreaPercent []
 
static const char kImageLimitResizeAreaPercent []
 
static const char kImageMaxRewritesAtOnce []
 
static const char kImagePreserveURLs []
 
static const char kImageRecompressionQuality []
 
static const char kImageResolutionLimitBytes []
 
static const char kImageWebpQualityForSaveData []
 
static const char kImageWebpRecompressionQuality []
 
static const char kImageWebpRecompressionQualityForSmallScreens []
 
static const char kImageWebpAnimatedRecompressionQuality []
 
static const char kImageWebpTimeoutMs []
 
static const char kImplicitCacheTtlMs []
 
static const char kIncreaseSpeedTracking []
 
static const char kInlineOnlyCriticalImages []
 
static const char kInPlacePreemptiveRewriteCss []
 
static const char kInPlacePreemptiveRewriteCssImages []
 
static const char kInPlacePreemptiveRewriteImages []
 
static const char kInPlacePreemptiveRewriteJavascript []
 
static const char kInPlaceResourceOptimization []
 
static const char kInPlaceRewriteDeadlineMs []
 
static const char kInPlaceSMaxAgeSec []
 
static const char kInPlaceWaitForOptimized []
 
static const char kJsInlineMaxBytes []
 
static const char kJsOutlineMinBytes []
 
static const char kJsPreserveURLs []
 
static const char kLazyloadImagesAfterOnload []
 
static const char kLazyloadImagesBlankUrl []
 
static const char kLoadFromFileCacheTtlMs []
 
static const char kLogBackgroundRewrite []
 
static const char kLogMobilizationSamples []
 
static const char kLogRewriteTiming []
 
static const char kLogUrlIndices []
 
static const char kLowercaseHtmlNames []
 
static const char kMaxCacheableResponseContentLength []
 
static const char kMaxCombinedCssBytes []
 
static const char kMaxCombinedJsBytes []
 
static const char kMaxHtmlCacheTimeMs []
 
static const char kMaxHtmlParseBytes []
 
static const char kMaxImageSizeLowResolutionBytes []
 
static const char kMaxInlinedPreviewImagesIndex []
 
static const char kMaxLowResImageSizeBytes []
 
static const char kMaxLowResToHighResImageSizePercentage []
 
static const char kMaxRewriteInfoLogSize []
 
static const char kMaxUrlSegmentSize []
 
static const char kMaxUrlSize []
 
static const char kMetadataCacheStalenessThresholdMs []
 
static const char kMinImageSizeLowResolutionBytes []
 
static const char kMinResourceCacheTimeToRewriteMs []
 
static const char kModifyCachingHeaders []
 
static const char kNoop []
 
static const char kNoTransformOptimizedImages []
 
static const char kNonCacheablesForCachePartialHtml []
 
static const char kObliviousPagespeedUrls []
 
static const char kOptionCookiesDurationMs []
 
static const char kOverrideCachingTtlMs []
 
static const char kPreserveSubresourceHints []
 
static const char kPreserveUrlRelativity []
 
static const char kPrivateNotVaryForIE []
 
static const char kProactiveResourceFreshening []
 
static const char kProactivelyFreshenUserFacingRequest []
 
static const char kProgressiveJpegMinBytes []
 
static const char kPubliclyCacheMismatchedHashesExperimental []
 
static const char kRejectBlacklistedStatusCode []
 
static const char kRejectBlacklisted []
 
static const char kRemoteConfigurationTimeoutMs []
 
static const char kRemoteConfigurationUrl []
 
static const char kReportUnloadTime []
 
static const char kRequestOptionOverride []
 
static const char kRespectVary []
 
static const char kRespectXForwardedProto []
 
static const char kResponsiveImageDensities []
 
static const char kRewriteDeadlineMs []
 
static const char kRewriteLevel []
 
static const char kRewriteRandomDropPercentage []
 
static const char kRewriteUncacheableResources []
 
static const char kRunningExperiment []
 
static const char kServeStaleIfFetchError []
 
static const char kServeStaleWhileRevalidateThresholdSec []
 
static const char kServeXhrAccessControlHeaders []
 
static const char kStickyQueryParameters []
 
static const char kSupportNoScriptEnabled []
 
static const char kTestOnlyPrioritizeCriticalCssDontApplyOriginalCss []
 
static const char kUrlSigningKey []
 
static const char kUseAnalyticsJs []
 
static const char kUseBlankImageForInlinePreview []
 
static const char kUseExperimentalJsMinifier []
 
static const char kUseFallbackPropertyCacheValues []
 
static const char kUseImageScanlineApi []
 
static const char kXModPagespeedHeaderValue []
 
static const char kXPsaBlockingRewrite []
 
static const char kAllow []
 Options that require special handling, e.g. non-scalar values.
 
static const char kBlockingRewriteRefererUrls []
 
static const char kDisableFilters []
 
static const char kDisallow []
 
static const char kDomain []
 
static const char kDownstreamCachePurgeLocationPrefix []
 
static const char kEnableFilters []
 
static const char kExperimentVariable []
 
static const char kExperimentSpec []
 
static const char kForbidFilters []
 
static const char kInlineResourcesWithoutExplicitAuthorization []
 
static const char kRetainComment []
 
static const char kPermitIdsForCssCombining []
 
static const char kAddResourceHeader []
 2-argument ones:
 
static const char kCustomFetchHeader []
 
static const char kLoadFromFile []
 
static const char kLoadFromFileMatch []
 
static const char kLoadFromFileRule []
 
static const char kLoadFromFileRuleMatch []
 
static const char kMapOriginDomain []
 
static const char kMapProxyDomain []
 
static const char kMapRewriteDomain []
 
static const char kShardDomain []
 
static const char kLibrary []
 3-argument ones:
 
static const char kUrlValuedAttribute []
 
static const char kCacheFlushFilename []
 
static const char kCacheFlushPollIntervalSec []
 
static const char kCompressMetadataCache []
 
static const char kFetcherProxy []
 
static const char kFetchHttps []
 
static const char kFileCacheCleanInodeLimit []
 
static const char kFileCacheCleanIntervalMs []
 
static const char kFileCacheCleanSizeKb []
 
static const char kFileCachePath []
 
static const char kLogDir []
 
static const char kLruCacheByteLimit []
 
static const char kLruCacheKbPerProcess []
 
static const char kMemcachedServers []
 
static const char kMemcachedThreads []
 
static const char kMemcachedTimeoutUs []
 
static const char kProxySuffix []
 
static const char kRateLimitBackgroundFetches []
 
static const char kServeWebpToAnyAgent []
 
static const char kSlurpDirectory []
 
static const char kSlurpFlushLimit []
 
static const char kSlurpReadOnly []
 
static const char kSslCertDirectory []
 
static const char kSslCertFile []
 
static const char kStatisticsEnabled []
 
static const char kStatisticsLoggingChartsCSS []
 
static const char kStatisticsLoggingChartsJS []
 
static const char kStatisticsLoggingEnabled []
 
static const char kStatisticsLoggingIntervalMs []
 
static const char kStatisticsLoggingMaxFileSizeKb []
 
static const char kTestProxy []
 
static const char kTestProxySlurp []
 
static const char kUseSharedMemLocking []
 
static const char kNullOption []
 The option name you have when you don't have an option name.
 
static const int kOptionsVersion = 14
 
static const int kHashBytes = 20
 Number of bytes used for signature hashing.
 
static const int kCachePurgeBytes = 25000
 Number of bytes capacity in the URL invalidation set.
 
static const char kCacheExtenderId []
 
static const char kCssCombinerId []
 
static const char kCssFilterId []
 
static const char kCssImportFlattenerId []
 
static const char kCssInlineId []
 
static const char kGoogleFontCssInlineId []
 
static const char kImageCombineId []
 
static const char kImageCompressionId []
 
static const char kInPlaceRewriteId []
 
static const char kJavascriptCombinerId []
 
static const char kJavascriptInlineId []
 
static const char kJavascriptMinId []
 
static const char kJavascriptMinSourceMapId []
 
static const char kLocalStorageCacheId []
 
static const char kPrioritizeCriticalCssId []
 
static const Filter kFirstFilter = kAddBaseTag
 Used for enumerating over all entries in the Filter enum.
 
static const char kDefaultAllowVaryOn []
 
static const int kDefaultBeaconReinstrumentTimeSec
 
static const int64 kDefaultCssFlattenMaxBytes
 
static const int64 kDefaultCssImageInlineMaxBytes
 
static const int64 kDefaultCssInlineMaxBytes
 
static const int64 kDefaultCssOutlineMinBytes
 
static const int64 kDefaultGoogleFontCssInlineMaxBytes
 
static const int64 kDefaultImageInlineMaxBytes
 
static const int64 kDefaultJsInlineMaxBytes
 
static const int64 kDefaultJsOutlineMinBytes
 
static const int64 kDefaultProgressiveJpegMinBytes
 
static const int64 kDefaultMaxCacheableResponseContentLength
 
static const int64 kDefaultMaxHtmlCacheTimeMs
 
static const int64 kDefaultMaxHtmlParseBytes
 
static const int64 kDefaultMaxLowResImageSizeBytes
 
static const int kDefaultMaxLowResToFullResImageSizePercentage
 
static const int64 kDefaultMetadataInputErrorsCacheTtlMs
 
static const int64 kDefaultMinResourceCacheTimeToRewriteMs
 
static const char kDefaultDownstreamCachePurgeMethod []
 
static const int64 kDefaultDownstreamCacheRewrittenPercentageThreshold
 
static const int64 kDefaultIdleFlushTimeMs
 
static const int64 kDefaultFlushBufferLimitBytes
 
static const int64 kDefaultImplicitCacheTtlMs
 
static const int64 kDefaultPrioritizeVisibleContentCacheTimeMs
 
static const char kDefaultBeaconUrl []
 
static const int64 kDefaultImageRecompressQuality
 
static const int64 kDefaultImageJpegQualityForSaveData
 
static const int64 kDefaultImageJpegRecompressQuality
 
static const int64 kDefaultImageJpegRecompressQualityForSmallScreens
 
static const int kDefaultImageLimitOptimizedPercent
 
static const int kDefaultImageLimitRenderedAreaPercent
 
static const int kDefaultImageLimitResizeAreaPercent
 
static const int64 kDefaultImageResolutionLimitBytes
 
static const int64 kDefaultImageJpegNumProgressiveScans
 
static const int64 kDefaultImageWebpQualityForSaveData
 
static const int64 kDefaultImageWebpRecompressQuality
 
static const int64 kDefaultImageWebpAnimatedRecompressQuality
 
static const int64 kDefaultImageWebpRecompressQualityForSmallScreens
 
static const int64 kDefaultImageWebpTimeoutMs
 
static const int kDefaultDomainShardCount
 
static const int64 kDefaultOptionCookiesDurationMs
 
static const int64 kDefaultLoadFromFileCacheTtlMs
 
static const double kDefaultResponsiveImageDensities []
 
static const int kDefaultMaxUrlSize
 
static const int kDefaultImageMaxRewritesAtOnce
 
static const int kDefaultMaxUrlSegmentSize
 
static const int kDefaultRewriteDeadlineMs
 Default time to wait for rewrite before returning original resource.
 
static const int kDefaultMaxInlinedPreviewImagesIndex
 
static const int64 kDefaultMinImageSizeLowResolutionBytes
 
static const int64 kDefaultMaxImageSizeLowResolutionBytes
 
static const int64 kDefaultFinderPropertiesCacheExpirationTimeMs
 Default cache expiration value for finder properties in pcache.
 
static const int64 kDefaultFinderPropertiesCacheRefreshTimeMs
 Default cache refresh value for finder properties in pcache.
 
static const int64 kDefaultExperimentCookieDurationMs
 
static const int64 kDefaultMetadataCacheStalenessThresholdMs
 
static const int64 kDefaultMaxCombinedCssBytes
 Default maximum size of the combined CSS resource.
 
static const int64 kDefaultMaxCombinedJsBytes
 Default maximum size of the combined js resource generated by JsCombiner.
 
static const int kDefaultExperimentTrafficPercent
 
static const int kDefaultExperimentSlot
 Default Custom Variable slot in which to put Experiment information.
 
static const char kDefaultBlockingRewriteKey []
 
static const char kRejectedRequestUrlKeyName []
 
static const int kDefaultPropertyCacheHttpStatusStabilityThreshold
 
static const int kDefaultMaxRewriteInfoLogSize
 

Protected Member Functions

void set_option_at (int index, OptionBase *option)
 
template<class T >
void set_option (const T &new_value, OptionTemplateBase< T > *option)
 
void Modify ()
 Marks the config as modified.
 
void set_default_x_header_value (StringPiece x_header_value)
 
bool SetupExperimentRewriters ()
 
virtual void SetRequiredExperimentFilters ()
 Enables filters needed by Experiment regardless of experiment.
 
bool InsertExperimentSpecInVector (ExperimentSpec *spec)
 

Static Protected Member Functions

template<class RewriteOptionsSubclass , class OptionClass >
static void AddProperty (typename OptionClass::ValueType default_value, OptionClass RewriteOptionsSubclass::*offset, const char *id, StringPiece option_name, OptionScope scope, const char *help_text, bool safe_to_print, Properties *properties)
 Adds a new Property to 'properties' (the last argument).
 
static void AddDeprecatedProperty (StringPiece option_name, OptionScope scope)
 
static void MergeSubclassProperties (Properties *properties)
 

Protected Attributes

Option< BeaconUrlbeacon_url_
 Protected option values so that derived class can modify.
 
Option< GoogleStringx_header_value_
 The value we put for the X-Mod-Pagespeed header. Default is our version.
 

Detailed Description

Defines a set of customizations that can be applied to any Rewrite. There are multiple categories of customizations:

The options are themselves a complex system. Many Option objects are instantiated for each RewriteOptions instance. RewriteOptions can be constructed and destroyed multiple times per request so to reduce this cost, the static aspects of Options are factored out into Properties, which are intialized once per process via RewriteOptions::Initialize. Subclasses may also add new Properties and so property-list-merging takes place at Initialization time.

Member Typedef Documentation

Convenience name for (name,value) pairs of options (typically filter parameters), as well as sets of those pairs.

Member Enumeration Documentation

Enumerator
kEnabledOff 

Don't optimize HTML. Do serve .pagespeed. Can be overridden via query param.

kEnabledOn 

Pagespeed runs normally. Can be overridden via query param.

kEnabledUnplugged 

Completely passive. Do not serve .pagespeed. Return from handlers immediately. Cannot be overridden via query param.

If you add or remove anything from this list, you must also update the kFilterVectorStaticInitializer array in rewrite_options.cc. If you add an image-related filter or a css-related filter, you must add it to the kRelatedFilters array in image_rewrite_filter.cc and/or css_filter.cc

Each filter added here should go into at least one of the filter-arrays in rewrite_options.cc, even if it's just kDangerousFilterSet.

Filters that can improve bandwidth but have basically zero risk of breaking pages should be added to kOptimizeForBandwidthFilterSet. Filters with relatively low risk should be added to kCoreFilterSet.

Enumerator
kAddBaseTag 

Update kFirstFilter if you add something before this.

kExperimentHttp2 

used while developing proper HTTP2 features.

kMobilizePrecompute 
Todo:
TODO(jud): This is unused, remove it.

Determines the scope at which an option is evaluated. In Apache, for example, kDirectoryScope indicates it can be changed via .htaccess files, which is the only way that sites using shared hosting can change settings.

The options are ordered from most permissive to least permissive.

Enumerator
kQueryScope 

customized at query (query-param, request headers, response headers)

kDirectoryScope 

customized at directory level (.htaccess, <Directory>)

kServerScope 

customized at server level (e.g. VirtualHost)

kLegacyProcessScope 

Customized at process level only (command-line flags). This is a legacy value that will make us accept it in a VirtualHost in Apache for backwards compatibility; it should not be used for new options.

kProcessScopeStrict 

Customized at process level and enforced as such.

Todo:
TODO(huibao): Use bitmask for the values of the enums, and make combination of rewrite levels possible.
Enumerator
kPassThrough 

Enable no filters. Parse HTML but do not perform any transformations. This is the default value. Most users should explicitly enable the kCoreFilters level by calling SetRewriteLevel(kCoreFilters).

kOptimizeForBandwidth 

Enable filters that make resources smaller, but carry no risk of site breakage. Turning this on implies inplace resource optimization and preserve-URLs.

kCoreFilters 

Enable the core set of filters. These filters are considered generally safe for most sites, though even safe filters can break some sites. Most users should specify this option, and then optionally add or remove specific filters based on specific needs.

kMobilizeFilters 

Enable the filters which are essential to make webpages designed for desktop computers look good on mobile devices.

kTestingCoreFilters 

Enable all filters intended for core, but some of which might need more testing. Good for if users are willing to test out the results of the rewrite more closely.

kAllFilters 

Enable all filters. This includes filters you should never turn on for a real page, like StripScripts!

Member Function Documentation

static bool net_instaweb::RewriteOptions::AddByNameToFilterSet ( const StringPiece &  option,
FilterSet set,
MessageHandler handler 
)
static

Lookup the given name to see if it's a filter name or one of the special names like "core" or "rewrite_images", and if so add the corresponding filter(s) to the given set. If the given name doesn't match -and- if handler is not NULL, logs a warning message to handler. Returns true if the name matched and the set was updated, false otherwise.

static bool net_instaweb::RewriteOptions::AddCommaSeparatedListToOptionSet ( const StringPiece &  options,
OptionSet *  set,
MessageHandler handler 
)
static

Adds pairs of (option, value) to the option set. The option names and values are not checked for validity, just stored. If the string piece was parsed correctly, this returns true. If there were parsing errors this returns false. The set is still populated on error.

virtual ExperimentSpec* net_instaweb::RewriteOptions::AddExperimentSpec ( const StringPiece &  spec,
MessageHandler handler 
)
virtual

Creates a ExperimentSpec from spec and adds it to the configuration, returning it on success and NULL on failure.

void net_instaweb::RewriteOptions::AddOverrideCacheTtl ( StringPiece  wildcard)
inline

Overrides the cache ttl for all urls matching the wildcard with override_caching_ttl_ms().

void net_instaweb::RewriteOptions::AddResourceHeader ( const StringPiece &  name,
const StringPiece &  value 
)

Unconditionally appends the given name / value to resource_headers_. Use ValidateAndAddResourceHeader if you need validation.

void net_instaweb::RewriteOptions::AddUrlCacheInvalidationEntry ( StringPiece  url_pattern,
int64  timestamp_ms,
bool  ignores_metadata_and_pcache 
)

If timestamp_ms greater than or equal to the last timestamp in url_cache_invalidation_entries_, then appends an UrlCacheInvalidationEntry with 'timestamp_ms' and 'url_pattern' to url_cache_invalidation_entries_. Else does nothing.

Also see PurgeCacheUrl. AddUrlCacheInvalidationEntry with a non-wildcard pattern and ignores_metadata_and_pcache==false is equivalent to PurgeCacheUrl.

If ignores_metadata_and_pcache is true, metadata is not invalidated and property cache is invalidated of URLs matching url_pattern. If false, metadata cache and property cache entries may be invalidated, depending on whether there are wildcards in the pattern, and whether enable_cache_purge() is true. Note that HTTP cache invalidation is always exactly for the URLs matching url_pattern. This should probably always be set to false.

void net_instaweb::RewriteOptions::AddUrlValuedAttribute ( const StringPiece &  element,
const StringPiece &  attribute,
semantic_type::Category  category 
)

Store that when we see <element attribute="X"> we should treat X as a URL pointing to a resource of the type indicated by category. For example, while by default we would treat the 'src' attribute of an a 'img' element as the URL for an image and will cache-extend, inline, or otherwise optimize it as appropriate, we would not do the same for the 'src' atrtribute of a 'span' element () because there's no "src" attribute of "span" in the HTML spec. If someone needed us to treat span.src as a URL, however, they could call: AddUrlValuedAttribute("src", "span", appropriate_category)

Makes copies of element and attribute.

bool net_instaweb::RewriteOptions::AdjustFiltersByCommaSeparatedList ( const StringPiece &  filters,
MessageHandler handler 
)

Enables filters specified without a prefix or with a prefix of '+' and disables filters specified with a prefix of '-'. Returns false if any of the filter names are invalid, but all the valid ones will be added anyway.

const OptionBaseVector& net_instaweb::RewriteOptions::all_options ( ) const
inline

Return the list of all options. Used to initialize the configuration vector to the Apache configuration system.

void net_instaweb::RewriteOptions::Allow ( StringPiece  wildcard_pattern)
inline

Registers a wildcard pattern for to be allowed, potentially overriding previous Disallow wildcards.

void net_instaweb::RewriteOptions::AllowOnlyWhenInlining ( StringPiece  wildcard_pattern)
inline

Helper function to Disallow something except when inlining. Useful for resources that you expect to be on good CDNs but may still be worth inlining if small enough.

bool net_instaweb::RewriteOptions::AvailableExperimentId ( int  id)

Returns false if id is negative, or if the id is reserved for NoExperiment or NotSet, or if we already have an experiment with that id.

int64 net_instaweb::RewriteOptions::cache_invalidation_timestamp ( ) const

Cache invalidation timestamp is in milliseconds since 1970. It is used for invalidating everything in the cache written prior to the timestamp.

Todo:
TODO(jmarantz): rename to cache_invalidation_timestamp_ms().
void net_instaweb::RewriteOptions::ClearFilters ( )

Clear all explicitly enabled and disabled filters. Some filters may still be enabled by the rewrite level and HtmlWriterFilter will be enabled.

bool net_instaweb::RewriteOptions::ClearSignatureForTesting ( )
inline

Clears a computed signature, unfreezing the options object. This is intended for testing. Returns whether the options were frozen in the first place.

bool net_instaweb::RewriteOptions::ClearSignatureWithCaution ( )

Clears the computed signature, unfreezing the options object. Warning: Please note that using this method is extremely risky and should be avoided as much as possible. If you are planning to use this, please discuss this with your team-mates and ensure that you clearly understand its implications. Also, please do repeat this warning at every place you use this method.

Returns true if the signature was previously computed, and thus should be recomputed after modification.

virtual RewriteOptions* net_instaweb::RewriteOptions::Clone ( ) const
virtual

Make an identical copy of these options and return it. This does not copy the signature, and the returned options are not in a frozen state.

Reimplemented in net_instaweb::SystemRewriteOptions, and net_instaweb::ApacheConfig.

HttpOptions net_instaweb::RewriteOptions::ComputeHttpOptions ( ) const

Produces a new HttpOptions each time this is called, shouldn't be a big deal since we don't call it very often and HttpOptions are pretty light, but we might want to reconsider if those assumptions change.

void net_instaweb::RewriteOptions::ComputeSignature ( )

Computes a signature for the RewriteOptions object, including all contained classes (DomainLawyer, FileLoadPolicy, WildCardGroups).

Computing a signature "freezes" the class instance. Attempting to modify a RewriteOptions after freezing will DCHECK.

int64 net_instaweb::RewriteOptions::css_outline_min_bytes ( ) const
inline
Todo:
TODO(jmarantz): consider setting flags in the set_ methods so that first's explicit settings can override default values from second.
bool net_instaweb::RewriteOptions::css_preserve_urls ( ) const
inline

css_preserve_urls() is determined by the following rules in order:

  1. Value set by the user, if the user has explicitly set it.
  2. Default value (true) for OptimizeForBandwidth, if this is the rewrite level.
  3. Default value (true) for MobilizeFilters, if this is the rewrite level.
  4. Default value (false) otherwise.
void net_instaweb::RewriteOptions::DisableAllFiltersNotExplicitlyEnabled ( )

Explicitly disable all filters which are not currently explicitly enabled

Note: Do not call EnableFilter(...) for this options object after calling DisableAllFilters..., because the Disable list will not be auto-updated.

Used to deal with query param ?ModPagespeedFilter=foo Which implies that all filters not listed should be disabled.

bool net_instaweb::RewriteOptions::DisableFiltersByCommaSeparatedList ( const StringPiece &  filters,
MessageHandler handler 
)

Adds a set of filters to the disabled set. Returns false if any of the filter names are invalid, but all the valid ones will be added anyway.

void net_instaweb::RewriteOptions::Disallow ( StringPiece  wildcard_pattern)
inline

Registers a wildcard pattern for to be disallowed, potentially overriding previous Allow wildcards.

virtual void net_instaweb::RewriteOptions::DisallowResourcesForProxy ( )
virtual

Disallows resources that are served on well-distributed CDNs already, and are likely to be in browser-caches, or that are troublesome resources stored on external domains. Note: this is not currently called by mod_pagespeed.

virtual void net_instaweb::RewriteOptions::DisallowTroublesomeResources ( )
virtual

Blacklist of javascript files that don't like their names changed. This should be called for root options to set defaults.

Todo:
TODO(sligocki): Rename to allow for more general initialization.
const DomainLawyer* net_instaweb::RewriteOptions::domain_lawyer ( ) const
inline

When someone asks for a readonly lawyer, we can return a pointer to the potentially shared DomainLawyer* object. But if you want a mutable one, we clone whatever Lawyer we had and detach it from the shared group. Here are several scenarios.

  1. We are setting up the global_options() for a ServerContext on startup. There will be no concurrent access, and at this point there will be no sharing with other RewriteOptions.
  2. We are merging down global_options() based on the vhost/directory/.htaccess data and need to update (among other things) the settings. This may happen concurrently for several different server-scoped, directory-scoped, or request-scoped RewriteOptions objects. Those will all be attached to their parent when the options get created. However writing to these will effectively detach them. One case that would be problematic is a mutation of a parent RewriteOptions->WriteableDomainLawyer() concurrent with instantiating a new child RewriteOptions. However this does not occur in our system.

The only similar place this does occur is cache_invalidation_timestamp_ which can be mutated when there are active children.

void net_instaweb::RewriteOptions::EnableExtendCacheFilters ( )

Enables extend_cache_css, extend_cache_images, and extend_cache_scripts. Does not enable extend_cache_pdfs.

void net_instaweb::RewriteOptions::EnableFilter ( Filter  filter)

Adds the filter to the list of enabled filters. However, if the filter is also present in either the list of disabled or forbidden filters, that takes precedence and it is not enabled.

bool net_instaweb::RewriteOptions::EnableFiltersByCommaSeparatedList ( const StringPiece &  filters,
MessageHandler handler 
)

Adds a set of filters to the enabled set. Returns false if any of the filter names are invalid, but all the valid ones will be added anyway.

static const char* net_instaweb::RewriteOptions::FilterId ( Filter  filter)
static

Returns a two-letter id code for this filter, used for for encoding URLs.

static const char* net_instaweb::RewriteOptions::FilterName ( Filter  filter)
static

Return the appropriate human-readable filter name for the given filter, e.g. "CombineCss".

bool net_instaweb::RewriteOptions::ForbidFiltersByCommaSeparatedList ( const StringPiece &  filters,
MessageHandler handler 
)

Adds a set of filters to the forbidden set. Returns false if any of the filter names are invalid, but all the valid ones will be added anyway.

void net_instaweb::RewriteOptions::ForceEnableFilter ( Filter  filter)

Guarantees that a filter would be enabled even if it is present in the list of disabled filters by removing it from disabled & forbidden filter lists.

void net_instaweb::RewriteOptions::Freeze ( )

Freeze a RewriteOptions so we can't modify it anymore and thus know that it's safe to read it from multiple threads, but don't bother calculating its signature since we will only be using this instance for merging and cloning.

ExperimentSpec* net_instaweb::RewriteOptions::GetExperimentSpec ( int  id) const

Returns the spec with the id_ that matches id. Returns NULL if no spec matches.

GoogleString net_instaweb::RewriteOptions::GetExperimentStateStr ( ) const

Returns a string representation of experiment_id() suitable for consumption by SetExperimentStateStr(), encoding the index of the current experiment (not its id). If we're not running an experiment, returns the empty string.

bool net_instaweb::RewriteOptions::has_cache_invalidation_timestamp_ms ( ) const

Determines whether there is a valid cache_invalidation_timestamp. It is invalid to call cache_invalidation_timestamp() if has_cache_invalidation_timestamp_ms() is false.

bool net_instaweb::RewriteOptions::HasValidSaveDataQualities ( ) const

Returns true if any quality for Save-Data is valid and different from the base quality.

bool net_instaweb::RewriteOptions::HasValidSmallScreenQualities ( ) const

Returns true if any quality for small screen is valid and different from the base quality.

int64 net_instaweb::RewriteOptions::idle_flush_time_ms ( ) const
inline

How much inactivity of HTML input will result in PSA introducing a flush. Values <= 0 disable the feature.

bool net_instaweb::RewriteOptions::ImageOptimizationEnabled ( ) const

Checks if either of the optimizing rewrite options are ON and it includes kRecompressJPeg, kRecompressPng, kRecompressWebp, kConvertGifToPng, kConvertJpegToWebp, kConvertPngToJpeg, and kConvertToWebpLossless.

static bool net_instaweb::RewriteOptions::Initialize ( )
static

Static initialization of members. Calls to Initialize and Terminate must be matched. Returns 'true' for the first Initialize call and the last Terminate call.

void net_instaweb::RewriteOptions::InitializeOptions ( const Properties properties)

Initializes the Options objects in a RewriteOptions instance based on the supplied Properties vector. Note that subclasses can statically define additional properties, in which case they should call this method from their constructor.

bool net_instaweb::RewriteOptions::InsertExperimentSpecInVector ( ExperimentSpec spec)
protected

Helper method to add pre-configured ExperimentSpec objects to the internal vector of ExperimentSpec's. Returns true if the experiment was added successfully. Takes ownership of (and may delete) spec.

bool net_instaweb::RewriteOptions::IsAllowed ( StringPiece  url) const
inline

Determines, based on the sequence of Allow/Disallow calls above, whether a url is allowed.

default allow

bool net_instaweb::RewriteOptions::IsAllowedWhenInlining ( StringPiece  url) const
inline

Call this when:

  1. IsAllowed() returns false and
  2. The url is for a resource we're planning to inline if successful.

If it returns true, it's ok to fetch, rewrite, and inline this resource as if IsAllowed() had returned true.

default disallow

static bool net_instaweb::RewriteOptions::IsDeprecatedOptionName ( StringPiece  option_name)
static

Determine if this is an option name that used to do things, and which we may therefore want to accept w/a warning for backwards compatibility.

bool net_instaweb::RewriteOptions::IsEqual ( const RewriteOptions that) const

Determines whether this and that are the same. Uses the signature() to short-cut most of the deep comparisons, but then compares directly some options and other fields that are omitted from the signature.

bool net_instaweb::RewriteOptions::IsRequestDeclined ( const GoogleString url,
const RequestHeaders request_headers 
) const

Determine if the request url needs to be declined based on the url, request headers and rewrite options.

bool net_instaweb::RewriteOptions::IsRetainedComment ( StringPiece  comment) const
inline

If enabled, the 'remove_comments' filter will remove all HTML comments. As discussed in Issue 237, some comments have semantic value and must be retained.

bool net_instaweb::RewriteOptions::IsUrlCacheInvalidationEntriesSorted ( ) const

Checks if url_cache_invalidation_entries_ is in increasing order of timestamp. For testing.

bool net_instaweb::RewriteOptions::IsUrlCacheValid ( StringPiece  url,
int64  time_ms,
bool  search_wildcards 
) const

Returns whether the given URL is valid for use in the cache, given the timestamp stored in the cache.

It first checks time_ms against the global cache invalidation timestamp.

It next checks if PurgeCacheUrl has been called on url with a timestamp earlier than time_ms. Note: this is not a wildcard check but an exact lookup.

Finally, if search_wildcards is true, it scans url_cache_invalidation_entries_ for entries with timestamp_ms > time_ms and url matching the url_pattern.

In most contexts where you'd call this you should consider instead calling OptionsAwareHTTPCacheCallback::IsCacheValid instead, which takes into account request-headers.

const JavascriptLibraryIdentification* net_instaweb::RewriteOptions::javascript_library_identification ( ) const
inline

Return the javascript_library_identification_ object that applies to the current configuration (NULL if identification is disabled).

static Filter net_instaweb::RewriteOptions::LookupFilterById ( const StringPiece &  filter_id)
static

Convert an id string like "ah" to a Filter enum like kAddHead. Returns kEndOfFilters if the id isn't known.

static const PropertyBase* net_instaweb::RewriteOptions::LookupOptionById ( StringPiece  option_id)
static

Looks up an option id/name and returns the corresponding PropertyBase if found, or NULL if the id/name is not found.

static const StringPiece net_instaweb::RewriteOptions::LookupOptionNameById ( StringPiece  option_id)
static

Looks up an option id and returns the corresponding name, or kNullOption if the id is not found. Example: for "ii" it returns "ImageInlineMaxBytes".

bool net_instaweb::RewriteOptions::MatchesDownstreamCacheRebeaconingKey ( StringPiece  key) const
inline

Return true only if downstream cache rebeaconing key is configured and the key argument matches the configured key.

int net_instaweb::RewriteOptions::max_url_segment_size ( ) const
inline

The maximum length of a URL segment. for http://a/b/c.d, this is == strlen("c.d")

virtual void net_instaweb::RewriteOptions::Merge ( const RewriteOptions src)
virtual

Merge src into 'this'. Generally, options that are explicitly set in src will override those explicitly set in 'this' (except that filters forbidden in 'this' cannot be enabled by 'src'), although option Merge implementations can be redefined by specific Option class implementations (e.g. OptionInt64MergeWithMax). One semantic subject to interpretation is when a core-filter is disabled in the first set and not in the second. My judgement is that the 'disable' from 'this' should override the core-set membership in the 'src', but not an 'enable' in the 'src'.

You can make an exact duplicate of RewriteOptions object 'src' via (new 'typeof src')->Merge(src), aka Clone().

Merge expects that 'src' and 'this' are the same type. If that's not true, this function will DCHECK.

Reimplemented in net_instaweb::ApacheConfig, and net_instaweb::SystemRewriteOptions.

bool net_instaweb::RewriteOptions::MergeOK ( ) const

Determines whether it's OK to merge from the RewriteOptions object in the current thread. Note that this is stricter than necessary, but makes it easier to reason about potential thread safety issues for copy-on-write sharing of substructures.

This is exposed as an external API for ease of unit testing.

void net_instaweb::RewriteOptions::MergeOnlyProcessScopeOptions ( const RewriteOptions src)

Merge the process scope options (including strict ones) from src into this.

static void net_instaweb::RewriteOptions::MergeSubclassProperties ( Properties properties)
staticprotected

Merges properties into all_properties so that RewriteOptions::Merge and SetOptionFromName can work across options from RewriteOptions and all relevant subclasses.

Each RewriteOptions subclass keeps its own property lists using its own private Properties* member variables. The private lists are used for initialization of default-values during construction. We cannot initialize subclass default option values during RewriteOptions construction because options with non-POD ValueType (e.g. GoogleString) have not yet been initialized, so we have to keep separate per-class property-lists for use during construction. However, we use a global sorted list for fast merging and setting-by-option-name.

bool net_instaweb::RewriteOptions::ModificationOK ( ) const

Determines whether it's OK to modify the RewriteOptions in the current thread. Note that this is stricter than necessary, but makes it easier to reason about potential thread safety issues for copy-on-write sharing of substructures.

This is exposed as an external API for ease of unit testing.

bool net_instaweb::RewriteOptions::NeedsDependenciesCohort ( ) const

Returns true if this configuration turns on options that may need the dependencies cohort to operate.

static int net_instaweb::RewriteOptions::NumFilterIds ( )
static

Returns the number of filter ids. This is used to loop over all filter ids using the FilterId() method.

bool net_instaweb::RewriteOptions::OptionValue ( StringPiece  option_name,
const char **  id,
bool *  was_set,
GoogleString value 
) const

Returns the id and value of the specified option-enum in *id and *value. Sets *was_set to true if this option has been altered from the default.

If this option was not found, false is returned, and *id, *was_set, and *value will be left unassigned.

virtual OptionSettingResult net_instaweb::RewriteOptions::ParseAndSetOptionFromName1 ( StringPiece  name,
StringPiece  arg,
GoogleString msg,
MessageHandler handler 
)
virtual

Advanced option parsing, that can understand non-scalar values (unlike SetOptionFromName), and which is extensible by platforms. Returns whether succeeded or the kind of failure, and writes the diagnostic into *msg.

If you extend any of these you also need to extend Merge() and SubclassSignatureLockHeld().

OptionSettingResult net_instaweb::RewriteOptions::ParseAndSetOptionFromNameWithScope ( StringPiece  name,
StringPiece  arg,
OptionScope  max_scope,
GoogleString msg,
MessageHandler handler 
)

Parses and sets options like ParseAndSetOptionFromName1, but with a maximum scope specified. ParseAndSetOptionFromName1 will apply options from any scope, whereas ParseAndSetOptionFromNameWithScope will only apply options within max_scope scope.

static bool net_instaweb::RewriteOptions::ParseBeaconUrl ( const StringPiece &  in,
BeaconUrl out 
)
static

Parse a beacon url, or a pair of beacon urls (http https) separated by a space. If only an http url is given, the https url is derived from it by simply substituting the protocol.

static bool net_instaweb::RewriteOptions::ParseFromString ( StringPiece  value_string,
bool *  value 
)
static

These static methods are used by Option<T>::SetFromString to set Option<T>::value_ from a string representation of it.

GoogleString net_instaweb::RewriteOptions::PurgeSetString ( ) const

Generates a human-readable view of the PurgeSet, including timestamps in GMT.

bool net_instaweb::RewriteOptions::RequiresAddHead ( ) const

Determines whether any filter is enabled that requires a 'head' element to work.

GoogleString net_instaweb::RewriteOptions::SafeEnabledOptionsToString ( ) const

Returns a string containing the enabled options which do not leak sensitive information about the server state.

void net_instaweb::RewriteOptions::set_cache_invalidation_timestamp_mutex ( ThreadSystem::RWLock lock)
inline

Supply optional mutex for setting a global cache invalidation timestamp. Ownership of 'lock' is transfered to this.

void net_instaweb::RewriteOptions::set_default_x_header_value ( StringPiece  x_header_value)
inlineprotected

Sets the global default value for 'x_header_value'. Note that setting this Option reaches through to the underlying property and sets the default value there, and in fact does *not affect the value of the instantiated RewriteOptions object.

Todo:
TODO(jmarantz): Remove this method and make another one that operate directly on the Property.
void net_instaweb::RewriteOptions::set_domain_shard_count ( int64  x)
inline

The argument is int64 to allow it to be set from the http header or url query param and int64_query_params_ only allows setting of 64 bit values.

void net_instaweb::RewriteOptions::set_downstream_cache_purge_location_prefix ( StringPiece  p)
inline

Remove any trailing slashes. Leaving them in causes the request to have multiple trailing slashes.

template<class T >
void net_instaweb::RewriteOptions::set_option ( const T &  new_value,
OptionTemplateBase< T > *  option 
)
inlineprotected

When setting an option, however, we generally are doing so with a variable rather than a constant so it makes sense to pass it by reference.

void net_instaweb::RewriteOptions::set_option_at ( int  index,
OptionBase option 
)
inlineprotected

Populates all_options_, based on the passed-in index, which should correspond to the property index calculated after sorting all_properties_. This enables us to sort the all_properties_ vector once, and use that to give us all_options_ that is sorted the same way.

void net_instaweb::RewriteOptions::SetDefaultRewriteLevel ( RewriteLevel  level)
inline

Sets the default rewrite level for this RewriteOptions object only. Note that the defaults for other RewriteOptions objects are unaffected.

Todo:
TODO(jmarantz): Get rid of this method. The semantics it requires are costly to implement and don't add much value.

Do not set the modified bit – we are only changing the default.

virtual bool net_instaweb::RewriteOptions::SetExperimentState ( int  id)
virtual

Sets which side of the experiment these RewriteOptions are on. Cookie-setting must be done separately. experiment::kExperimentNotSet indicates it hasn't been set. experiment::kNoExperiment indicates this request shouldn't be in any experiment. Then sets the rewriters to match the experiment indicated by id. Returns true if succeeded in setting state.

void net_instaweb::RewriteOptions::SetExperimentStateStr ( const StringPiece &  experiment_index)

We encode experiment information in urls as an experiment index: the first ExperimentSpec is a, the next is b, and so on. Empty string or an invalid letter means kNoExperiment.

OptionSettingResult net_instaweb::RewriteOptions::SetOptionFromName ( StringPiece  name,
StringPiece  value,
GoogleString msg 
)

Set Option 'name' to 'value'. Returns whether it succeeded or the kind of failure (wrong name or value), and writes the diagnostic into 'msg'. This only understands simple scalar options, and not more general things like filter lists, blacklists, etc.

bool net_instaweb::RewriteOptions::SetOptionFromNameAndLog ( StringPiece  name,
StringPiece  value,
MessageHandler handler 
)

Sets Option 'name' to 'value'. Returns whether it succeeded and logs any warnings to 'handler'.

OptionSettingResult net_instaweb::RewriteOptions::SetOptionFromQuery ( StringPiece  name,
StringPiece  value 
)

Same as SetOptionFromName, but only works with options that are valid to use as query parameters, returning kOptionNameUnknown for properties where the scope() is not kQueryScope.

OptionSettingResult net_instaweb::RewriteOptions::SetOptionFromRemoteConfig ( StringPiece  name,
StringPiece  value 
)

Same as SetOptionFromName, but only works with options that are valid to use as remote config, returning kOptionNameUnknown for properties where the scope() is not kQueryScope or kDirectoryScope.

bool net_instaweb::RewriteOptions::SetOptionsFromName ( const OptionSet &  option_set,
MessageHandler handler 
)

Set all of the options to their values specified in the option set. Returns true if all options in the set were successful, false if not.

bool net_instaweb::RewriteOptions::SetupExperimentRewriters ( )
protected

Enable/disable filters and set options according to the current ExperimentSpec that experiment_id_ matches. Returns true if the state was set successfully.

const GoogleString& net_instaweb::RewriteOptions::signature ( ) const
inline

Returns the computed signature.

We take a reader-lock because we may be looking at the global_options signature concurrent with updating it if someone flushes cache. Note that the default mutex implementation is NullRWLock, which isn't actually a mutex. Only (currently) for the Apache global_options() object do we create a real mutex. We don't expect contention here because we take a reader-lock and the only time we Write is if someone flushes the cache.

void net_instaweb::RewriteOptions::SoftEnableFilterForTesting ( Filter  filter)

Induces a filter to be considered enabled by turning on the AllFilters level and disabling the filters that are not wanted. This is used for testing the desired behavior of PreserveUrls, which is to disable inlining and combining when the level is CoreFilters, but allow explictly enabled combiners and inliners to work.

Beware: this mode of enabling filters is difficult to manage across multiple levels of test inheritance. In particular, once SoftEnableFilterForTesting is called, EnableFilter will no longer work due to the explicit disables. It does work to call SoftEnableFilterForTesting multiple times to enable several filters, and it also works to call EnableFilter first. ForceEnable also works.

It is only necessary to call this in tests with PreserveUrls.

Caveat emptor.

virtual GoogleString net_instaweb::RewriteOptions::SubclassSignatureLockHeld ( )
inlinevirtual

If you subclass RewriteOptions and store any configuration data that's not an Option, use this hook to include the signature of your additional data.

Reimplemented in net_instaweb::ApacheConfig, and net_instaweb::SystemRewriteOptions.

bool net_instaweb::RewriteOptions::SupportSaveData ( ) const
inline

Returns true if PageSpeed responds differently for image requests with Save-Data header, i.e., using a unique quality and adding "Vary: Save-Data" header.

virtual GoogleString net_instaweb::RewriteOptions::ToExperimentDebugString ( ) const
virtual

Returns a string with more information about the currently running experiment. Primarily used for tagging Google Analytics data. This format is not at all specific to Google Analytics, however.

virtual GoogleString net_instaweb::RewriteOptions::ToExperimentString ( ) const
virtual

Returns a string identifying the currently running experiment to be used in tagging Google Analytics data.

bool net_instaweb::RewriteOptions::UpdateCacheInvalidationTimestampMs ( int64  timestamp_ms)

Sets the cache invalidation timestamp – in milliseconds since

  1. This function is meant to be called on a RewriteOptions* immediately after instantiation.

It can also be used to mutate the invalidation timestamp of a RewriteOptions instance that is used as a base for cloning/merging, in which case you should make sure to establish a real mutex with set_cache_invalidation_timestamp_mutex for such instances.

bool net_instaweb::RewriteOptions::UpdateCachePurgeSet ( const CopyOnWrite< PurgeSet > &  purge_set)

Mutates the options PurgeSet by copying the contents from purge_set. Returns true if the contents actually changed, false if the incoming purge_set was identical to purge_set already in this.

void net_instaweb::RewriteOptions::UrlValuedAttribute ( int  index,
StringPiece *  element,
StringPiece *  attribute,
semantic_type::Category *  category 
) const

Look up a url-valued attribute, return details via element, attribute, and category. index must be less than num_url_valued_attributes().

bool net_instaweb::RewriteOptions::UsePerOriginPropertyCachePage ( ) const

Returns true if any filter benefits from per-origin property cache information.

bool net_instaweb::RewriteOptions::ValidateAndAddResourceHeader ( const StringPiece &  name,
const StringPiece &  value,
GoogleString error_message 
)

If false was returned, no changes are made, and error_message will be assigned a failure description. If true was returned, the name/value passed validation and have been appended to resource_headers_. Multiple calls to ValidateAndAddResourceHeader with the same name will result in multiple headers being appended with the same name.

bool net_instaweb::RewriteOptions::ValidateConfiguredHttpHeader ( const GoogleString name,
const GoogleString value,
GoogleString error_message 
)

Returns true iff given name and value are valid to set as a http header. If false is returned, error_message will have a descriptive failure message set.

Member Data Documentation

const char net_instaweb::RewriteOptions::kAcceptInvalidSignatures[]
static

Any new Option added should have a corresponding name here that must be passed in when Add*Property is called in AddProperties(). You must also update the LookupOptionByNameTest method in rewrite_options_test.cc. If you add an image-related option or css-related option you must also add it to the kRelatedOptions array in image_rewrite_filter.cc and/or css_filter.cc.

const char net_instaweb::RewriteOptions::kCacheFlushFilename[]
static

apache/ or system/ specific:

Todo:
TODO(matterbury): move these to system_rewrite_options.cc?
const int64 net_instaweb::RewriteOptions::kDefaultExperimentCookieDurationMs
static

Default duration after which the experiment cookie will expire on the user's browser.

const int64 net_instaweb::RewriteOptions::kDefaultMaxImageSizeLowResolutionBytes
static

Default maximum image size below which low res image is generated by InlinePreviewImagesFilter.

const int net_instaweb::RewriteOptions::kDefaultMaxInlinedPreviewImagesIndex
static

Default number of first N images for which low res image is generated by DelayImagesFilter.

const int net_instaweb::RewriteOptions::kDefaultMaxUrlSegmentSize
static

See http://github.com/pagespeed/mod_pagespeed/issues/9 Apache evidently limits each URL path segment (between /) to about 256 characters. This is not fundamental URL limitation but is Apache specific.

const int net_instaweb::RewriteOptions::kDefaultMaxUrlSize
static

IE limits URL size overall to about 2k characters. See http://support.microsoft.com/kb/208427/EN-US

const int64 net_instaweb::RewriteOptions::kDefaultMetadataCacheStalenessThresholdMs
static

Default time in milliseconds for which a metadata cache entry may be used after expiry.

const int64 net_instaweb::RewriteOptions::kDefaultMinImageSizeLowResolutionBytes
static

Default minimum image size above which low res image is generated by InlinePreviewImagesFilter.

const char net_instaweb::RewriteOptions::kImageJpegNumProgressiveScans[]
static
Todo:
TODO(huibao): Unify terminology for image rewrites. For example, kImageJpeg*Quality might be renamed to kImageJpegQuality.
const int net_instaweb::RewriteOptions::kOptionsVersion = 14
static

This version index serves as global signature key. Much of the data emitted in signatures is based on the option ordering, which can change as we add new options. So every time there is a binary-incompatible change to the option ordering, we bump this version.

Note: we now use a two-letter code for identifying enabled filters, so there is no need bump the option version when changing the filter enum.

Updating this value will have the indirect effect of flushing the metadata cache. The HTTPCache can be flushed by updating kHttpCacheVersion in http_cache.cc.

This version number should be incremented if any default-values are changed, either in an Add*Property() call or via options->set_default.


The documentation for this class was generated from the following file: