Page Speed Optimization Libraries
1.7.30.2
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_ 00021 00022 #include <cstddef> 00023 #include <map> 00024 #include <set> 00025 #include <utility> 00026 #include <vector> 00027 00028 #include "base/logging.h" 00029 #include "net/instaweb/http/public/meta_data.h" 00030 #include "net/instaweb/http/public/semantic_type.h" 00031 #include "net/instaweb/rewriter/public/domain_lawyer.h" 00032 #include "net/instaweb/rewriter/public/file_load_policy.h" 00033 #include "net/instaweb/rewriter/public/javascript_library_identification.h" 00034 #include "net/instaweb/util/public/basictypes.h" 00035 #include "net/instaweb/util/public/enum_set.h" 00036 #include "net/instaweb/util/public/gtest_prod.h" 00037 #include "net/instaweb/util/public/md5_hasher.h" 00038 #include "net/instaweb/util/public/scoped_ptr.h" 00039 #include "net/instaweb/util/public/string.h" 00040 #include "net/instaweb/util/public/string_util.h" 00041 #include "net/instaweb/util/public/thread_system.h" 00042 #include "pagespeed/kernel/base/dense_hash_map.h" 00043 #include "pagespeed/kernel/base/fast_wildcard_group.h" 00044 #include "pagespeed/kernel/base/rde_hash_map.h" 00045 #include "pagespeed/kernel/base/string_hash.h" 00046 #include "pagespeed/kernel/base/wildcard.h" 00047 #include "pagespeed/kernel/util/copy_on_write.h" 00048 00049 namespace net_instaweb { 00050 00051 class Hasher; 00052 class MessageHandler; 00053 class RequestHeaders; 00054 00075 class RewriteOptions { 00076 private: 00081 class PropertyBase; 00082 template<class ValueType> class Property; 00083 template<class RewriteOptionsSubclass, class OptionClass> class PropertyLeaf; 00084 00085 public: 00098 enum Filter { 00099 kAddBaseTag, 00100 kAddHead, 00101 kAddInstrumentation, 00102 kComputeStatistics, 00103 kCachePartialHtml, 00104 kCanonicalizeJavascriptLibraries, 00105 kCollapseWhitespace, 00106 kCollectFlushEarlyContentFilter, 00107 kCombineCss, 00108 kCombineHeads, 00109 kCombineJavascript, 00110 kComputeCriticalCss, 00111 kComputeVisibleText, 00112 kConvertGifToPng, 00113 kConvertJpegToProgressive, 00114 kConvertJpegToWebp, 00115 kConvertMetaTags, 00116 kConvertPngToJpeg, 00117 kConvertToWebpLossless, 00118 kDebug, 00119 kDecodeRewrittenUrls, 00120 kDedupInlinedImages, 00121 kDeferIframe, 00122 kDeferJavascript, 00123 kDelayImages, 00124 kDeterministicJs, 00125 kDisableJavascript, 00126 kDivStructure, 00127 kElideAttributes, 00128 kExperimentSpdy, 00129 kExplicitCloseTags, 00130 kExtendCacheCss, 00131 kExtendCacheImages, 00132 kExtendCachePdfs, 00133 kExtendCacheScripts, 00134 kFallbackRewriteCssUrls, 00135 kFixReflows, 00136 kFlattenCssImports, 00137 kFlushSubresources, 00138 kHandleNoscriptRedirect, 00139 kHtmlWriterFilter, 00140 kInlineCss, 00141 kInlineGoogleFontCss, 00142 kInlineImages, 00143 kInlineImportToLink, 00144 kInlineJavascript, 00145 kInPlaceOptimizeForBrowser, 00146 kInsertDnsPrefetch, 00147 kInsertGA, 00148 kInsertImageDimensions, 00149 kJpegSubsampling, 00150 kLazyloadImages, 00151 kLeftTrimUrls, 00152 kLocalStorageCache, 00153 kMakeGoogleAnalyticsAsync, 00154 kMoveCssAboveScripts, 00155 kMoveCssToHead, 00156 kOutlineCss, 00157 kOutlineJavascript, 00158 kPedantic, 00159 kPrioritizeCriticalCss, 00160 kRecompressJpeg, 00161 kRecompressPng, 00162 kRecompressWebp, 00163 kRemoveComments, 00164 kRemoveQuotes, 00165 kResizeImages, 00166 kResizeMobileImages, 00167 kResizeToRenderedImageDimensions, 00168 kRewriteCss, 00169 kRewriteDomains, 00170 kRewriteJavascript, 00171 kRewriteStyleAttributes, 00172 kRewriteStyleAttributesWithUrl, 00173 kSplitHtml, 00174 kSplitHtmlHelper, 00175 kSpriteImages, 00176 kSquashImagesForMobileScreen, 00177 kStripImageColorProfile, 00178 kStripImageMetaData, 00179 kStripNonCacheable, 00180 kStripScripts, 00181 kEndOfFilters 00182 }; 00183 00184 enum EnabledEnum { 00187 kEnabledOff, 00189 kEnabledOn, 00192 kEnabledUnplugged, 00193 }; 00194 00201 static const char kAccessControlAllowOrigins[]; 00202 static const char kAddOptionsToUrls[]; 00203 static const char kAllowLoggingUrlsInLogRecord[]; 00204 static const char kAlwaysRewriteCss[]; 00205 static const char kAnalyticsID[]; 00206 static const char kAvoidRenamingIntrospectiveJavascript[]; 00207 static const char kAwaitPcacheLookup[]; 00208 static const char kBeaconReinstrumentTimeSec[]; 00209 static const char kBeaconUrl[]; 00210 static const char kBlinkMaxHtmlSizeRewritable[]; 00211 static const char kCacheInvalidationTimestamp[]; 00212 static const char kCacheSmallImagesUnrewritten[]; 00213 static const char kClientDomainRewrite[]; 00214 static const char kCombineAcrossPaths[]; 00215 static const char kCriticalImagesBeaconEnabled[]; 00216 static const char kCriticalLineConfig[]; 00217 static const char kCssFlattenMaxBytes[]; 00218 static const char kCssImageInlineMaxBytes[]; 00219 static const char kCssInlineMaxBytes[]; 00220 static const char kCssOutlineMinBytes[]; 00221 static const char kCssPreserveURLs[]; 00222 static const char kDefaultCacheHtml[]; 00223 static const char kDisableBackgroundFetchesForBots[]; 00224 static const char kDisableRewriteOnNoTransform[]; 00225 static const char kDistributeFetches[]; 00226 static const char kDistributedRewriteKey[]; 00227 static const char kDistributedRewriteServers[]; 00228 static const char kDistributedRewriteTimeoutMs[]; 00229 static const char kDomainRewriteHyperlinks[]; 00230 static const char kDomainShardCount[]; 00231 static const char kDownstreamCachePurgeMethod[]; 00232 static const char kDownstreamCacheRebeaconingKey[]; 00233 static const char kDownstreamCacheRewrittenPercentageThreshold[]; 00234 static const char kEnableAggressiveRewritersForMobile[]; 00235 static const char kEnableBlinkHtmlChangeDetection[]; 00236 static const char kEnableBlinkHtmlChangeDetectionLogging[]; 00237 static const char kEnableCachePurge[]; 00238 static const char kEnableDeferJsExperimental[]; 00239 static const char kEnableExtendedInstrumentation[]; 00240 static const char kEnableFlushEarlyCriticalCss[]; 00241 static const char kEnableLazyLoadHighResImages[]; 00242 static const char kEnablePrioritizingScripts[]; 00243 static const char kEnabled[]; 00244 static const char kExperimentCookieDurationMs[]; 00245 static const char kExperimentSlot[]; 00246 static const char kFetcherTimeOutMs[]; 00247 static const char kFinderPropertiesCacheExpirationTimeMs[]; 00248 static const char kFinderPropertiesCacheRefreshTimeMs[]; 00249 static const char kFlushBufferLimitBytes[]; 00250 static const char kFlushHtml[]; 00251 static const char kFlushMoreResourcesEarlyIfTimePermits[]; 00252 static const char kForbidAllDisabledFilters[]; 00253 static const char kHideRefererUsingMeta[]; 00254 static const char kIdleFlushTimeMs[]; 00255 static const char kImageInlineMaxBytes[]; 00256 static const char kImageJpegNumProgressiveScans[]; 00257 static const char kImageJpegNumProgressiveScansForSmallScreens[]; 00258 static const char kImageJpegRecompressionQuality[]; 00259 static const char kImageJpegRecompressionQualityForSmallScreens[]; 00260 static const char kImageLimitOptimizedPercent[]; 00261 static const char kImageLimitRenderedAreaPercent[]; 00262 static const char kImageLimitResizeAreaPercent[]; 00263 static const char kImageMaxRewritesAtOnce[]; 00264 static const char kImagePreserveURLs[]; 00265 static const char kImageRecompressionQuality[]; 00266 static const char kImageResolutionLimitBytes[]; 00267 static const char kImageWebpRecompressionQuality[]; 00268 static const char kImageWebpRecompressionQualityForSmallScreens[]; 00269 static const char kImageWebpTimeoutMs[]; 00270 static const char kImplicitCacheTtlMs[]; 00271 static const char kIncreaseSpeedTracking[]; 00272 static const char kInlineOnlyCriticalImages[]; 00273 static const char kInlineUnauthorizedResourcesExperimental[]; 00274 static const char kInPlacePreemptiveRewriteCss[]; 00275 static const char kInPlacePreemptiveRewriteCssImages[]; 00276 static const char kInPlacePreemptiveRewriteImages[]; 00277 static const char kInPlacePreemptiveRewriteJavascript[]; 00278 static const char kInPlaceResourceOptimization[]; 00279 static const char kInPlaceRewriteDeadlineMs[]; 00280 static const char kInPlaceWaitForOptimized[]; 00281 static const char kJsInlineMaxBytes[]; 00282 static const char kJsOutlineMinBytes[]; 00283 static const char kJsPreserveURLs[]; 00284 static const char kLazyloadImagesAfterOnload[]; 00285 static const char kLazyloadImagesBlankUrl[]; 00286 static const char kLogBackgroundRewrite[]; 00287 static const char kLogRewriteTiming[]; 00288 static const char kLogUrlIndices[]; 00289 static const char kLowercaseHtmlNames[]; 00290 static const char kMaxCacheableResponseContentLength[]; 00291 static const char kMaxCombinedCssBytes[]; 00292 static const char kMaxCombinedJsBytes[]; 00293 static const char kMaxHtmlCacheTimeMs[]; 00294 static const char kMaxHtmlParseBytes[]; 00295 static const char kMaxImageBytesForWebpInCss[]; 00296 static const char kMaxImageSizeLowResolutionBytes[]; 00297 static const char kMaxInlinedPreviewImagesIndex[]; 00298 static const char kMaxLowResImageSizeBytes[]; 00299 static const char kMaxLowResToHighResImageSizePercentage[]; 00300 static const char kMaxPrefetchJsElements[]; 00301 static const char kMaxRewriteInfoLogSize[]; 00302 static const char kMaxUrlSegmentSize[]; 00303 static const char kMaxUrlSize[]; 00304 static const char kMetadataCacheStalenessThresholdMs[]; 00305 static const char kMinCacheTtlMs[]; 00306 static const char kMinImageSizeLowResolutionBytes[]; 00307 static const char kMinResourceCacheTimeToRewriteMs[]; 00308 static const char kModifyCachingHeaders[]; 00309 static const char kNonCacheablesForCachePartialHtml[]; 00310 static const char kObliviousPagespeedUrls[]; 00311 static const char kOverrideCachingTtlMs[]; 00312 static const char kPersistBlinkBlacklist[]; 00313 static const char kPreserveUrlRelativity[]; 00314 static const char kProactivelyFreshenUserFacingRequest[]; 00315 static const char kProactiveResourceFreshening[]; 00316 static const char kProgressiveJpegMinBytes[]; 00317 static const char kRejectBlacklisted[]; 00318 static const char kRejectBlacklistedStatusCode[]; 00319 static const char kReportUnloadTime[]; 00320 static const char kRespectVary[]; 00321 static const char kRespectXForwardedProto[]; 00322 static const char kRewriteDeadlineMs[]; 00323 static const char kRewriteLevel[]; 00324 static const char kRewriteRandomDropPercentage[]; 00325 static const char kRewriteUncacheableResources[]; 00326 static const char kRunningExperiment[]; 00327 static const char kServeGhostClickBusterWithSplitHtml[]; 00328 static const char kServeSplitHtmlInTwoChunks[]; 00329 static const char kServeStaleIfFetchError[]; 00330 static const char kServeStaleWhileRevalidateThresholdSec[]; 00331 static const char kServeXhrAccessControlHeaders[]; 00332 static const char kSupportNoScriptEnabled[]; 00333 static const char kTestOnlyPrioritizeCriticalCssDontApplyOriginalCss[]; 00334 static const char kUseBlankImageForInlinePreview[]; 00335 static const char kUseFallbackPropertyCacheValues[]; 00336 static const char kUseImageScanlineApi[]; 00337 static const char kUseSelectorsForCriticalCss[]; 00338 static const char kUseSmartDiffInBlink[]; 00339 static const char kXModPagespeedHeaderValue[]; 00340 static const char kXPsaBlockingRewrite[]; 00342 static const char kAllow[]; 00343 static const char kBlockingRewriteRefererUrls[]; 00344 static const char kDisableFilters[]; 00345 static const char kDisallow[]; 00346 static const char kDistributableFilters[]; 00347 static const char kDomain[]; 00348 static const char kDownstreamCachePurgeLocationPrefix[]; 00349 static const char kEnableFilters[]; 00350 static const char kExperimentVariable[]; 00351 static const char kExperimentSpec[]; 00352 static const char kForbidFilters[]; 00353 static const char kRetainComment[]; 00355 static const char kCustomFetchHeader[]; 00356 static const char kLoadFromFile[]; 00357 static const char kLoadFromFileMatch[]; 00358 static const char kLoadFromFileRule[]; 00359 static const char kLoadFromFileRuleMatch[]; 00360 static const char kMapOriginDomain[]; 00361 static const char kMapProxyDomain[]; 00362 static const char kMapRewriteDomain[]; 00363 static const char kShardDomain[]; 00365 static const char kLibrary[]; 00366 static const char kUrlValuedAttribute[]; 00369 static const char kCacheFlushFilename[]; 00370 static const char kCacheFlushPollIntervalSec[]; 00371 static const char kCompressMetadataCache[]; 00372 static const char kFetcherProxy[]; 00373 static const char kFetchFromModSpdy[]; 00374 static const char kFetchHttps[]; 00375 static const char kFileCacheCleanInodeLimit[]; 00376 static const char kFileCacheCleanIntervalMs[]; 00377 static const char kFileCacheCleanSizeKb[]; 00378 static const char kFileCachePath[]; 00379 static const char kLogDir[]; 00380 static const char kLruCacheByteLimit[]; 00381 static const char kLruCacheKbPerProcess[]; 00382 static const char kMemcachedServers[]; 00383 static const char kMemcachedThreads[]; 00384 static const char kMemcachedTimeoutUs[]; 00385 static const char kRateLimitBackgroundFetches[]; 00386 static const char kServeWebpToAnyAgent[]; 00387 static const char kSlurpDirectory[]; 00388 static const char kSlurpFlushLimit[]; 00389 static const char kSlurpReadOnly[]; 00390 static const char kSslCertDirectory[]; 00391 static const char kSslCertFile[]; 00392 static const char kStatisticsEnabled[]; 00393 static const char kStatisticsHandlerPath[]; 00394 static const char kStatisticsLoggingChartsCSS[]; 00395 static const char kStatisticsLoggingChartsJS[]; 00396 static const char kStatisticsLoggingEnabled[]; 00397 static const char kStatisticsLoggingIntervalMs[]; 00398 static const char kStatisticsLoggingMaxFileSizeKb[]; 00399 static const char kTestProxy[]; 00400 static const char kTestProxySlurp[]; 00401 static const char kUseSharedMemLocking[]; 00403 static const char kNullOption[]; 00404 00412 struct BeaconUrl { 00413 GoogleString http; 00414 GoogleString https; 00415 GoogleString http_in; 00416 GoogleString https_in; 00417 }; 00418 00419 struct NameValue { 00420 NameValue(const StringPiece& name_in, const StringPiece& value_in) { 00421 name_in.CopyToString(&name); 00422 value_in.CopyToString(&value); 00423 } 00424 GoogleString name; 00425 GoogleString value; 00426 }; 00427 00443 static const int kOptionsVersion = 13; 00444 00446 static const int kHashBytes = 20; 00447 00452 enum OptionScope { 00453 kDirectoryScope, 00454 kServerScope, 00455 kProcessScope, 00456 kProcessScopeStrict, 00457 }; 00458 00459 static const char kCacheExtenderId[]; 00460 static const char kCollectFlushEarlyContentFilterId[]; 00461 static const char kCssCombinerId[]; 00462 static const char kCssFilterId[]; 00463 static const char kCssImportFlattenerId[]; 00464 static const char kCssInlineId[]; 00465 static const char kGoogleFontCssInlineId[]; 00466 static const char kImageCombineId[]; 00467 static const char kImageCompressionId[]; 00468 static const char kInPlaceRewriteId[]; 00469 static const char kJavascriptCombinerId[]; 00470 static const char kJavascriptInlineId[]; 00471 static const char kJavascriptMinId[]; 00472 static const char kLocalStorageCacheId[]; 00473 static const char kPrioritizeCriticalCssId[]; 00474 00475 static const char kPanelCommentPrefix[]; 00476 00479 static const char* FilterName(Filter filter); 00480 00483 static const char* FilterId(Filter filter); 00484 00487 static int NumFilterIds(); 00488 00490 static const Filter kFirstFilter = kAddBaseTag; 00491 00492 typedef EnumSet<Filter, kEndOfFilters> FilterSet; 00493 typedef std::vector<Filter> FilterVector; 00494 00496 typedef std::set<GoogleString> FilterIdSet; 00497 00503 static bool AddByNameToFilterSet(const StringPiece& option, FilterSet* set, 00504 MessageHandler* handler); 00505 00508 typedef std::pair<StringPiece, StringPiece> OptionStringPair; 00509 typedef std::set<OptionStringPair> OptionSet; 00510 00511 typedef std::vector<PropertyBase*> PropertyVector; 00512 00515 class OptionBase { 00516 public: 00517 OptionBase() {} 00518 virtual ~OptionBase(); 00519 00520 virtual bool SetFromString(StringPiece value_string) = 0; 00521 virtual void Merge(const OptionBase* src) = 0; 00522 virtual bool was_set() const = 0; 00523 virtual GoogleString Signature(const Hasher* hasher) const = 0; 00524 virtual GoogleString ToString() const = 0; 00525 const char* id() const { return property()->id(); } 00526 const char* help_text() const { return property()->help_text(); } 00527 OptionScope scope() const { return property()->scope(); } 00528 StringPiece option_name() const { return property()->option_name(); } 00529 bool is_used_for_signature_computation() const { 00530 return property()->is_used_for_signature_computation(); 00531 } 00532 virtual const PropertyBase* property() const = 0; 00533 }; 00534 00536 typedef std::vector<OptionBase*> OptionBaseVector; 00537 00538 enum RewriteLevel { 00543 kPassThrough, 00544 00548 kOptimizeForBandwidth, 00549 00555 kCoreFilters, 00556 00560 kTestingCoreFilters, 00561 00564 kAllFilters, 00565 }; 00566 00568 enum OptionSettingResult { 00569 kOptionOk, 00570 kOptionNameUnknown, 00571 kOptionValueInvalid 00572 }; 00573 00574 static const int kDefaultBeaconReinstrumentTimeSec; 00575 static const int64 kDefaultBlinkMaxHtmlSizeRewritable; 00576 static const int64 kDefaultCssFlattenMaxBytes; 00577 static const int64 kDefaultCssImageInlineMaxBytes; 00578 static const int64 kDefaultCssInlineMaxBytes; 00579 static const int64 kDefaultCssOutlineMinBytes; 00580 static const int64 kDefaultImageInlineMaxBytes; 00581 static const int64 kDefaultJsInlineMaxBytes; 00582 static const int64 kDefaultJsOutlineMinBytes; 00583 static const int64 kDefaultProgressiveJpegMinBytes; 00584 static const int64 kDefaultMaxCacheableResponseContentLength; 00585 static const int64 kDefaultMaxHtmlCacheTimeMs; 00586 static const int64 kDefaultMaxHtmlParseBytes; 00587 static const int64 kDefaultMaxImageBytesForWebpInCss; 00588 static const int64 kDefaultMaxLowResImageSizeBytes; 00589 static const int kDefaultMaxLowResToFullResImageSizePercentage; 00590 static const int64 kDefaultMetadataInputErrorsCacheTtlMs; 00591 static const int64 kDefaultMinResourceCacheTimeToRewriteMs; 00592 static const char kDefaultDownstreamCachePurgeMethod[]; 00593 static const int64 kDefaultDownstreamCacheRewrittenPercentageThreshold; 00594 static const int64 kDefaultCacheInvalidationTimestamp; 00595 static const int64 kDefaultIdleFlushTimeMs; 00596 static const int64 kDefaultFlushBufferLimitBytes; 00597 static const int64 kDefaultImplicitCacheTtlMs; 00598 static const int64 kDefaultMinCacheTtlMs; 00599 static const int64 kDefaultPrioritizeVisibleContentCacheTimeMs; 00600 static const char kDefaultBeaconUrl[]; 00601 static const int64 kDefaultImageRecompressQuality; 00602 static const int64 kDefaultImageJpegRecompressQuality; 00603 static const int64 kDefaultImageJpegRecompressQualityForSmallScreens; 00604 static const int kDefaultImageLimitOptimizedPercent; 00605 static const int kDefaultImageLimitRenderedAreaPercent; 00606 static const int kDefaultImageLimitResizeAreaPercent; 00607 static const int64 kDefaultImageResolutionLimitBytes; 00608 static const int64 kDefaultImageJpegNumProgressiveScans; 00609 static const int64 kDefaultImageWebpRecompressQuality; 00610 static const int64 kDefaultImageWebpRecompressQualityForSmallScreens; 00611 static const int64 kDefaultImageWebpTimeoutMs; 00612 static const int kDefaultDomainShardCount; 00613 static const int64 kDefaultBlinkHtmlChangeDetectionTimeMs; 00614 static const int kDefaultMaxPrefetchJsElements; 00615 00618 static const int kDefaultMaxUrlSize; 00619 00620 static const int kDefaultImageMaxRewritesAtOnce; 00621 00626 static const int kDefaultMaxUrlSegmentSize; 00627 00629 static const int kDefaultRewriteDeadlineMs; 00630 00632 static const int64 kDefaultDistributedTimeoutMs; 00633 00636 static const int kDefaultMaxInlinedPreviewImagesIndex; 00639 static const int64 kDefaultMinImageSizeLowResolutionBytes; 00642 static const int64 kDefaultMaxImageSizeLowResolutionBytes; 00644 static const int64 kDefaultFinderPropertiesCacheExpirationTimeMs; 00646 static const int64 kDefaultFinderPropertiesCacheRefreshTimeMs; 00647 00650 static const int64 kDefaultExperimentCookieDurationMs; 00651 00654 static const int64 kDefaultMetadataCacheStalenessThresholdMs; 00655 00657 static const int64 kDefaultMaxCombinedCssBytes; 00658 00660 static const int64 kDefaultMaxCombinedJsBytes; 00661 00662 static const int kDefaultExperimentTrafficPercent; 00664 static const int kDefaultExperimentSlot; 00665 00666 static const char kDefaultBlockingRewriteKey[]; 00667 00668 static const char kRejectedRequestUrlKeyName[]; 00669 00670 static const int kDefaultPropertyCacheHttpStatusStabilityThreshold; 00671 00672 static const int kDefaultMaxRewriteInfoLogSize; 00673 00681 class ExperimentSpec { 00682 public: 00687 ExperimentSpec(const StringPiece& spec, RewriteOptions* options, 00688 MessageHandler* handler); 00689 00693 explicit ExperimentSpec(int id); 00694 00695 virtual ~ExperimentSpec(); 00696 00698 virtual ExperimentSpec* Clone(); 00699 00700 bool is_valid() const { return id_ >= 0; } 00701 00703 int id() const { return id_; } 00704 int percent() const { return percent_; } 00705 GoogleString ga_id() const { return ga_id_; } 00706 int slot() const { return ga_variable_slot_; } 00707 RewriteLevel rewrite_level() const { return rewrite_level_; } 00708 FilterSet enabled_filters() const { return enabled_filters_; } 00709 FilterSet disabled_filters() const { return disabled_filters_; } 00710 OptionSet filter_options() const { return filter_options_; } 00711 int64 css_inline_max_bytes() const { return css_inline_max_bytes_; } 00712 int64 js_inline_max_bytes() const { return js_inline_max_bytes_; } 00713 int64 image_inline_max_bytes() const { return image_inline_max_bytes_; } 00714 bool use_default() const { return use_default_; } 00715 00716 protected: 00720 void Merge(const ExperimentSpec& spec); 00721 00722 private: 00723 FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest); 00724 00727 void Initialize(const StringPiece& spec, MessageHandler* handler); 00728 00729 int id_; 00730 GoogleString ga_id_; 00731 int ga_variable_slot_; 00732 int percent_; 00733 RewriteLevel rewrite_level_; 00734 FilterSet enabled_filters_; 00735 FilterSet disabled_filters_; 00736 OptionSet filter_options_; 00737 int64 css_inline_max_bytes_; 00738 int64 js_inline_max_bytes_; 00739 int64 image_inline_max_bytes_; 00742 bool use_default_; 00743 DISALLOW_COPY_AND_ASSIGN(ExperimentSpec); 00744 }; 00745 00747 struct ElementAttributeCategory { 00748 GoogleString element; 00749 GoogleString attribute; 00750 semantic_type::Category category; 00751 }; 00752 00759 class Properties { 00760 public: 00769 static bool Initialize(Properties** properties); 00770 00779 static bool Terminate(Properties** properties_handle); 00780 00782 int size() const { return property_vector_.size(); } 00783 00784 const PropertyBase* property(int index) const { 00785 return property_vector_[index]; 00786 } 00787 PropertyBase* property(int index) { return property_vector_[index]; } 00788 00794 void Merge(Properties* properties); 00795 00796 void push_back(PropertyBase* p) { property_vector_.push_back(p); } 00797 00798 private: 00801 Properties(); 00802 ~Properties(); 00803 00807 int initialization_count_; 00808 00813 bool owns_properties_; 00814 PropertyVector property_vector_; 00815 }; 00816 00818 struct FilterEnumToIdAndNameEntry { 00819 RewriteOptions::Filter filter_enum; 00820 const char* filter_id; 00821 const char* filter_name; 00822 }; 00823 00824 static bool ParseRewriteLevel(const StringPiece& in, RewriteLevel* out); 00825 00829 static bool ParseBeaconUrl(const StringPiece& in, BeaconUrl* out); 00830 00834 bool ImageOptimizationEnabled() const; 00835 00836 explicit RewriteOptions(ThreadSystem* thread_system); 00837 virtual ~RewriteOptions(); 00838 00842 static bool Initialize(); 00843 static bool Terminate(); 00844 00845 #ifndef NDEBUG 00846 00847 00848 00849 00850 00851 00852 bool ModificationOK() const; 00853 00860 bool MergeOK() const; 00861 #endif 00862 00867 void InitializeOptions(const Properties* properties); 00868 00869 bool modified() const { return modified_; } 00870 00876 void SetDefaultRewriteLevel(RewriteLevel level) { 00878 level_.set_default(level); 00879 } 00880 void SetRewriteLevel(RewriteLevel level) { 00881 set_option(level, &level_); 00882 } 00883 00885 void AddCustomFetchHeader(const StringPiece& name, const StringPiece& value); 00886 00887 const NameValue* custom_fetch_header(int i) const { 00888 return custom_fetch_headers_[i]; 00889 } 00890 00891 int num_custom_fetch_headers() const { 00892 return custom_fetch_headers_.size(); 00893 } 00894 00897 ExperimentSpec* GetExperimentSpec(int id) const; 00898 00902 bool AvailableExperimentId(int id); 00903 00906 virtual bool AddExperimentSpec(const StringPiece& spec, 00907 MessageHandler* handler); 00908 00916 virtual bool SetExperimentState(int id); 00917 00921 void SetExperimentStateStr(const StringPiece& experiment_index); 00922 00923 int experiment_id() const { return experiment_id_; } 00924 00925 int experiment_spec_id(int i) const { 00926 return experiment_specs_[i]->id(); 00927 } 00928 00933 GoogleString GetExperimentStateStr() const; 00934 00935 ExperimentSpec* experiment_spec(int i) const { 00936 return experiment_specs_[i]; 00937 } 00938 00939 int num_experiments() const { return experiment_specs_.size(); } 00940 00952 void AddUrlValuedAttribute(const StringPiece& element, 00953 const StringPiece& attribute, 00954 semantic_type::Category category); 00955 00958 void UrlValuedAttribute(int index, 00959 StringPiece* element, 00960 StringPiece* attribute, 00961 semantic_type::Category* category) const; 00962 00963 int num_url_valued_attributes() const { 00964 if (url_valued_attributes_ == NULL) { 00965 return 0; 00966 } else { 00967 return url_valued_attributes_->size(); 00968 } 00969 } 00970 00972 bool RegisterLibrary( 00973 uint64 bytes, StringPiece md5_hash, StringPiece canonical_url) { 00974 return WriteableJavascriptLibraryIdentification()->RegisterLibrary( 00975 bytes, md5_hash, canonical_url); 00976 } 00977 00980 const JavascriptLibraryIdentification* javascript_library_identification() 00981 const { 00982 if (Enabled(kCanonicalizeJavascriptLibraries)) { 00983 return javascript_library_identification_.get(); 00984 } else { 00985 return NULL; 00986 } 00987 } 00988 00989 RewriteLevel level() const { return level_.value(); } 00990 00995 bool AdjustFiltersByCommaSeparatedList(const StringPiece& filters, 00996 MessageHandler* handler); 00997 01001 bool EnableFiltersByCommaSeparatedList(const StringPiece& filters, 01002 MessageHandler* handler); 01003 01007 bool DisableFiltersByCommaSeparatedList(const StringPiece& filters, 01008 MessageHandler* handler); 01009 01013 bool ForbidFiltersByCommaSeparatedList(const StringPiece& filters, 01014 MessageHandler* handler); 01015 01017 void DisableAllFilters(); 01018 01026 void DisableAllFiltersNotExplicitlyEnabled(); 01027 01030 void DistributeFiltersByCommaSeparatedList(const StringPiece& filter_ids, 01031 MessageHandler* handler); 01034 void DistributeFilter(const StringPiece& filter_id); 01035 01038 bool Distributable(const StringPiece& filter_id) const; 01039 01043 void EnableFilter(Filter filter); 01046 void ForceEnableFilter(Filter filter); 01047 void DisableFilter(Filter filter); 01048 void DisableIfNotExplictlyEnabled(Filter filter); 01049 void ForbidFilter(Filter filter); 01050 void EnableFilters(const FilterSet& filter_set); 01051 void DisableFilters(const FilterSet& filter_set); 01052 void ForbidFilters(const FilterSet& filter_set); 01055 void ClearFilters(); 01056 01074 void SoftEnableFilterForTesting(Filter filter); 01075 01078 void EnableExtendCacheFilters(); 01079 01080 bool Enabled(Filter filter) const; 01081 bool Forbidden(Filter filter) const; 01082 bool Forbidden(StringPiece filter_id) const; 01083 01085 void GetEnabledFiltersRequiringScriptExecution(FilterVector* filters) const; 01086 01088 void DisableFiltersRequiringScriptExecution(); 01089 01094 static bool AddCommaSeparatedListToOptionSet( 01095 const StringPiece& options, OptionSet* set, MessageHandler* handler); 01096 01101 OptionSettingResult SetOptionFromName( 01102 StringPiece name, StringPiece value, GoogleString* msg); 01103 01108 virtual OptionSettingResult ParseAndSetOptionFromName1( 01109 StringPiece name, StringPiece arg, 01110 GoogleString* msg, MessageHandler* handler); 01111 01112 virtual OptionSettingResult ParseAndSetOptionFromName2( 01113 StringPiece name, StringPiece arg1, StringPiece arg2, 01114 GoogleString* msg, MessageHandler* handler); 01115 01116 virtual OptionSettingResult ParseAndSetOptionFromName3( 01117 StringPiece name, StringPiece arg1, StringPiece arg2, StringPiece arg3, 01118 GoogleString* msg, MessageHandler* handler); 01119 01124 OptionSettingResult SetOptionFromName(StringPiece name, StringPiece value); 01125 01131 bool OptionValue(StringPiece option_name, const char** id, 01132 bool* was_set, GoogleString* value) const; 01133 01136 bool SetOptionsFromName(const OptionSet& option_set); 01137 01140 bool SetOptionFromNameAndLog(StringPiece name, 01141 StringPiece value, 01142 MessageHandler* handler); 01143 01146 static bool ParseFromString(StringPiece value_string, bool* value); 01147 static bool ParseFromString(StringPiece value_string, EnabledEnum* value); 01148 static bool ParseFromString(StringPiece value_string, int* value) { 01149 return StringToInt(value_string, value); 01150 } 01151 static bool ParseFromString(StringPiece value_string, int64* value) { 01152 return StringToInt64(value_string, value); 01153 } 01154 static bool ParseFromString(StringPiece value_string, GoogleString* value) { 01155 value_string.CopyToString(value); 01156 return true; 01157 } 01158 static bool ParseFromString(StringPiece value_string, RewriteLevel* value) { 01159 return ParseRewriteLevel(value_string, value); 01160 } 01161 static bool ParseFromString(StringPiece value_string, BeaconUrl* value) { 01162 return ParseBeaconUrl(value_string, value); 01163 } 01164 01167 int64 css_outline_min_bytes() const { return css_outline_min_bytes_.value(); } 01168 void set_css_outline_min_bytes(int64 x) { 01169 set_option(x, &css_outline_min_bytes_); 01170 } 01171 01172 GoogleString ga_id() const { return ga_id_.value(); } 01173 void set_ga_id(GoogleString id) { 01174 set_option(id, &ga_id_); 01175 } 01176 01177 bool increase_speed_tracking() const { 01178 return increase_speed_tracking_.value(); 01179 } 01180 void set_increase_speed_tracking(bool x) { 01181 set_option(x, &increase_speed_tracking_); 01182 } 01183 01184 int64 js_outline_min_bytes() const { return js_outline_min_bytes_.value(); } 01185 void set_js_outline_min_bytes(int64 x) { 01186 set_option(x, &js_outline_min_bytes_); 01187 } 01188 01189 int64 progressive_jpeg_min_bytes() const { 01190 return progressive_jpeg_min_bytes_.value(); 01191 } 01192 void set_progressive_jpeg_min_bytes(int64 x) { 01193 set_option(x, &progressive_jpeg_min_bytes_); 01194 } 01195 01196 int64 css_flatten_max_bytes() const { return css_flatten_max_bytes_.value(); } 01197 void set_css_flatten_max_bytes(int64 x) { 01198 set_option(x, &css_flatten_max_bytes_); 01199 } 01200 bool cache_small_images_unrewritten() const { 01201 return cache_small_images_unrewritten_.value(); 01202 } 01203 void set_cache_small_images_unrewritten(bool x) { 01204 set_option(x, &cache_small_images_unrewritten_); 01205 } 01206 int64 image_resolution_limit_bytes() const { 01207 return image_resolution_limit_bytes_.value(); 01208 } 01209 void set_image_resolution_limit_bytes(int64 x) { 01210 set_option(x, &image_resolution_limit_bytes_); 01211 } 01212 01214 int64 ImageInlineMaxBytes() const; 01215 void set_image_inline_max_bytes(int64 x); 01217 int64 CssImageInlineMaxBytes() const; 01218 void set_css_image_inline_max_bytes(int64 x) { 01219 set_option(x, &css_image_inline_max_bytes_); 01220 } 01222 int64 MaxImageInlineMaxBytes() const; 01223 int64 css_inline_max_bytes() const { return css_inline_max_bytes_.value(); } 01224 void set_css_inline_max_bytes(int64 x) { 01225 set_option(x, &css_inline_max_bytes_); 01226 } 01227 int64 js_inline_max_bytes() const { return js_inline_max_bytes_.value(); } 01228 void set_js_inline_max_bytes(int64 x) { 01229 set_option(x, &js_inline_max_bytes_); 01230 } 01231 int64 max_html_cache_time_ms() const { 01232 return max_html_cache_time_ms_.value(); 01233 } 01234 void set_max_html_cache_time_ms(int64 x) { 01235 set_option(x, &max_html_cache_time_ms_); 01236 } 01237 int64 max_html_parse_bytes() const { 01238 return max_html_parse_bytes_.value(); 01239 } 01240 void set_max_html_parse_bytes(int64 x) { 01241 set_option(x, &max_html_parse_bytes_); 01242 } 01243 int64 max_image_bytes_for_webp_in_css() const { 01244 return max_image_bytes_for_webp_in_css_.value(); 01245 } 01246 void set_max_image_bytes_for_webp_in_css(int64 x) { 01247 set_option(x, &max_image_bytes_for_webp_in_css_); 01248 } 01249 int64 max_cacheable_response_content_length() const { 01250 return max_cacheable_response_content_length_.value(); 01251 } 01252 void set_max_cacheable_response_content_length(int64 x) { 01253 set_option(x, &max_cacheable_response_content_length_); 01254 } 01255 int64 min_resource_cache_time_to_rewrite_ms() const { 01256 return min_resource_cache_time_to_rewrite_ms_.value(); 01257 } 01258 void set_min_resource_cache_time_to_rewrite_ms(int64 x) { 01259 set_option(x, &min_resource_cache_time_to_rewrite_ms_); 01260 } 01261 bool need_to_store_experiment_data() const { 01262 return need_to_store_experiment_data_; 01263 } 01264 void set_need_to_store_experiment_data(bool x) { 01265 need_to_store_experiment_data_ = x; 01266 } 01267 01268 int64 blocking_fetch_timeout_ms() const { 01269 return blocking_fetch_timeout_ms_.value(); 01270 } 01271 void set_blocking_fetch_timeout_ms(int64 x) { 01272 set_option(x, &blocking_fetch_timeout_ms_); 01273 } 01274 bool override_ie_document_mode() const { 01275 return override_ie_document_mode_.value(); 01276 } 01277 void set_override_ie_document_mode(bool x) { 01278 set_option(x, &override_ie_document_mode_); 01279 } 01280 01281 int64 blink_blacklist_end_timestamp_ms() const { 01282 return blink_blacklist_end_timestamp_ms_.value(); 01283 } 01284 void set_blink_blacklist_end_timestamp_ms(int64 x) { 01285 set_option(x, &blink_blacklist_end_timestamp_ms_); 01286 } 01287 01288 bool persist_blink_blacklist() const { 01289 return persist_blink_blacklist_.value(); 01290 } 01291 void set_persist_blink_blacklist(bool x) { 01292 set_option(x, &persist_blink_blacklist_); 01293 } 01294 01295 bool preserve_url_relativity() const { 01296 return preserve_url_relativity_.value(); 01297 } 01298 void set_preserve_url_relativity(bool x) { 01299 set_option(x, &preserve_url_relativity_); 01300 } 01301 01309 bool IsUrlCacheValid(StringPiece url, int64 time_ms) const; 01310 01314 bool IsUrlPurged(StringPiece url, int64 time_ms) const; 01315 01332 void AddUrlCacheInvalidationEntry(StringPiece url_pattern, 01333 int64 timestamp_ms, 01334 bool ignores_metadata_and_pcache); 01335 01337 void PurgeUrl(StringPiece url, int64 timestamp_ms); 01338 01341 bool IsUrlCacheInvalidationEntriesSorted() const; 01342 01345 void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock* lock) { 01346 cache_invalidation_timestamp_.set_mutex(lock); 01347 } 01348 01350 int64 cache_invalidation_timestamp() const { 01351 ThreadSystem::ScopedReader lock(cache_invalidation_timestamp_.mutex()); 01352 return cache_invalidation_timestamp_.value(); 01353 } 01354 01361 void set_cache_invalidation_timestamp(int64 timestamp_ms) { 01362 cache_invalidation_timestamp_.mutex()->DCheckLocked(); 01363 DCHECK_LT(0, timestamp_ms); 01364 set_option(timestamp_ms, &cache_invalidation_timestamp_); 01365 } 01366 01373 bool UpdateCacheInvalidationTimestampMs(int64 timestamp_ms); 01374 01377 int64 idle_flush_time_ms() const { 01378 return idle_flush_time_ms_.value(); 01379 } 01380 void set_idle_flush_time_ms(int64 x) { 01381 set_option(x, &idle_flush_time_ms_); 01382 } 01383 01385 int64 flush_buffer_limit_bytes() const { 01386 return flush_buffer_limit_bytes_.value(); 01387 } 01388 01389 void set_flush_buffer_limit_bytes(int64 x) { 01390 set_option(x, &flush_buffer_limit_bytes_); 01391 } 01392 01395 int max_url_segment_size() const { return max_url_segment_size_.value(); } 01396 void set_max_url_segment_size(int x) { 01397 set_option(x, &max_url_segment_size_); 01398 } 01399 01400 int image_max_rewrites_at_once() const { 01401 return image_max_rewrites_at_once_.value(); 01402 } 01403 void set_image_max_rewrites_at_once(int x) { 01404 set_option(x, &image_max_rewrites_at_once_); 01405 } 01406 01408 int max_url_size() const { return max_url_size_.value(); } 01409 void set_max_url_size(int x) { 01410 set_option(x, &max_url_size_); 01411 } 01412 01413 int rewrite_deadline_ms() const { return rewrite_deadline_ms_.value(); } 01414 void set_rewrite_deadline_ms(int x) { 01415 set_option(x, &rewrite_deadline_ms_); 01416 } 01417 01418 bool test_instant_fetch_rewrite_deadline() const { 01419 return test_instant_fetch_rewrite_deadline_.value(); 01420 } 01421 void set_test_instant_fetch_rewrite_deadline(bool x) { 01422 set_option(x, &test_instant_fetch_rewrite_deadline_); 01423 } 01424 01425 void set_test_only_prioritize_critical_css_dont_apply_original_css(bool x) { 01426 set_option(x, &test_only_prioritize_critical_css_dont_apply_original_css_); 01427 } 01428 bool test_only_prioritize_critical_css_dont_apply_original_css() const { 01429 return test_only_prioritize_critical_css_dont_apply_original_css_.value(); 01430 } 01431 01432 int domain_shard_count() const { return domain_shard_count_.value(); } 01435 void set_domain_shard_count(int64 x) { 01436 int value = x; 01437 set_option(value, &domain_shard_count_); 01438 } 01439 01440 void set_enabled(EnabledEnum x) { 01441 set_option(x, &enabled_); 01442 } 01443 bool enabled() const { 01444 return enabled_.value() == kEnabledOn; 01445 } 01446 bool unplugged() const { 01447 return enabled_.value() == kEnabledUnplugged; 01448 } 01449 01450 void set_add_options_to_urls(bool x) { 01451 set_option(x, &add_options_to_urls_); 01452 } 01453 01454 bool add_options_to_urls() const { 01455 return add_options_to_urls_.value(); 01456 } 01457 01458 void set_in_place_rewriting_enabled(bool x) { 01459 set_option(x, &in_place_rewriting_enabled_); 01460 } 01461 01462 void set_oblivious_pagespeed_urls(bool x) { 01463 set_option(x, &oblivious_pagespeed_urls_); 01464 } 01465 01466 bool oblivious_pagespeed_urls() const { 01467 return oblivious_pagespeed_urls_.value(); 01468 } 01469 01470 bool in_place_rewriting_enabled() const { 01471 return CheckBandwidthOption(in_place_rewriting_enabled_); 01472 } 01473 01474 void set_in_place_wait_for_optimized(bool x) { 01475 set_option(x, &in_place_wait_for_optimized_); 01476 } 01477 01478 bool in_place_wait_for_optimized() const { 01479 return in_place_wait_for_optimized_.value(); 01480 } 01481 01482 void set_in_place_rewrite_deadline_ms(int x) { 01483 set_option(x, &in_place_rewrite_deadline_ms_); 01484 } 01485 01486 int in_place_rewrite_deadline_ms() const { 01487 return in_place_rewrite_deadline_ms_.value(); 01488 } 01489 01490 void set_in_place_preemptive_rewrite_css(bool x) { 01491 set_option(x, &in_place_preemptive_rewrite_css_); 01492 } 01493 bool in_place_preemptive_rewrite_css() const { 01494 return CheckBandwidthOption(in_place_preemptive_rewrite_css_); 01495 } 01496 01497 void set_in_place_preemptive_rewrite_css_images(bool x) { 01498 set_option(x, &in_place_preemptive_rewrite_css_images_); 01499 } 01500 bool in_place_preemptive_rewrite_css_images() const { 01501 return CheckBandwidthOption(in_place_preemptive_rewrite_css_images_); 01502 } 01503 01504 void set_in_place_preemptive_rewrite_images(bool x) { 01505 set_option(x, &in_place_preemptive_rewrite_images_); 01506 } 01507 bool in_place_preemptive_rewrite_images() const { 01508 return CheckBandwidthOption(in_place_preemptive_rewrite_images_); 01509 } 01510 01511 void set_in_place_preemptive_rewrite_javascript(bool x) { 01512 set_option(x, &in_place_preemptive_rewrite_javascript_); 01513 } 01514 bool in_place_preemptive_rewrite_javascript() const { 01515 return CheckBandwidthOption(in_place_preemptive_rewrite_javascript_); 01516 } 01517 01518 void set_combine_across_paths(bool x) { 01519 set_option(x, &combine_across_paths_); 01520 } 01521 bool combine_across_paths() const { return combine_across_paths_.value(); } 01522 01523 void set_log_background_rewrites(bool x) { 01524 set_option(x, &log_background_rewrites_); 01525 } 01526 bool log_background_rewrites() const { 01527 return log_background_rewrites_.value(); 01528 } 01529 01530 void set_log_rewrite_timing(bool x) { 01531 set_option(x, &log_rewrite_timing_); 01532 } 01533 bool log_rewrite_timing() const { return log_rewrite_timing_.value(); } 01534 01535 void set_log_url_indices(bool x) { 01536 set_option(x, &log_url_indices_); 01537 } 01538 bool log_url_indices() const { return log_url_indices_.value(); } 01539 01540 void set_lowercase_html_names(bool x) { 01541 set_option(x, &lowercase_html_names_); 01542 } 01543 bool lowercase_html_names() const { return lowercase_html_names_.value(); } 01544 01545 void set_always_rewrite_css(bool x) { 01546 set_option(x, &always_rewrite_css_); 01547 } 01548 bool always_rewrite_css() const { return always_rewrite_css_.value(); } 01549 01550 void set_respect_vary(bool x) { 01551 set_option(x, &respect_vary_); 01552 } 01553 bool respect_vary() const { return respect_vary_.value(); } 01554 01555 void set_respect_x_forwarded_proto(bool x) { 01556 set_option(x, &respect_x_forwarded_proto_); 01557 } 01558 bool respect_x_forwarded_proto() const { 01559 return respect_x_forwarded_proto_.value(); 01560 } 01561 01562 void set_flush_html(bool x) { set_option(x, &flush_html_); } 01563 bool flush_html() const { return flush_html_.value(); } 01564 01565 void set_serve_split_html_in_two_chunks(bool x) { 01566 set_option(x, &serve_split_html_in_two_chunks_); 01567 } 01568 bool serve_split_html_in_two_chunks() const { 01569 return serve_split_html_in_two_chunks_.value(); 01570 } 01571 01572 void set_serve_stale_if_fetch_error(bool x) { 01573 set_option(x, &serve_stale_if_fetch_error_); 01574 } 01575 bool serve_stale_if_fetch_error() const { 01576 return serve_stale_if_fetch_error_.value(); 01577 } 01578 01579 void set_serve_ghost_click_buster_with_split_html(bool x) { 01580 set_option(x, &serve_ghost_click_buster_with_split_html_); 01581 } 01582 bool serve_ghost_click_buster_with_split_html() const { 01583 return serve_ghost_click_buster_with_split_html_.value(); 01584 } 01585 01586 void set_serve_xhr_access_control_headers(bool x) { 01587 set_option(x, &serve_xhr_access_control_headers_); 01588 } 01589 bool serve_xhr_access_control_headers() const { 01590 return serve_xhr_access_control_headers_.value(); 01591 } 01592 01593 void set_proactively_freshen_user_facing_request(bool x) { 01594 set_option(x, &proactively_freshen_user_facing_request_); 01595 } 01596 bool proactively_freshen_user_facing_request() const { 01597 return proactively_freshen_user_facing_request_.value(); 01598 } 01599 01600 void set_serve_stale_while_revalidate_threshold_sec(int64 x) { 01601 set_option(x, &serve_stale_while_revalidate_threshold_sec_); 01602 } 01603 int64 serve_stale_while_revalidate_threshold_sec() const { 01604 return serve_stale_while_revalidate_threshold_sec_.value(); 01605 } 01606 01607 void set_enable_flush_early_critical_css(bool x) { 01608 set_option(x, &enable_flush_early_critical_css_); 01609 } 01610 bool enable_flush_early_critical_css() const { 01611 return enable_flush_early_critical_css_.value(); 01612 } 01613 01614 void set_use_selectors_for_critical_css(bool x) { 01615 set_option(x, &use_selectors_for_critical_css_); 01616 } 01617 bool use_selectors_for_critical_css() const { 01618 return use_selectors_for_critical_css_.value(); 01619 } 01620 01621 void set_default_cache_html(bool x) { set_option(x, &default_cache_html_); } 01622 bool default_cache_html() const { return default_cache_html_.value(); } 01623 01624 void set_modify_caching_headers(bool x) { 01625 set_option(x, &modify_caching_headers_); 01626 } 01627 bool modify_caching_headers() const { 01628 return modify_caching_headers_.value(); 01629 } 01630 01631 void set_inline_only_critical_images(bool x) { 01632 set_option(x, &inline_only_critical_images_); 01633 } 01634 bool inline_only_critical_images() const { 01635 return inline_only_critical_images_.value(); 01636 } 01637 01638 void set_inline_unauthorized_resources(bool x) { 01639 set_option(x, &inline_unauthorized_resources_); 01640 } 01641 bool inline_unauthorized_resources() const { 01642 return inline_unauthorized_resources_.value(); 01643 } 01644 01645 void set_critical_images_beacon_enabled(bool x) { 01646 set_option(x, &critical_images_beacon_enabled_); 01647 } 01648 bool critical_images_beacon_enabled() const { 01649 return critical_images_beacon_enabled_.value(); 01650 } 01651 01652 void set_beacon_reinstrument_beacon_time_sec(int x) { 01653 set_option(x, &beacon_reinstrument_time_sec_); 01654 } 01655 int beacon_reinstrument_time_sec() const { 01656 return beacon_reinstrument_time_sec_.value(); 01657 } 01658 01659 void set_lazyload_images_after_onload(bool x) { 01660 set_option(x, &lazyload_images_after_onload_); 01661 } 01662 bool lazyload_images_after_onload() const { 01663 return lazyload_images_after_onload_.value(); 01664 } 01665 01666 void set_lazyload_images_blank_url(const StringPiece& p) { 01667 set_option(GoogleString(p.data(), p.size()), &lazyload_images_blank_url_); 01668 } 01669 const GoogleString& lazyload_images_blank_url() const { 01670 return lazyload_images_blank_url_.value(); 01671 } 01672 01673 void set_max_inlined_preview_images_index(int x) { 01674 set_option(x, &max_inlined_preview_images_index_); 01675 } 01676 int max_inlined_preview_images_index() const { 01677 return max_inlined_preview_images_index_.value(); 01678 } 01679 01680 void set_use_blank_image_for_inline_preview(bool x) { 01681 set_option(x, &use_blank_image_for_inline_preview_); 01682 } 01683 bool use_blank_image_for_inline_preview() const { 01684 return use_blank_image_for_inline_preview_.value(); 01685 } 01686 01687 void set_min_image_size_low_resolution_bytes(int64 x) { 01688 set_option(x, &min_image_size_low_resolution_bytes_); 01689 } 01690 int64 min_image_size_low_resolution_bytes() const { 01691 return min_image_size_low_resolution_bytes_.value(); 01692 } 01693 01694 void set_max_image_size_low_resolution_bytes(int64 x) { 01695 set_option(x, &max_image_size_low_resolution_bytes_); 01696 } 01697 int64 max_image_size_low_resolution_bytes() const { 01698 return max_image_size_low_resolution_bytes_.value(); 01699 } 01700 01701 void set_experiment_cookie_duration_ms(int64 x) { 01702 set_option(x, &experiment_cookie_duration_ms_); 01703 } 01704 int64 experiment_cookie_duration_ms() const { 01705 return experiment_cookie_duration_ms_.value(); 01706 } 01707 01708 void set_finder_properties_cache_expiration_time_ms(int64 x) { 01709 set_option(x, &finder_properties_cache_expiration_time_ms_); 01710 } 01711 int64 finder_properties_cache_expiration_time_ms() const { 01712 return finder_properties_cache_expiration_time_ms_.value(); 01713 } 01714 01715 void set_finder_properties_cache_refresh_time_ms(int64 x) { 01716 set_option(x, &finder_properties_cache_refresh_time_ms_); 01717 } 01718 int64 finder_properties_cache_refresh_time_ms() const { 01719 return finder_properties_cache_refresh_time_ms_.value(); 01720 } 01721 01722 void set_rewrite_random_drop_percentage(int x) { 01723 set_option(x, &rewrite_random_drop_percentage_); 01724 } 01725 int rewrite_random_drop_percentage() const { 01726 return rewrite_random_drop_percentage_.value(); 01727 } 01728 01729 bool css_preserve_urls() const { 01730 return CheckBandwidthOption(css_preserve_urls_); 01731 } 01732 void set_css_preserve_urls(bool x) { 01733 set_option(x, &css_preserve_urls_); 01734 } 01735 01736 bool image_preserve_urls() const { 01737 return CheckBandwidthOption(image_preserve_urls_); 01738 } 01739 void set_image_preserve_urls(bool x) { 01740 set_option(x, &image_preserve_urls_); 01741 } 01742 01743 bool js_preserve_urls() const { 01744 return CheckBandwidthOption(js_preserve_urls_); 01745 } 01746 void set_js_preserve_urls(bool x) { 01747 set_option(x, &js_preserve_urls_); 01748 } 01749 01750 void set_metadata_cache_staleness_threshold_ms(int64 x) { 01751 set_option(x, &metadata_cache_staleness_threshold_ms_); 01752 } 01753 int64 metadata_cache_staleness_threshold_ms() const { 01754 return metadata_cache_staleness_threshold_ms_.value(); 01755 } 01756 01757 void set_metadata_input_errors_cache_ttl_ms(int64 x) { 01758 set_option(x, &metadata_input_errors_cache_ttl_ms_); 01759 } 01760 int64 metadata_input_errors_cache_ttl_ms() const { 01761 return metadata_input_errors_cache_ttl_ms_.value(); 01762 } 01763 01764 const GoogleString& downstream_cache_purge_method() const { 01765 return downstream_cache_purge_method_.value(); 01766 } 01767 void set_downstream_cache_purge_method(const StringPiece& p) { 01768 set_option(p.as_string(), &downstream_cache_purge_method_); 01769 } 01770 01771 const GoogleString& downstream_cache_purge_location_prefix() const { 01772 return downstream_cache_purge_location_prefix_.value(); 01773 } 01774 void set_downstream_cache_purge_location_prefix(const StringPiece& p) { 01775 set_option(p.as_string(), &downstream_cache_purge_location_prefix_); 01776 } 01777 bool downstream_cache_integration_enabled() const { 01778 return !downstream_cache_purge_location_prefix().empty(); 01779 } 01780 01781 void set_downstream_cache_rebeaconing_key(const StringPiece& p) { 01782 set_option(p.as_string(), &downstream_cache_rebeaconing_key_); 01783 } 01784 const GoogleString& downstream_cache_rebeaconing_key() const { 01785 return downstream_cache_rebeaconing_key_.value(); 01786 } 01787 01788 void set_downstream_cache_rewritten_percentage_threshold(int64 x) { 01789 set_option(x, &downstream_cache_rewritten_percentage_threshold_); 01790 } 01791 int64 downstream_cache_rewritten_percentage_threshold() const { 01792 return downstream_cache_rewritten_percentage_threshold_.value(); 01793 } 01794 01795 const BeaconUrl& beacon_url() const { return beacon_url_.value(); } 01796 void set_beacon_url(const GoogleString& beacon_url) { 01797 beacon_url_.SetFromString(beacon_url); 01798 } 01799 01801 virtual bool trim_urls_in_css() const { return true; } 01802 01803 int64 image_jpeg_recompress_quality() const { 01804 return image_jpeg_recompress_quality_.value(); 01805 } 01806 void set_image_jpeg_recompress_quality(int64 x) { 01807 set_option(x, &image_jpeg_recompress_quality_); 01808 } 01809 01810 int64 image_jpeg_recompress_quality_for_small_screens() const { 01811 return image_jpeg_recompress_quality_for_small_screens_.value(); 01812 } 01813 void set_image_jpeg_recompress_quality_for_small_screens(int64 x) { 01814 set_option(x, &image_jpeg_recompress_quality_for_small_screens_); 01815 } 01816 01817 int64 image_recompress_quality() const { 01818 return image_recompress_quality_.value(); 01819 } 01820 void set_image_recompress_quality(int64 x) { 01821 set_option(x, &image_recompress_quality_); 01822 } 01823 01824 int image_limit_optimized_percent() const { 01825 return image_limit_optimized_percent_.value(); 01826 } 01827 void set_image_limit_optimized_percent(int x) { 01828 set_option(x, &image_limit_optimized_percent_); 01829 } 01830 int image_limit_resize_area_percent() const { 01831 return image_limit_resize_area_percent_.value(); 01832 } 01833 void set_image_limit_resize_area_percent(int x) { 01834 set_option(x, &image_limit_resize_area_percent_); 01835 } 01836 01837 int image_limit_rendered_area_percent() const { 01838 return image_limit_rendered_area_percent_.value(); 01839 } 01840 void set_image_limit_rendered_area_percent(int x) { 01841 set_option(x, &image_limit_rendered_area_percent_); 01842 } 01843 01844 int64 image_jpeg_num_progressive_scans() const { 01845 return image_jpeg_num_progressive_scans_.value(); 01846 } 01847 void set_image_jpeg_num_progressive_scans(int64 x) { 01848 set_option(x, &image_jpeg_num_progressive_scans_); 01849 } 01850 01851 int64 image_jpeg_num_progressive_scans_for_small_screens() const { 01852 return image_jpeg_num_progressive_scans_for_small_screens_.value(); 01853 } 01854 void set_image_jpeg_num_progressive_scans_for_small_screens(int64 x) { 01855 set_option(x, &image_jpeg_num_progressive_scans_for_small_screens_); 01856 } 01857 01858 int64 image_webp_recompress_quality() const { 01859 return image_webp_recompress_quality_.value(); 01860 } 01861 void set_image_webp_recompress_quality(int64 x) { 01862 set_option(x, &image_webp_recompress_quality_); 01863 } 01864 01865 int64 image_webp_recompress_quality_for_small_screens() const { 01866 return image_webp_recompress_quality_for_small_screens_.value(); 01867 } 01868 void set_image_webp_recompress_quality_for_small_screens(int64 x) { 01869 set_option(x, &image_webp_recompress_quality_for_small_screens_); 01870 } 01871 int64 image_webp_timeout_ms() const { 01872 return image_webp_timeout_ms_.value(); 01873 } 01874 void set_image_webp_timeout_ms(int64 x) { 01875 set_option(x, &image_webp_timeout_ms_); 01876 } 01877 01878 bool domain_rewrite_hyperlinks() const { 01879 return domain_rewrite_hyperlinks_.value(); 01880 } 01881 void set_domain_rewrite_hyperlinks(bool x) { 01882 set_option(x, &domain_rewrite_hyperlinks_); 01883 } 01884 01885 bool client_domain_rewrite() const { 01886 return client_domain_rewrite_.value(); 01887 } 01888 void set_client_domain_rewrite(bool x) { 01889 set_option(x, &client_domain_rewrite_); 01890 } 01891 01892 void set_flush_more_resources_early_if_time_permits(bool x) { 01893 set_option(x, &flush_more_resources_early_if_time_permits_); 01894 } 01895 bool flush_more_resources_early_if_time_permits() const { 01896 return flush_more_resources_early_if_time_permits_.value(); 01897 } 01898 01899 void set_flush_more_resources_in_ie_and_firefox(bool x) { 01900 set_option(x, &flush_more_resources_in_ie_and_firefox_); 01901 } 01902 bool flush_more_resources_in_ie_and_firefox() const { 01903 return flush_more_resources_in_ie_and_firefox_.value(); 01904 } 01905 01906 void set_max_prefetch_js_elements(int x) { 01907 set_option(x, &max_prefetch_js_elements_); 01908 } 01909 int max_prefetch_js_elements() const { 01910 return max_prefetch_js_elements_.value(); 01911 } 01912 01913 void set_enable_defer_js_experimental(bool x) { 01914 set_option(x, &enable_defer_js_experimental_); 01915 } 01916 bool enable_defer_js_experimental() const { 01917 return enable_defer_js_experimental_.value(); 01918 } 01919 01920 void set_disable_rewrite_on_no_transform(bool x) { 01921 set_option(x, &disable_rewrite_on_no_transform_); 01922 } 01923 bool disable_rewrite_on_no_transform() const { 01924 return disable_rewrite_on_no_transform_.value(); 01925 } 01926 01927 void set_disable_background_fetches_for_bots(bool x) { 01928 set_option(x, &disable_background_fetches_for_bots_); 01929 } 01930 bool disable_background_fetches_for_bots() const { 01931 return disable_background_fetches_for_bots_.value(); 01932 } 01933 01934 void set_enable_cache_purge(bool x) { 01935 set_option(x, &enable_cache_purge_); 01936 } 01937 bool enable_cache_purge() const { 01938 return enable_cache_purge_.value(); 01939 } 01940 01941 void set_proactive_resource_freshening(bool x) { 01942 set_option(x, &proactive_resource_freshening_); 01943 } 01944 bool proactive_resource_freshening() const { 01945 return proactive_resource_freshening_.value(); 01946 } 01947 01948 void set_lazyload_highres_images(bool x) { 01949 set_option(x, &lazyload_highres_images_); 01950 } 01951 bool lazyload_highres_images() const { 01952 return lazyload_highres_images_.value(); 01953 } 01954 01955 void set_enable_blink_debug_dashboard(bool x) { 01956 set_option(x, &enable_blink_debug_dashboard_); 01957 } 01958 bool enable_blink_debug_dashboard() const { 01959 return enable_blink_debug_dashboard_.value(); 01960 } 01961 01962 void set_enable_blink_html_change_detection(bool x) { 01963 set_option(x, &enable_blink_html_change_detection_); 01964 } 01965 bool enable_blink_html_change_detection() const { 01966 return enable_blink_html_change_detection_.value(); 01967 } 01968 01969 void set_enable_blink_html_change_detection_logging(bool x) { 01970 set_option(x, &enable_blink_html_change_detection_logging_); 01971 } 01972 bool enable_blink_html_change_detection_logging() const { 01973 return enable_blink_html_change_detection_logging_.value(); 01974 } 01975 01976 void set_use_smart_diff_in_blink(bool x) { 01977 set_option(x, &use_smart_diff_in_blink_); 01978 } 01979 bool use_smart_diff_in_blink() const { 01980 return use_smart_diff_in_blink_.value(); 01981 } 01982 01983 void set_use_fallback_property_cache_values(bool x) { 01984 set_option(x, &use_fallback_property_cache_values_); 01985 } 01986 bool use_fallback_property_cache_values() const { 01987 return use_fallback_property_cache_values_.value(); 01988 } 01989 01990 void set_await_pcache_lookup(bool x) { 01991 set_option(x, &await_pcache_lookup_); 01992 } 01993 bool await_pcache_lookup() const { 01994 return await_pcache_lookup_.value(); 01995 } 01996 01997 void set_enable_prioritizing_scripts(bool x) { 01998 set_option(x, &enable_prioritizing_scripts_); 01999 } 02000 bool enable_prioritizing_scripts() const { 02001 return enable_prioritizing_scripts_.value(); 02002 } 02003 02004 void set_blink_html_change_detection_time_ms(int64 x) { 02005 set_option(x, &blink_html_change_detection_time_ms_); 02006 } 02007 int64 blink_html_change_detection_time_ms() const { 02008 return blink_html_change_detection_time_ms_.value(); 02009 } 02010 02011 const GoogleString& blocking_rewrite_key() const { 02012 return blocking_rewrite_key_.value(); 02013 } 02014 void set_blocking_rewrite_key(const StringPiece& p) { 02015 set_option(p.as_string(), &blocking_rewrite_key_); 02016 } 02017 02018 void EnableBlockingRewriteForRefererUrlPattern( 02019 const StringPiece& url_pattern) { 02020 Modify(); 02021 blocking_rewrite_referer_urls_.Allow(url_pattern); 02022 } 02023 02024 bool IsBlockingRewriteEnabledForReferer(const StringPiece& url) const { 02025 return blocking_rewrite_referer_urls_.Match(url, false); 02026 } 02027 02028 bool IsBlockingRewriteRefererUrlPatternPresent() const { 02029 return blocking_rewrite_referer_urls_.num_wildcards() > 0; 02030 } 02031 02032 bool rewrite_uncacheable_resources() const { 02033 return rewrite_uncacheable_resources_.value(); 02034 } 02035 02036 void set_rewrite_uncacheable_resources(bool x) { 02037 set_option(x, &rewrite_uncacheable_resources_); 02038 } 02039 02040 void set_running_experiment(bool x) { 02041 set_option(x, &running_experiment_); 02042 } 02043 bool running_experiment() const { 02044 return running_experiment_.value(); 02045 } 02046 02048 void set_experiment_ga_slot(int x) { 02049 set_option(x, &experiment_ga_slot_); 02050 } 02051 02052 int experiment_ga_slot() const { return experiment_ga_slot_.value(); } 02053 02054 void set_report_unload_time(bool x) { 02055 set_option(x, &report_unload_time_); 02056 } 02057 bool report_unload_time() const { 02058 return report_unload_time_.value(); 02059 } 02060 02061 void set_implicit_cache_ttl_ms(int64 x) { 02062 set_option(x, &implicit_cache_ttl_ms_); 02063 } 02064 int64 implicit_cache_ttl_ms() const { 02065 return implicit_cache_ttl_ms_.value(); 02066 } 02067 02068 void set_x_header_value(const StringPiece& p) { 02069 set_option(p.as_string(), &x_header_value_); 02070 } 02071 const GoogleString& x_header_value() const { 02072 return x_header_value_.value(); 02073 } 02074 02075 void set_distributed_rewrite_key(const StringPiece& p) { 02076 set_option(p.as_string(), &distributed_rewrite_key_); 02077 } 02078 const GoogleString& distributed_rewrite_key() const { 02079 return distributed_rewrite_key_.value(); 02080 } 02081 02082 void set_distribute_fetches(bool x) { 02083 set_option(x, &distribute_fetches_); 02084 } 02085 bool distribute_fetches() const { 02086 return distribute_fetches_.value(); 02087 } 02088 02089 void set_distributed_rewrite_servers(const StringPiece& p) { 02090 set_option(p.as_string(), &distributed_rewrite_servers_); 02091 } 02092 const GoogleString& distributed_rewrite_servers() const { 02093 return distributed_rewrite_servers_.value(); 02094 } 02095 02096 void set_distributed_rewrite_timeout_ms(const int64 x) { 02097 set_option(x, &distributed_rewrite_timeout_ms_); 02098 } 02099 int64 distributed_rewrite_timeout_ms() const { 02100 return distributed_rewrite_timeout_ms_.value(); 02101 } 02102 02103 void set_avoid_renaming_introspective_javascript(bool x) { 02104 set_option(x, &avoid_renaming_introspective_javascript_); 02105 } 02106 bool avoid_renaming_introspective_javascript() const { 02107 return avoid_renaming_introspective_javascript_.value(); 02108 } 02109 02110 int64 blink_max_html_size_rewritable() const { 02111 return blink_max_html_size_rewritable_.value(); 02112 } 02113 void set_blink_max_html_size_rewritable(int64 x) { 02114 set_option(x, &blink_max_html_size_rewritable_); 02115 } 02116 02117 void set_critical_line_config(const StringPiece& p) { 02118 set_option(GoogleString(p.data(), p.size()), &critical_line_config_); 02119 } 02120 const GoogleString& critical_line_config() const { 02121 return critical_line_config_.value(); 02122 } 02123 02124 void set_forbid_all_disabled_filters(bool x) { 02125 set_option(x, &forbid_all_disabled_filters_); 02126 } 02127 bool forbid_all_disabled_filters() const { 02128 return forbid_all_disabled_filters_.value(); 02129 } 02130 02131 bool reject_blacklisted() const { return reject_blacklisted_.value(); } 02132 void set_reject_blacklisted(bool x) { 02133 set_option(x, &reject_blacklisted_); 02134 } 02135 02136 HttpStatus::Code reject_blacklisted_status_code() const { 02137 return static_cast<HttpStatus::Code>( 02138 reject_blacklisted_status_code_.value()); 02139 } 02140 void set_reject_blacklisted_status_code(HttpStatus::Code x) { 02141 set_option(static_cast<int>(x), &reject_blacklisted_status_code_); 02142 } 02143 02144 bool support_noscript_enabled() const { 02145 return support_noscript_enabled_.value(); 02146 } 02147 void set_support_noscript_enabled(bool x) { 02148 set_option(x, &support_noscript_enabled_); 02149 } 02150 02151 bool enable_extended_instrumentation() const { 02152 return enable_extended_instrumentation_.value(); 02153 } 02154 void set_enable_extended_instrumentation(bool x) { 02155 set_option(x, &enable_extended_instrumentation_); 02156 } 02157 02158 void set_max_combined_css_bytes(int64 x) { 02159 set_option(x, &max_combined_css_bytes_); 02160 } 02161 int64 max_combined_css_bytes() const { 02162 return max_combined_css_bytes_.value(); 02163 } 02164 02165 void set_max_combined_js_bytes(int64 x) { 02166 set_option(x, &max_combined_js_bytes_); 02167 } 02168 int64 max_combined_js_bytes() const { 02169 return max_combined_js_bytes_.value(); 02170 } 02171 02172 void set_pre_connect_url(const StringPiece& p) { 02173 set_option(GoogleString(p.data(), p.size()), &pre_connect_url_); 02174 } 02175 const GoogleString& pre_connect_url() const { 02176 return pre_connect_url_.value(); 02177 } 02178 void set_property_cache_http_status_stability_threshold(int x) { 02179 set_option(x, &property_cache_http_status_stability_threshold_); 02180 } 02181 int property_cache_http_status_stability_threshold() const { 02182 return property_cache_http_status_stability_threshold_.value(); 02183 } 02184 02185 void set_max_rewrite_info_log_size(int x) { 02186 set_option(x, &max_rewrite_info_log_size_); 02187 } 02188 int max_rewrite_info_log_size() const { 02189 return max_rewrite_info_log_size_.value(); 02190 } 02191 02192 void set_enable_aggressive_rewriters_for_mobile(bool x) { 02193 set_option(x, &enable_aggressive_rewriters_for_mobile_); 02194 } 02195 bool enable_aggressive_rewriters_for_mobile() const { 02196 return enable_aggressive_rewriters_for_mobile_.value(); 02197 } 02198 02199 void set_allow_logging_urls_in_log_record(bool x) { 02200 set_option(x, &allow_logging_urls_in_log_record_); 02201 } 02202 bool allow_logging_urls_in_log_record() const { 02203 return allow_logging_urls_in_log_record_.value(); 02204 } 02205 02206 void set_non_cacheables_for_cache_partial_html(const StringPiece& p) { 02207 set_option(p.as_string(), &non_cacheables_for_cache_partial_html_); 02208 } 02209 const GoogleString& non_cacheables_for_cache_partial_html() const { 02210 return non_cacheables_for_cache_partial_html_.value(); 02211 } 02212 02213 void set_access_control_allow_origins(const StringPiece& p) { 02214 set_option(p.as_string(), &access_control_allow_origins_); 02215 } 02216 const GoogleString& access_control_allow_origins() const { 02217 return access_control_allow_origins_.value(); 02218 } 02219 02220 void set_hide_referer_using_meta(bool x) { 02221 set_option(x, &hide_referer_using_meta_); 02222 } 02223 bool hide_referer_using_meta() const { 02224 return hide_referer_using_meta_.value(); 02225 } 02226 02227 void set_max_low_res_image_size_bytes(int64 x) { 02228 set_option(x, &max_low_res_image_size_bytes_); 02229 } 02230 int64 max_low_res_image_size_bytes() const { 02231 return max_low_res_image_size_bytes_.value(); 02232 } 02233 02234 void set_max_low_res_to_full_res_image_size_percentage(int x) { 02235 set_option(x, &max_low_res_to_full_res_image_size_percentage_); 02236 } 02237 int max_low_res_to_full_res_image_size_percentage() const { 02238 return max_low_res_to_full_res_image_size_percentage_.value(); 02239 } 02240 02241 void set_serve_rewritten_webp_urls_to_any_agent(bool x) { 02242 set_option(x, &serve_rewritten_webp_urls_to_any_agent_); 02243 } 02244 bool serve_rewritten_webp_urls_to_any_agent() const { 02245 return serve_rewritten_webp_urls_to_any_agent_.value(); 02246 } 02247 02263 virtual void Merge(const RewriteOptions& src); 02264 02267 void Allow(const StringPiece& wildcard_pattern) { 02268 Modify(); 02269 allow_resources_.Allow(wildcard_pattern); 02270 } 02271 02274 void Disallow(const StringPiece& wildcard_pattern) { 02275 Modify(); 02276 allow_resources_.Disallow(wildcard_pattern); 02277 } 02278 02282 virtual void DisallowTroublesomeResources(); 02283 02288 virtual void DisallowResourcesForProxy(); 02289 02310 const DomainLawyer* domain_lawyer() const { return domain_lawyer_.get(); } 02311 DomainLawyer* WriteableDomainLawyer(); 02312 02313 FileLoadPolicy* file_load_policy() { return &file_load_policy_; } 02314 const FileLoadPolicy* file_load_policy() const { return &file_load_policy_; } 02315 02318 bool IsAllowed(const StringPiece& url) const { 02319 return allow_resources_.Match(url, true); 02320 } 02321 02323 void RetainComment(const StringPiece& comment) { 02324 Modify(); 02325 retain_comments_.Allow(comment); 02326 } 02327 02331 bool IsRetainedComment(const StringPiece& comment) const { 02332 return retain_comments_.Match(comment, false); 02333 } 02334 02336 void DisableLazyloadForClassName(const StringPiece& class_name) { 02337 Modify(); 02338 lazyload_enabled_classes_.Disallow(class_name); 02339 } 02340 02342 bool IsLazyloadEnabledForClassName(const StringPiece& class_name) const { 02343 return lazyload_enabled_classes_.Match(class_name, true); 02344 } 02345 02346 void set_override_caching_ttl_ms(int64 x) { 02347 set_option(x, &override_caching_ttl_ms_); 02348 } 02349 int64 override_caching_ttl_ms() const { 02350 return override_caching_ttl_ms_.value(); 02351 } 02352 02355 void AddOverrideCacheTtl(const StringPiece& wildcard) { 02356 Modify(); 02357 override_caching_wildcard_.Allow(wildcard); 02358 } 02359 02361 bool IsCacheTtlOverridden(const StringPiece& url) const { 02362 return override_caching_wildcard_.Match(url, false); 02363 } 02364 02365 void AddRejectedUrlWildcard(const GoogleString& wildcard) { 02366 AddRejectedHeaderWildcard(kRejectedRequestUrlKeyName, wildcard); 02367 } 02368 02369 void AddRejectedHeaderWildcard(const StringPiece& header_name, 02370 const GoogleString& wildcard) { 02371 Modify(); 02372 std::pair<FastWildcardGroupMap::iterator, bool> insert_result = 02373 rejected_request_map_.insert(std::make_pair( 02374 header_name, static_cast<FastWildcardGroup*>(NULL))); 02375 02376 if (insert_result.second) { 02377 insert_result.first->second = new FastWildcardGroup; 02378 } 02379 insert_result.first->second->Allow(wildcard); 02380 } 02381 02382 void set_min_cache_ttl_ms(int64 x) { 02383 set_option(x, &min_cache_ttl_ms_); 02384 } 02385 int64 min_cache_ttl_ms() const { 02386 return min_cache_ttl_ms_.value(); 02387 } 02388 02391 bool IsRequestDeclined(const GoogleString& url, 02392 const RequestHeaders* request_headers) const; 02393 02397 virtual RewriteOptions* Clone() const; 02398 02400 virtual RewriteOptions* NewOptions() const; 02401 02407 void ComputeSignature(); 02408 02413 void Freeze(); 02414 02421 void ClearSignatureWithCaution(); 02422 02423 bool frozen() const { return frozen_; } 02424 02428 bool ClearSignatureForTesting() { 02429 bool frozen = frozen_; 02430 ClearSignatureWithCaution(); 02431 return frozen; 02432 } 02433 02435 const GoogleString& signature() const { 02443 ThreadSystem::ScopedReader lock(cache_invalidation_timestamp_.mutex()); 02444 DCHECK(frozen_); 02445 DCHECK(!signature_.empty()); 02446 return signature_; 02447 } 02448 02449 virtual GoogleString OptionsToString() const; 02450 GoogleString FilterSetToString(const FilterSet& filter_set) const; 02451 02454 virtual GoogleString ToExperimentString() const; 02455 02459 virtual GoogleString ToExperimentDebugString() const; 02460 02463 static Filter LookupFilterById(const StringPiece& filter_id); 02464 02466 static Filter LookupFilter(const StringPiece& filter_name); 02467 02470 static const PropertyBase* LookupOptionById(StringPiece option_id); 02471 static const PropertyBase* LookupOptionByName(StringPiece option_name); 02472 02475 static const StringPiece LookupOptionNameById(StringPiece option_id); 02476 02478 static bool IsValidOptionName(StringPiece name); 02479 02482 const OptionBaseVector& all_options() const { 02483 return all_options_; 02484 } 02485 02489 bool IsEqual(const RewriteOptions& that) const; 02490 02492 const Hasher* hasher() const { return &hasher_; } 02493 02494 ThreadSystem* thread_system() const { return thread_system_; } 02495 02496 protected: 02506 template<class T> class OptionTemplateBase : public OptionBase { 02507 public: 02508 typedef T ValueType; 02509 02510 OptionTemplateBase() : was_set_(false), property_(NULL) {} 02511 02512 virtual bool was_set() const { return was_set_; } 02513 02514 void set(const T& val) { 02515 was_set_ = true; 02516 value_ = val; 02517 } 02518 02519 void set_default(const T& val) { 02520 if (!was_set_) { 02521 value_ = val; 02522 } 02523 } 02524 02525 const T& value() const { return value_; } 02526 02532 virtual void Merge(const OptionBase* src) { 02533 DCHECK(option_name() == src->option_name()); 02534 MergeHelper(static_cast<const OptionTemplateBase*>(src)); 02535 } 02536 02537 void MergeHelper(const OptionTemplateBase* src) { 02540 if (src->was_set_ || !was_set_) { 02541 value_ = src->value_; 02542 was_set_ = src->was_set_; 02543 } 02544 } 02545 02547 void set_property(const Property<T>* property) { 02548 property_ = property; 02549 02554 value_ = property->default_value(); 02555 } 02556 virtual const PropertyBase* property() const { return property_; } 02557 02566 void set_global_default(const T& val) { 02567 Property<T>* property = const_cast<Property<T>*>(property_); 02568 property->set_default(val); 02569 } 02570 02579 void DoNotUseForSignatureComputation() { 02580 Property<T>* property = const_cast<Property<T>*>(property_); 02581 property->set_do_not_use_for_signature_computation(true); 02582 } 02583 02584 private: 02585 bool was_set_; 02586 T value_; 02587 const Property<T>* property_; 02588 02589 DISALLOW_COPY_AND_ASSIGN(OptionTemplateBase); 02590 }; 02591 02596 template<class T> class Option : public OptionTemplateBase<T> { 02597 public: 02598 Option() {} 02599 02601 virtual bool SetFromString(StringPiece value_string) { 02602 T value; 02603 bool success = RewriteOptions::ParseFromString(value_string, &value); 02604 if (success) { 02605 this->set(value); 02606 } 02607 return success; 02608 } 02609 02610 virtual GoogleString Signature(const Hasher* hasher) const { 02611 return RewriteOptions::OptionSignature(this->value(), hasher); 02612 } 02613 02614 virtual GoogleString ToString() const { 02615 return RewriteOptions::ToString(this->value()); 02616 } 02617 02618 private: 02619 DISALLOW_COPY_AND_ASSIGN(Option); 02620 }; 02621 02634 class MutexedOptionInt64MergeWithMax : public Option<int64> { 02635 public: 02636 MutexedOptionInt64MergeWithMax(); 02637 virtual ~MutexedOptionInt64MergeWithMax(); 02638 02643 virtual void Merge(const OptionBase* src_base); 02644 02655 void checked_set(const int64& value) { 02656 mutex_->DCheckLocked(); 02657 Option<int64>::set(value); 02658 } 02659 02673 ThreadSystem::RWLock* mutex() const { return mutex_.get(); } 02674 02680 void set_mutex(ThreadSystem::RWLock* lock) { mutex_.reset(lock); } 02681 02682 private: 02683 scoped_ptr<ThreadSystem::RWLock> mutex_; 02684 }; 02685 02686 protected: 02688 template<class RewriteOptionsSubclass, class OptionClass> 02689 static void AddProperty( 02690 typename OptionClass::ValueType default_value, 02691 OptionClass RewriteOptionsSubclass::*offset, 02692 const char* id, 02693 StringPiece option_name, 02694 OptionScope scope, 02695 const char* help_text, 02696 Properties* properties) { 02697 PropertyBase* property = 02698 new PropertyLeaf<RewriteOptionsSubclass, OptionClass>( 02699 default_value, offset, id, option_name); 02700 property->set_scope(scope); 02701 property->set_help_text(help_text); 02702 properties->push_back(property); 02703 } 02704 02718 static void MergeSubclassProperties(Properties* properties); 02719 02721 void DisableFiltersForPreserveUrl(); 02722 02728 void set_option_at(int index, OptionBase* option) { 02729 all_options_[index] = option; 02730 } 02731 02735 template<class T> 02736 void set_option(const T& new_value, OptionTemplateBase<T>* option) { 02737 option->set(new_value); 02738 Modify(); 02739 } 02740 02742 void Modify(); 02743 02751 void set_default_x_header_value(const StringPiece& x_header_value) { 02752 x_header_value_.set_global_default(x_header_value.as_string()); 02753 } 02754 02758 bool SetupExperimentRewriters(); 02759 02761 virtual void SetRequiredExperimentFilters(); 02762 02766 bool InsertExperimentSpecInVector(ExperimentSpec* spec); 02767 02769 Option<BeaconUrl> beacon_url_; 02770 02772 Option<GoogleString> x_header_value_; 02773 02774 private: 02775 struct OptionIdCompare; 02776 02779 class PropertyBase { 02780 public: 02781 PropertyBase(const char* id, StringPiece option_name) 02782 : id_(id), 02783 help_text_(NULL), 02784 option_name_(option_name), 02785 scope_(kDirectoryScope), 02786 do_not_use_for_signature_computation_(false), 02787 index_(-1) { 02788 } 02789 virtual ~PropertyBase(); 02790 02793 virtual void InitializeOption(RewriteOptions* options) const = 0; 02794 02795 void set_do_not_use_for_signature_computation(bool x) { 02796 do_not_use_for_signature_computation_ = x; 02797 } 02798 bool is_used_for_signature_computation() const { 02799 return !do_not_use_for_signature_computation_; 02800 } 02801 02802 void set_scope(OptionScope x) { scope_ = x; } 02803 OptionScope scope() const { return scope_; } 02804 02805 void set_help_text(const char* x) { help_text_ = x; } 02806 const char* help_text() const { return help_text_; } 02807 02808 void set_index(int index) { index_ = index; } 02809 const char* id() const { return id_; } 02810 StringPiece option_name() const { return option_name_; } 02811 int index() const { return index_; } 02812 02813 private: 02814 const char* id_; 02815 const char* help_text_; 02816 StringPiece option_name_; 02817 OptionScope scope_; 02818 bool do_not_use_for_signature_computation_; 02819 int index_; 02820 02821 DISALLOW_COPY_AND_ASSIGN(PropertyBase); 02822 }; 02823 02827 template<class ValueType> 02828 class Property : public PropertyBase { 02829 public: 02834 Property(ValueType default_value, 02835 const char* id, 02836 StringPiece option_name) 02837 : PropertyBase(id, option_name), 02838 default_value_(default_value) { 02839 } 02840 02841 void set_default(ValueType value) { default_value_ = value; } 02842 const ValueType& default_value() const { return default_value_; } 02843 02844 private: 02845 ValueType default_value_; 02846 02847 DISALLOW_COPY_AND_ASSIGN(Property); 02848 }; 02849 02864 template<class RewriteOptionsSubclass, class OptionClass> 02865 class PropertyLeaf : public Property<typename OptionClass::ValueType> { 02866 public: 02870 typedef OptionClass RewriteOptionsSubclass::*OptionOffset; 02871 typedef typename OptionClass::ValueType ValueType; 02872 02873 PropertyLeaf(ValueType default_value, 02874 OptionOffset offset, 02875 const char* id, 02876 StringPiece option_name) 02877 : Property<ValueType>(default_value, id, option_name), 02878 offset_(offset) { 02879 } 02880 02881 virtual void InitializeOption(RewriteOptions* options) const { 02882 RewriteOptionsSubclass* options_subclass = 02883 static_cast<RewriteOptionsSubclass*>(options); 02884 OptionClass& option = options_subclass->*offset_; 02885 option.set_property(this); 02886 DCHECK_NE(-1, this->index()) << "Call Property::set_index first."; 02887 options->set_option_at(this->index(), &option); 02888 } 02889 02890 private: 02891 OptionOffset offset_; 02892 02893 DISALLOW_COPY_AND_ASSIGN(PropertyLeaf); 02894 }; 02895 02896 static Properties* properties_; 02897 static Properties* all_properties_; 02898 02899 FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest); 02900 FRIEND_TEST(RewriteOptionsTest, LookupOptionByNameTest); 02901 02903 bool HasRejectedHeader(const StringPiece& header_name, 02904 const RequestHeaders* request_headers) const; 02905 02906 bool IsRejectedUrl(const GoogleString& url) const { 02907 return IsRejectedRequest(kRejectedRequestUrlKeyName, url); 02908 } 02909 02910 bool IsRejectedRequest(const StringPiece& header_name, 02911 const StringPiece& value) const { 02912 FastWildcardGroupMap::const_iterator it = rejected_request_map_.find( 02913 header_name); 02914 if (it != rejected_request_map_.end()) { 02915 return it->second->Match(value, false); 02916 } 02917 return false; 02918 } 02919 02922 JavascriptLibraryIdentification* WriteableJavascriptLibraryIdentification(); 02923 02930 struct PrioritizeVisibleContentFamily { 02931 PrioritizeVisibleContentFamily(StringPiece url_pattern_string, 02932 int64 cache_time_ms_in, 02933 StringPiece non_cacheable_elements_in) 02934 : url_pattern(url_pattern_string), 02935 cache_time_ms(cache_time_ms_in), 02936 non_cacheable_elements(non_cacheable_elements_in.data(), 02937 non_cacheable_elements_in.size()) {} 02938 02939 PrioritizeVisibleContentFamily* Clone() const { 02940 return new PrioritizeVisibleContentFamily( 02941 url_pattern.spec(), cache_time_ms, non_cacheable_elements); 02942 } 02943 02944 GoogleString ComputeSignature() const { 02945 return StrCat(url_pattern.spec(), ";", Integer64ToString(cache_time_ms), 02946 ";", non_cacheable_elements); 02947 } 02948 02949 GoogleString ToString() const { 02950 return StrCat("URL pattern: ", url_pattern.spec(), ", Cache time (ms): ", 02951 Integer64ToString(cache_time_ms), ", Non-cacheable: ", 02952 non_cacheable_elements); 02953 } 02954 02955 Wildcard url_pattern; 02956 int64 cache_time_ms; 02957 GoogleString non_cacheable_elements; 02958 }; 02959 02962 struct UrlCacheInvalidationEntry { 02963 UrlCacheInvalidationEntry(StringPiece url_pattern_in, 02964 int64 timestamp_ms_in, 02965 bool ignores_metadata_and_pcache_in) 02966 : url_pattern(url_pattern_in), 02967 timestamp_ms(timestamp_ms_in), 02968 ignores_metadata_and_pcache(ignores_metadata_and_pcache_in) {} 02969 02970 UrlCacheInvalidationEntry* Clone() const { 02971 return new UrlCacheInvalidationEntry( 02972 url_pattern.spec(), timestamp_ms, ignores_metadata_and_pcache); 02973 } 02974 02975 GoogleString ComputeSignature() const { 02976 if (ignores_metadata_and_pcache) { 02977 return ""; 02978 } 02979 return StrCat(url_pattern.spec(), "@", Integer64ToString(timestamp_ms)); 02980 } 02981 02982 GoogleString ToString() const { 02983 return StrCat( 02984 url_pattern.spec(), ", ", 02985 (ignores_metadata_and_pcache ? "STRICT" : "REFERENCE"), " @ ", 02986 Integer64ToString(timestamp_ms)); 02987 } 02988 02989 Wildcard url_pattern; 02990 int64 timestamp_ms; 02991 bool ignores_metadata_and_pcache; 02992 }; 02993 02994 typedef std::vector<UrlCacheInvalidationEntry*> 02995 UrlCacheInvalidationEntryVector; 02996 typedef dense_hash_map<GoogleString, int64> UrlCacheInvalidationMap; 02997 03001 typedef rde::hash_map<StringPiece, const PropertyBase*, 03002 CaseFoldStringPieceHash, 6, 03003 CaseFoldStringPieceEqual> PropertyNameMap; 03004 03017 template<class OptionClass> 03018 static void AddRequestProperty(typename OptionClass::ValueType default_value, 03019 OptionClass RewriteOptions::*offset, 03020 const char* id) { 03021 AddProperty(default_value, offset, id, kNullOption, kProcessScope, 03022 NULL, properties_); 03023 } 03024 03027 template<class OptionClass> 03028 static void AddBaseProperty(typename OptionClass::ValueType default_value, 03029 OptionClass RewriteOptions::*offset, 03030 const char* id, 03031 StringPiece option_name, 03032 OptionScope scope, 03033 const char* help) { 03034 AddProperty(default_value, offset, id, option_name, scope, help, 03035 properties_); 03036 } 03037 03038 static void AddProperties(); 03039 bool AddCommaSeparatedListToFilterSetState( 03040 const StringPiece& filters, FilterSet* set, MessageHandler* handler); 03041 static bool AddCommaSeparatedListToFilterSet( 03042 const StringPiece& filters, FilterSet* set, MessageHandler* handler); 03045 void ResolveConflicts(); 03047 static void InitFilterIdToEnumArray(); 03048 static void InitOptionIdToPropertyArray(); 03049 static void InitOptionNameToPropertyArray(); 03050 03054 OptionSettingResult FormatSetOptionMessage( 03055 OptionSettingResult result, StringPiece name, StringPiece value, 03056 GoogleString* msg); 03057 03060 static GoogleString OptionSignature(bool x, const Hasher* hasher) { 03061 return x ? "T" : "F"; 03062 } 03063 static GoogleString OptionSignature(int x, const Hasher* hasher) { 03064 return IntegerToString(x); 03065 } 03066 static GoogleString OptionSignature(int64 x, const Hasher* hasher) { 03067 return Integer64ToString(x); 03068 } 03069 static GoogleString OptionSignature(const GoogleString& x, 03070 const Hasher* hasher); 03071 static GoogleString OptionSignature(RewriteLevel x, 03072 const Hasher* hasher); 03073 static GoogleString OptionSignature(const BeaconUrl& beacon_url, 03074 const Hasher* hasher); 03075 03078 static GoogleString ToString(bool x) { 03079 return x ? "True" : "False"; 03080 } 03081 static GoogleString ToString(int x) { 03082 return IntegerToString(x); 03083 } 03084 static GoogleString ToString(int64 x) { 03085 return Integer64ToString(x); 03086 } 03087 static GoogleString ToString(const GoogleString& x) { 03088 return x; 03089 } 03090 static GoogleString ToString(RewriteLevel x); 03091 static GoogleString ToString(const BeaconUrl& beacon_url); 03092 03095 static bool PropertyLessThanByOptionName(PropertyBase* p1, PropertyBase* p2) { 03096 return StringCaseCompare(p1->option_name(), p2->option_name()) < 0; 03097 } 03098 03100 static bool OptionNameLessThanArg(OptionBase* option, StringPiece arg) { 03101 return StringCaseCompare(option->option_name(), arg) < 0; 03102 } 03103 03105 static bool CompareUrlCacheInvalidationEntry(UrlCacheInvalidationEntry* e1, 03106 UrlCacheInvalidationEntry* e2) { 03107 return e1->timestamp_ms < e2->timestamp_ms; 03108 } 03109 03111 static bool FilterEnumToIdAndNameEntryLessThanById( 03112 const FilterEnumToIdAndNameEntry* e1, 03113 const FilterEnumToIdAndNameEntry* e2) { 03114 return strcmp(e1->filter_id, e2->filter_id) < 0; 03115 } 03116 03119 static StringPiece GetEffectiveOptionName(StringPiece name); 03120 03123 bool CheckBandwidthOption(const Option<bool>& option) const { 03124 if (option.was_set() || (level() != kOptimizeForBandwidth)) { 03125 return option.value(); 03126 } 03127 return true; 03128 } 03129 03130 bool modified_; 03131 bool frozen_; 03132 FilterSet enabled_filters_; 03133 FilterSet disabled_filters_; 03134 FilterSet forbidden_filters_; 03135 03138 FilterIdSet distributable_filters_; 03139 03145 Option<RewriteLevel> level_; 03146 03149 UrlCacheInvalidationEntryVector url_cache_invalidation_entries_; 03150 03152 UrlCacheInvalidationMap url_cache_invalidation_map_; 03153 03154 MutexedOptionInt64MergeWithMax cache_invalidation_timestamp_; 03155 Option<int64> css_flatten_max_bytes_; 03156 Option<bool> cache_small_images_unrewritten_; 03158 Option<int64> image_resolution_limit_bytes_; 03159 Option<int64> css_image_inline_max_bytes_; 03160 Option<int64> css_inline_max_bytes_; 03161 Option<int64> css_outline_min_bytes_; 03162 03164 Option<bool> css_preserve_urls_; 03165 Option<bool> js_preserve_urls_; 03166 Option<bool> image_preserve_urls_; 03167 03168 Option<int64> image_inline_max_bytes_; 03169 Option<int64> js_inline_max_bytes_; 03170 Option<int64> js_outline_min_bytes_; 03171 Option<int64> progressive_jpeg_min_bytes_; 03173 Option<int64> max_html_cache_time_ms_; 03176 Option<int64> max_html_parse_bytes_; 03178 Option<int64> max_image_bytes_for_webp_in_css_; 03180 Option<int64> min_resource_cache_time_to_rewrite_ms_; 03181 Option<int64> idle_flush_time_ms_; 03182 Option<int64> flush_buffer_limit_bytes_; 03183 03187 Option<int64> blocking_fetch_timeout_ms_; 03188 03191 Option<int64> image_recompress_quality_; 03192 03194 Option<int64> image_jpeg_recompress_quality_; 03195 Option<int64> image_jpeg_recompress_quality_for_small_screens_; 03196 Option<int64> image_jpeg_num_progressive_scans_; 03197 Option<int64> image_jpeg_num_progressive_scans_for_small_screens_; 03198 03200 Option<int> image_limit_optimized_percent_; 03201 Option<int> image_limit_resize_area_percent_; 03202 Option<int> image_limit_rendered_area_percent_; 03203 03205 Option<int64> image_webp_recompress_quality_; 03206 Option<int64> image_webp_recompress_quality_for_small_screens_; 03207 Option<int64> image_webp_timeout_ms_; 03208 03209 Option<int> image_max_rewrites_at_once_; 03210 Option<int> max_url_segment_size_; 03211 Option<int> max_url_size_; 03212 03213 03214 Option<int> rewrite_deadline_ms_; 03216 Option<int> domain_shard_count_; 03217 03218 Option<EnabledEnum> enabled_; 03219 03220 Option<bool> distributable_; 03221 03224 Option<bool> add_options_to_urls_; 03225 03227 Option<bool> in_place_rewriting_enabled_; 03229 Option<bool> in_place_wait_for_optimized_; 03232 Option<int> in_place_rewrite_deadline_ms_; 03235 Option<bool> in_place_preemptive_rewrite_css_; 03237 Option<bool> in_place_preemptive_rewrite_css_images_; 03240 Option<bool> in_place_preemptive_rewrite_images_; 03243 Option<bool> in_place_preemptive_rewrite_javascript_; 03244 Option<bool> combine_across_paths_; 03245 Option<bool> log_background_rewrites_; 03246 Option<bool> log_rewrite_timing_; 03247 Option<bool> log_url_indices_; 03248 Option<bool> lowercase_html_names_; 03249 Option<bool> always_rewrite_css_; 03250 Option<bool> respect_vary_; 03251 Option<bool> respect_x_forwarded_proto_; 03252 Option<bool> flush_html_; 03256 Option<bool> serve_split_html_in_two_chunks_; 03259 Option<bool> serve_stale_if_fetch_error_; 03261 Option<bool> serve_ghost_click_buster_with_split_html_; 03263 Option<bool> serve_xhr_access_control_headers_; 03266 Option<bool> proactively_freshen_user_facing_request_; 03269 Option<int64> serve_stale_while_revalidate_threshold_sec_; 03271 Option<bool> enable_flush_early_critical_css_; 03273 Option<bool> use_selectors_for_critical_css_; 03278 Option<bool> default_cache_html_; 03283 Option<bool> modify_caching_headers_; 03287 Option<bool> lazyload_images_after_onload_; 03290 Option<GoogleString> lazyload_images_blank_url_; 03293 Option<bool> use_blank_image_for_inline_preview_; 03297 Option<bool> inline_only_critical_images_; 03301 Option<bool> inline_unauthorized_resources_; 03304 Option<bool> critical_images_beacon_enabled_; 03307 Option<bool> client_domain_rewrite_; 03310 Option<bool> domain_rewrite_hyperlinks_; 03313 Option<bool> running_experiment_; 03316 Option<int> experiment_ga_slot_; 03317 03320 Option<bool> increase_speed_tracking_; 03321 03325 Option<bool> report_unload_time_; 03326 03327 Option<bool> serve_rewritten_webp_urls_to_any_agent_; 03328 03330 Option<bool> flush_more_resources_early_if_time_permits_; 03331 03333 Option<bool> flush_more_resources_in_ie_and_firefox_; 03334 03337 Option<int> max_prefetch_js_elements_; 03338 03340 Option<bool> enable_defer_js_experimental_; 03341 03343 Option<bool> disable_rewrite_on_no_transform_; 03344 03346 Option<bool> disable_background_fetches_for_bots_; 03347 03357 Option<bool> enable_cache_purge_; 03358 03362 Option<bool> proactive_resource_freshening_; 03363 03365 Option<bool> lazyload_highres_images_; 03366 03369 Option<bool> avoid_renaming_introspective_javascript_; 03370 03372 Option<bool> override_ie_document_mode_; 03373 03375 Option<bool> test_instant_fetch_rewrite_deadline_; 03376 03380 Option<bool> test_only_prioritize_critical_css_dont_apply_original_css_; 03381 03387 Option<GoogleString> blocking_rewrite_key_; 03388 03392 Option<int> beacon_reinstrument_time_sec_; 03393 03396 Option<int> max_inlined_preview_images_index_; 03398 Option<int64> min_image_size_low_resolution_bytes_; 03400 Option<int64> max_image_size_low_resolution_bytes_; 03403 Option<int> rewrite_random_drop_percentage_; 03404 03407 Option<bool> oblivious_pagespeed_urls_; 03408 03410 Option<int64> finder_properties_cache_expiration_time_ms_; 03411 03415 Option<int64> finder_properties_cache_refresh_time_ms_; 03418 Option<int64> experiment_cookie_duration_ms_; 03419 03422 Option<int64> metadata_cache_staleness_threshold_ms_; 03423 03425 Option<int64> metadata_input_errors_cache_ttl_ms_; 03426 03429 Option<GoogleString> downstream_cache_purge_method_; 03430 03432 Option<GoogleString> downstream_cache_purge_location_prefix_; 03433 03436 Option<GoogleString> downstream_cache_rebeaconing_key_; 03437 03443 Option<int64> downstream_cache_rewritten_percentage_threshold_; 03444 03448 Option<int64> implicit_cache_ttl_ms_; 03449 03451 Option<int64> max_cacheable_response_content_length_; 03452 03454 Option<int64> blink_blacklist_end_timestamp_ms_; 03456 Option<bool> persist_blink_blacklist_; 03457 03460 Option<bool> preserve_url_relativity_; 03461 03462 Option<GoogleString> ga_id_; 03463 03464 Option<int64> blink_max_html_size_rewritable_; 03467 Option<int64> blink_html_change_detection_time_ms_; 03469 Option<bool> enable_blink_debug_dashboard_; 03471 Option<bool> enable_blink_html_change_detection_; 03473 Option<bool> enable_blink_html_change_detection_logging_; 03475 Option<bool> use_smart_diff_in_blink_; 03477 Option<bool> use_fallback_property_cache_values_; 03479 Option<bool> await_pcache_lookup_; 03481 Option<bool> enable_prioritizing_scripts_; 03483 Option<bool> rewrite_uncacheable_resources_; 03485 Option<GoogleString> critical_line_config_; 03488 Option<GoogleString> distributed_rewrite_key_; 03490 Option<GoogleString> distributed_rewrite_servers_; 03495 Option<bool> distribute_fetches_; 03498 Option<int64> distributed_rewrite_timeout_ms_; 03504 Option<bool> forbid_all_disabled_filters_; 03506 Option<bool> enable_aggressive_rewriters_for_mobile_; 03507 03513 Option<bool> reject_blacklisted_; 03514 Option<int> reject_blacklisted_status_code_; 03515 03519 Option<bool> support_noscript_enabled_; 03520 03523 Option<bool> enable_extended_instrumentation_; 03524 03527 Option<int64> max_combined_css_bytes_; 03528 03531 Option<int64> max_combined_js_bytes_; 03532 03534 Option<GoogleString> pre_connect_url_; 03537 Option<int> property_cache_http_status_stability_threshold_; 03539 Option<int> max_rewrite_info_log_size_; 03540 03545 Option<int64> override_caching_ttl_ms_; 03546 FastWildcardGroup override_caching_wildcard_; 03547 03551 Option<int64> min_cache_ttl_ms_; 03552 03554 Option<bool> allow_logging_urls_in_log_record_; 03555 03557 Option<GoogleString> non_cacheables_for_cache_partial_html_; 03558 03562 Option<GoogleString> access_control_allow_origins_; 03563 03565 Option<bool> hide_referer_using_meta_; 03566 03571 Option<int64> max_low_res_image_size_bytes_; 03572 Option<int> max_low_res_to_full_res_image_size_percentage_; 03573 03576 OptionBaseVector all_options_; 03577 size_t initialized_options_; 03578 03581 static const FilterEnumToIdAndNameEntry* filter_id_to_enum_array_[ 03582 kEndOfFilters]; 03583 03585 static PropertyNameMap* option_name_to_property_map_; 03586 03588 static const PropertyBase** option_id_to_property_array_; 03589 03596 bool options_uniqueness_checked_; 03597 03598 bool need_to_store_experiment_data_; 03599 int experiment_id_; 03600 int experiment_percent_; 03601 std::vector<ExperimentSpec*> experiment_specs_; 03602 03604 std::vector<NameValue*> custom_fetch_headers_; 03605 03608 scoped_ptr<std::vector<ElementAttributeCategory> > url_valued_attributes_; 03609 03610 CopyOnWrite<JavascriptLibraryIdentification> 03611 javascript_library_identification_; 03612 03613 CopyOnWrite<DomainLawyer> domain_lawyer_; 03614 FileLoadPolicy file_load_policy_; 03615 03616 FastWildcardGroup allow_resources_; 03617 FastWildcardGroup retain_comments_; 03618 FastWildcardGroup lazyload_enabled_classes_; 03621 FastWildcardGroup blocking_rewrite_referer_urls_; 03622 03625 typedef std::map<StringPiece, FastWildcardGroup*> FastWildcardGroupMap; 03626 FastWildcardGroupMap rejected_request_map_; 03627 03628 GoogleString signature_; 03629 MD5Hasher hasher_; 03630 03631 ThreadSystem* thread_system_; 03632 03645 scoped_ptr<ThreadSystem::ThreadId> last_thread_id_; 03646 03647 DISALLOW_COPY_AND_ASSIGN(RewriteOptions); 03648 }; 03649 03650 } 03651 03652 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_