Page Speed Optimization Libraries  1.6.29.3
net/instaweb/rewriter/public/rewrite_options.h
Go to the documentation of this file.
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/rde_hash_map.h"
00044 #include "pagespeed/kernel/base/string_hash.h"
00045 #include "pagespeed/kernel/util/copy_on_write.h"
00046 #include "pagespeed/kernel/util/fast_wildcard_group.h"
00047 #include "pagespeed/kernel/util/wildcard.h"
00048 
00049 namespace net_instaweb {
00050 
00051 class Hasher;
00052 class MessageHandler;
00053 class RequestHeaders;
00054 
00075 class RewriteOptions {
00076  public:
00081   enum Filter {
00082     kAddBaseTag,  
00083     kAddHead,
00084     kAddInstrumentation,
00085     kComputeStatistics,
00086     kCachePartialHtml,
00087     kCanonicalizeJavascriptLibraries,
00088     kCollapseWhitespace,
00089     kCollectFlushEarlyContentFilter,
00090     kCombineCss,
00091     kCombineHeads,
00092     kCombineJavascript,
00093     kComputeCriticalCss,
00094     kComputeVisibleText,
00095     kConvertGifToPng,
00096     kConvertJpegToProgressive,
00097     kConvertJpegToWebp,
00098     kConvertMetaTags,
00099     kConvertPngToJpeg,
00100     kConvertToWebpLossless,
00101     kDebug,
00102     kDecodeRewrittenUrls,
00103     kDedupInlinedImages,
00104     kDeferIframe,
00105     kDeferJavascript,
00106     kDelayImages,
00107     kDetectReflowWithDeferJavascript,
00108     kDeterministicJs,
00109     kDisableJavascript,
00110     kDivStructure,
00111     kElideAttributes,
00112     kExplicitCloseTags,
00113     kExtendCacheCss,
00114     kExtendCacheImages,
00115     kExtendCachePdfs,
00116     kExtendCacheScripts,
00117     kFallbackRewriteCssUrls,
00118     kFlattenCssImports,
00119     kFlushSubresources,
00120     kHandleNoscriptRedirect,
00121     kHtmlWriterFilter,
00122     kInlineCss,
00123     kInlineImages,
00124     kInlineImportToLink,
00125     kInlineJavascript,
00126     kInPlaceOptimizeForBrowser,
00127     kInsertDnsPrefetch,
00128     kInsertGA,
00129     kInsertImageDimensions,
00130     kJpegSubsampling,
00131     kLazyloadImages,
00132     kLeftTrimUrls,
00133     kLocalStorageCache,
00134     kMakeGoogleAnalyticsAsync,
00135     kMoveCssAboveScripts,
00136     kMoveCssToHead,
00137     kOutlineCss,
00138     kOutlineJavascript,
00139     kPedantic,
00140     kPrioritizeCriticalCss,
00141     kRecompressJpeg,
00142     kRecompressPng,
00143     kRecompressWebp,
00144     kRemoveComments,
00145     kRemoveQuotes,
00146     kResizeImages,
00147     kResizeMobileImages,
00148     kResizeToRenderedImageDimensions,
00149     kRewriteCss,
00150     kRewriteDomains,
00151     kRewriteJavascript,
00152     kRewriteStyleAttributes,
00153     kRewriteStyleAttributesWithUrl,
00154     kSplitHtml,
00155     kSplitHtmlHelper,
00156     kSpriteImages,
00157     kSquashImagesForMobileScreen,
00158     kStripImageColorProfile,
00159     kStripImageMetaData,
00160     kStripNonCacheable,
00161     kStripScripts,
00162     kEndOfFilters
00163   };
00164 
00165   enum EnabledEnum {
00168     kEnabledOff,
00170     kEnabledOn,
00173     kEnabledUnplugged,
00174   };
00175 
00182   static const char kAccessControlAllowOrigins[];
00183   static const char kAddOptionsToUrls[];
00184   static const char kAllowLoggingUrlsInLogRecord[];
00185   static const char kAlwaysRewriteCss[];
00186   static const char kAnalyticsID[];
00187   static const char kAvoidRenamingIntrospectiveJavascript[];
00188   static const char kBeaconReinstrumentTimeSec[];
00189   static const char kBeaconUrl[];
00190   static const char kBlinkMaxHtmlSizeRewritable[];
00191   static const char kCacheInvalidationTimestamp[];
00192   static const char kCacheSmallImagesUnrewritten[];
00193   static const char kClientDomainRewrite[];
00194   static const char kCombineAcrossPaths[];
00195   static const char kCriticalImagesBeaconEnabled[];
00196   static const char kCriticalLineConfig[];
00197   static const char kCssFlattenMaxBytes[];
00198   static const char kCssImageInlineMaxBytes[];
00199   static const char kCssInlineMaxBytes[];
00200   static const char kCssOutlineMinBytes[];
00201   static const char kCssPreserveURLs[];
00202   static const char kDefaultCacheHtml[];
00203   static const char kDisableRewriteOnNoTransform[];
00204   static const char kDistributedRewriteKey[];
00205   static const char kDistributedRewriteServers[];
00206   static const char kDistributedRewriteTimeoutMs[];
00207   static const char kDomainRewriteHyperlinks[];
00208   static const char kDomainShardCount[];
00209   static const char kDownstreamCachePurgeMethod[];
00210   static const char kDownstreamCacheRewrittenPercentageThreshold[];
00211   static const char kEnableAggressiveRewritersForMobile[];
00212   static const char kEnableBlinkHtmlChangeDetection[];
00213   static const char kEnableBlinkHtmlChangeDetectionLogging[];
00214   static const char kEnableCachePurge[];
00215   static const char kEnableDeferJsExperimental[];
00216   static const char kEnableExtendedInstrumentation[];
00217   static const char kEnableFixReflow[];
00218   static const char kEnableFlushEarlyCriticalCss[];
00219   static const char kEnableLazyLoadHighResImages[];
00220   static const char kEnablePrioritizingScripts[];
00221   static const char kEnabled[];
00222   static const char kExperimentCookieDurationMs[];
00223   static const char kExperimentSlot[];
00224   static const char kFetcherTimeOutMs[];
00225   static const char kFinderPropertiesCacheExpirationTimeMs[];
00226   static const char kFinderPropertiesCacheRefreshTimeMs[];
00227   static const char kFlushBufferLimitBytes[];
00228   static const char kFlushHtml[];
00229   static const char kFlushMoreResourcesEarlyIfTimePermits[];
00230   static const char kForbidAllDisabledFilters[];
00231   static const char kHideRefererUsingMeta[];
00232   static const char kIdleFlushTimeMs[];
00233   static const char kImageInlineMaxBytes[];
00234   static const char kImageJpegNumProgressiveScans[];
00235   static const char kImageJpegNumProgressiveScansForSmallScreens[];
00236   static const char kImageJpegRecompressionQuality[];
00237   static const char kImageJpegRecompressionQualityForSmallScreens[];
00238   static const char kImageLimitOptimizedPercent[];
00239   static const char kImageLimitRenderedAreaPercent[];
00240   static const char kImageLimitResizeAreaPercent[];
00241   static const char kImageMaxRewritesAtOnce[];
00242   static const char kImagePreserveURLs[];
00243   static const char kImageRecompressionQuality[];
00244   static const char kImageResolutionLimitBytes[];
00245   static const char kImageWebpRecompressionQuality[];
00246   static const char kImageWebpRecompressionQualityForSmallScreens[];
00247   static const char kImageWebpTimeoutMs[];
00248   static const char kImplicitCacheTtlMs[];
00249   static const char kIncreaseSpeedTracking[];
00250   static const char kInlineOnlyCriticalImages[];
00251   static const char kInPlacePreemptiveRewriteCss[];
00252   static const char kInPlacePreemptiveRewriteCssImages[];
00253   static const char kInPlacePreemptiveRewriteImages[];
00254   static const char kInPlacePreemptiveRewriteJavascript[];
00255   static const char kInPlaceResourceOptimization[];
00256   static const char kInPlaceRewriteDeadlineMs[];
00257   static const char kInPlaceWaitForOptimized[];
00258   static const char kJsInlineMaxBytes[];
00259   static const char kJsOutlineMinBytes[];
00260   static const char kJsPreserveURLs[];
00261   static const char kLazyloadImagesAfterOnload[];
00262   static const char kLazyloadImagesBlankUrl[];
00263   static const char kLogBackgroundRewrite[];
00264   static const char kLogRewriteTiming[];
00265   static const char kLogUrlIndices[];
00266   static const char kLowercaseHtmlNames[];
00267   static const char kMaxCacheableResponseContentLength[];
00268   static const char kMaxCombinedJsBytes[];
00269   static const char kMaxHtmlCacheTimeMs[];
00270   static const char kMaxHtmlParseBytes[];
00271   static const char kMaxImageBytesForWebpInCss[];
00272   static const char kMaxImageSizeLowResolutionBytes[];
00273   static const char kMaxInlinedPreviewImagesIndex[];
00274   static const char kMaxPrefetchJsElements[];
00275   static const char kMaxRewriteInfoLogSize[];
00276   static const char kMaxUrlSegmentSize[];
00277   static const char kMaxUrlSize[];
00278   static const char kMetadataCacheStalenessThresholdMs[];
00279   static const char kMinImageSizeLowResolutionBytes[];
00280   static const char kMinResourceCacheTimeToRewriteMs[];
00281   static const char kModifyCachingHeaders[];
00282   static const char kNonCacheablesForCachePartialHtml[];
00283   static const char kObliviousPagespeedUrls[];
00284   static const char kOverrideCachingTtlMs[];
00285   static const char kPersistBlinkBlacklist[];
00286   static const char kProactivelyFreshenUserFacingRequest[];
00287   static const char kProgressiveJpegMinBytes[];
00288   static const char kRejectBlacklisted[];
00289   static const char kRejectBlacklistedStatusCode[];
00290   static const char kReportUnloadTime[];
00291   static const char kRespectVary[];
00292   static const char kRespectXForwardedProto[];
00293   static const char kRewriteDeadlineMs[];
00294   static const char kRewriteLevel[];
00295   static const char kRewriteRandomDropPercentage[];
00296   static const char kRewriteRequestUrlsEarly[];
00297   static const char kRewriteUncacheableResources[];
00298   static const char kRunningExperiment[];
00299   static const char kServeGhostClickBusterWithSplitHtml[];
00300   static const char kServeSplitHtmlInTwoChunks[];
00301   static const char kServeStaleIfFetchError[];
00302   static const char kServeStaleWhileRevalidateThresholdSec[];
00303   static const char kServeXhrAccessControlHeaders[];
00304   static const char kSupportNoScriptEnabled[];
00305   static const char kTestOnlyPrioritizeCriticalCssDontApplyOriginalCss[];
00306   static const char kUseBlankImageForInlinePreview[];
00307   static const char kUseFallbackPropertyCacheValues[];
00308   static const char kUseSmartDiffInBlink[];
00309   static const char kXModPagespeedHeaderValue[];
00310   static const char kXPsaBlockingRewrite[];
00312   static const char kAllow[];
00313   static const char kBlockingRewriteRefererUrls[];
00314   static const char kDisableFilters[];
00315   static const char kDisallow[];
00316   static const char kDistributableFilters[]; 
00317   static const char kDomain[];
00318   static const char kDownstreamCachePurgeLocationPrefix[];
00319   static const char kEnableFilters[];
00320   static const char kExperimentVariable[];
00321   static const char kExperimentSpec[];
00322   static const char kForbidFilters[];
00323   static const char kRetainComment[];
00325   static const char kCustomFetchHeader[];
00326   static const char kLoadFromFile[];
00327   static const char kLoadFromFileMatch[];
00328   static const char kLoadFromFileRule[];
00329   static const char kLoadFromFileRuleMatch[];
00330   static const char kMapOriginDomain[];
00331   static const char kMapProxyDomain[];
00332   static const char kMapRewriteDomain[];
00333   static const char kShardDomain[];
00335   static const char kLibrary[];
00336   static const char kUrlValuedAttribute[];
00339   static const char kCacheFlushFilename[];
00340   static const char kCacheFlushPollIntervalSec[];
00341   static const char kCompressMetadataCache[];
00342   static const char kExperimentalFetchFromModSpdy[];
00343   static const char kFetcherProxy[];
00344   static const char kFetchHttps[];
00345   static const char kFileCacheCleanInodeLimit[];
00346   static const char kFileCacheCleanIntervalMs[];
00347   static const char kFileCacheCleanSizeKb[];
00348   static const char kFileCachePath[];
00349   static const char kLogDir[];
00350   static const char kLruCacheByteLimit[];
00351   static const char kLruCacheKbPerProcess[];
00352   static const char kMemcachedServers[];
00353   static const char kMemcachedThreads[];
00354   static const char kMemcachedTimeoutUs[];
00355   static const char kRateLimitBackgroundFetches[];
00356   static const char kSlurpDirectory[];
00357   static const char kSlurpFlushLimit[];
00358   static const char kSlurpReadOnly[];
00359   static const char kSslCertDirectory[];
00360   static const char kSslCertFile[];
00361   static const char kStatisticsEnabled[];
00362   static const char kStatisticsHandlerPath[];
00363   static const char kStatisticsLoggingChartsCSS[];
00364   static const char kStatisticsLoggingChartsJS[];
00365   static const char kStatisticsLoggingEnabled[];
00366   static const char kStatisticsLoggingIntervalMs[];
00367   static const char kStatisticsLoggingMaxFileSizeKb[];
00368   static const char kTestProxy[];
00369   static const char kTestProxySlurp[];
00370   static const char kUseSharedMemLocking[];
00372   static const char kNullOption[];
00373 
00381   struct BeaconUrl {
00382     GoogleString http;
00383     GoogleString https;
00384     GoogleString http_in;
00385     GoogleString https_in;
00386   };
00387 
00388   struct NameValue {
00389     NameValue(const StringPiece& name_in, const StringPiece& value_in) {
00390       name_in.CopyToString(&name);
00391       value_in.CopyToString(&value);
00392     }
00393     GoogleString name;
00394     GoogleString value;
00395   };
00396 
00412   static const int kOptionsVersion = 13;
00413 
00415   static const int kHashBytes = 20;
00416 
00421   enum OptionScope {
00422     kDirectoryScope,  
00423     kServerScope,     
00424     kProcessScope,    
00425   };
00426 
00427   static const char kCacheExtenderId[];
00428   static const char kCollectFlushEarlyContentFilterId[];
00429   static const char kCssCombinerId[];
00430   static const char kCssFilterId[];
00431   static const char kCssImportFlattenerId[];
00432   static const char kCssInlineId[];
00433   static const char kImageCombineId[];
00434   static const char kImageCompressionId[];
00435   static const char kInPlaceRewriteId[];
00436   static const char kJavascriptCombinerId[];
00437   static const char kJavascriptInlineId[];
00438   static const char kJavascriptMinId[];
00439   static const char kLocalStorageCacheId[];
00440   static const char kPrioritizeCriticalCssId[];
00441 
00442   static const char kPanelCommentPrefix[];
00443 
00446   static const char* FilterName(Filter filter);
00447 
00450   static const char* FilterId(Filter filter);
00451 
00454   static int NumFilterIds();
00455 
00457   static const Filter kFirstFilter = kAddBaseTag;
00458 
00459   typedef EnumSet<Filter, kEndOfFilters> FilterSet;
00460   typedef std::vector<Filter> FilterVector;
00461 
00463   typedef std::set<GoogleString> FilterIdSet;
00464 
00470   static bool AddByNameToFilterSet(const StringPiece& option, FilterSet* set,
00471                                    MessageHandler* handler);
00472 
00475   typedef std::pair<StringPiece, StringPiece> OptionStringPair;
00476   typedef std::set<OptionStringPair> OptionSet;
00477 
00480   class PropertyBase {
00481    public:
00482     PropertyBase(const char* id, StringPiece option_name)
00483         : id_(id),
00484           help_text_(NULL),
00485           option_name_(option_name),
00486           scope_(kDirectoryScope),
00487           do_not_use_for_signature_computation_(false),
00488           index_(-1) {
00489     }
00490     virtual ~PropertyBase();
00491 
00494     virtual void InitializeOption(RewriteOptions* options) const = 0;
00495 
00496     void set_do_not_use_for_signature_computation(bool x) {
00497       do_not_use_for_signature_computation_ = x;
00498     }
00499     bool is_used_for_signature_computation() const {
00500       return !do_not_use_for_signature_computation_;
00501     }
00502 
00503     void set_scope(OptionScope x) { scope_ = x; }
00504     OptionScope scope() const { return scope_; }
00505 
00506     void set_help_text(const char* x) { help_text_ = x; }
00507     const char* help_text() const { return help_text_; }
00508 
00509     void set_index(int index) { index_ = index; }
00510     const char* id() const { return id_; }
00511     StringPiece option_name() const { return option_name_; }
00512     int index() const { return index_; }
00513 
00514    private:
00515     const char* id_;
00516     const char* help_text_;
00517     StringPiece option_name_; 
00518     OptionScope scope_;
00519     bool do_not_use_for_signature_computation_; 
00520     int index_;
00521 
00522     DISALLOW_COPY_AND_ASSIGN(PropertyBase);
00523   };
00524 
00525   typedef std::vector<PropertyBase*> PropertyVector;
00526 
00529   class OptionBase {
00530    public:
00531     OptionBase() {}
00532     virtual ~OptionBase();
00533 
00535     virtual bool SetFromString(const GoogleString& value_string) = 0;
00536     virtual void Merge(const OptionBase* src) = 0;
00537     virtual bool was_set() const = 0;
00538     virtual GoogleString Signature(const Hasher* hasher) const = 0;
00539     virtual GoogleString ToString() const = 0;
00540     const char* id() const { return property()->id(); }
00541     const char* help_text() const { return property()->help_text(); }
00542     OptionScope scope() const { return property()->scope(); }
00543     StringPiece option_name() const { return property()->option_name(); }
00544     bool is_used_for_signature_computation() const {
00545       return property()->is_used_for_signature_computation();
00546     }
00547     virtual const PropertyBase* property() const = 0;
00548   };
00549 
00551   typedef std::vector<OptionBase*> OptionBaseVector;
00552 
00553   enum RewriteLevel {
00558     kPassThrough,
00559 
00565     kCoreFilters,
00566 
00570     kTestingCoreFilters,
00571 
00574     kAllFilters,
00575   };
00576 
00578   enum OptionSettingResult {
00579     kOptionOk,
00580     kOptionNameUnknown,
00581     kOptionValueInvalid
00582   };
00583 
00584   static const int kDefaultBeaconReinstrumentTimeSec;
00585   static const int64 kDefaultBlinkMaxHtmlSizeRewritable;
00586   static const int64 kDefaultCssFlattenMaxBytes;
00587   static const int64 kDefaultCssImageInlineMaxBytes;
00588   static const int64 kDefaultCssInlineMaxBytes;
00589   static const int64 kDefaultCssOutlineMinBytes;
00590   static const int64 kDefaultImageInlineMaxBytes;
00591   static const int64 kDefaultJsInlineMaxBytes;
00592   static const int64 kDefaultJsOutlineMinBytes;
00593   static const int64 kDefaultProgressiveJpegMinBytes;
00594   static const int64 kDefaultMaxCacheableResponseContentLength;
00595   static const int64 kDefaultMaxHtmlCacheTimeMs;
00596   static const int64 kDefaultMaxHtmlParseBytes;
00597   static const int64 kDefaultMaxImageBytesForWebpInCss;
00598   static const int64 kDefaultMetadataInputErrorsCacheTtlMs;
00599   static const int64 kDefaultMinResourceCacheTimeToRewriteMs;
00600   static const char kDefaultDownstreamCachePurgeMethod[];
00601   static const int64 kDefaultDownstreamCacheRewrittenPercentageThreshold;
00602   static const int64 kDefaultCacheInvalidationTimestamp;
00603   static const int64 kDefaultIdleFlushTimeMs;
00604   static const int64 kDefaultFlushBufferLimitBytes;
00605   static const int64 kDefaultImplicitCacheTtlMs;
00606   static const int64 kDefaultPrioritizeVisibleContentCacheTimeMs;
00607   static const char kDefaultBeaconUrl[];
00608   static const int64 kDefaultImageRecompressQuality;
00609   static const int64 kDefaultImageJpegRecompressQuality;
00610   static const int64 kDefaultImageJpegRecompressQualityForSmallScreens;
00611   static const int kDefaultImageLimitOptimizedPercent;
00612   static const int kDefaultImageLimitRenderedAreaPercent;
00613   static const int kDefaultImageLimitResizeAreaPercent;
00614   static const int64 kDefaultImageResolutionLimitBytes;
00615   static const int64 kDefaultImageJpegNumProgressiveScans;
00616   static const int64 kDefaultImageWebpRecompressQuality;
00617   static const int64 kDefaultImageWebpRecompressQualityForSmallScreens;
00618   static const int64 kDefaultImageWebpTimeoutMs;
00619   static const int kDefaultDomainShardCount;
00620   static const int64 kDefaultBlinkHtmlChangeDetectionTimeMs;
00621   static const int kDefaultMaxPrefetchJsElements;
00622 
00625   static const int kDefaultMaxUrlSize;
00626 
00627   static const int kDefaultImageMaxRewritesAtOnce;
00628 
00633   static const int kDefaultMaxUrlSegmentSize;
00634 
00636   static const int kDefaultRewriteDeadlineMs;
00637 
00639   static const int64 kDefaultDistributedTimeoutMs;
00640 
00643   static const int kDefaultMaxInlinedPreviewImagesIndex;
00646   static const int64 kDefaultMinImageSizeLowResolutionBytes;
00649   static const int64 kDefaultMaxImageSizeLowResolutionBytes;
00651   static const int64 kDefaultFinderPropertiesCacheExpirationTimeMs;
00653   static const int64 kDefaultFinderPropertiesCacheRefreshTimeMs;
00654 
00657   static const int64 kDefaultExperimentCookieDurationMs;
00658 
00661   static const int64 kDefaultMetadataCacheStalenessThresholdMs;
00662 
00664   static const int64 kDefaultMaxCombinedJsBytes;
00665 
00666   static const int kDefaultExperimentTrafficPercent;
00668   static const int kDefaultExperimentSlot;
00669 
00670   static const char kDefaultBlockingRewriteKey[];
00671 
00672   static const char kRejectedRequestUrlKeyName[];
00673 
00674   static const int kDefaultPropertyCacheHttpStatusStabilityThreshold;
00675 
00676   static const int kDefaultMaxRewriteInfoLogSize;
00677 
00685   class ExperimentSpec {
00686    public:
00691     ExperimentSpec(const StringPiece& spec, RewriteOptions* options,
00692                    MessageHandler* handler);
00693 
00697     explicit ExperimentSpec(int id);
00698 
00699     virtual ~ExperimentSpec();
00700 
00702     virtual ExperimentSpec* Clone();
00703 
00704     bool is_valid() const { return id_ >= 0; }
00705 
00707     int id() const { return id_; }
00708     int percent() const { return percent_; }
00709     GoogleString ga_id() const { return ga_id_; }
00710     int slot() const { return ga_variable_slot_; }
00711     RewriteLevel rewrite_level() const { return rewrite_level_; }
00712     FilterSet enabled_filters() const { return enabled_filters_; }
00713     FilterSet disabled_filters() const { return disabled_filters_; }
00714     OptionSet filter_options() const { return filter_options_; }
00715     int64 css_inline_max_bytes() const { return css_inline_max_bytes_; }
00716     int64 js_inline_max_bytes() const { return js_inline_max_bytes_; }
00717     int64 image_inline_max_bytes() const { return image_inline_max_bytes_; }
00718     bool use_default() const { return use_default_; }
00719 
00720    protected:
00724     void Merge(const ExperimentSpec& spec);
00725 
00726    private:
00727     FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
00728 
00731     void Initialize(const StringPiece& spec, MessageHandler* handler);
00732 
00733     int id_; 
00734     GoogleString ga_id_; 
00735     int ga_variable_slot_;
00736     int percent_; 
00737     RewriteLevel rewrite_level_;
00738     FilterSet enabled_filters_;
00739     FilterSet disabled_filters_;
00740     OptionSet filter_options_;
00741     int64 css_inline_max_bytes_;
00742     int64 js_inline_max_bytes_;
00743     int64 image_inline_max_bytes_;
00746     bool use_default_;
00747     DISALLOW_COPY_AND_ASSIGN(ExperimentSpec);
00748   };
00749 
00751   struct ElementAttributeCategory {
00752     GoogleString element;
00753     GoogleString attribute;
00754     semantic_type::Category category;
00755   };
00756 
00763   class Properties {
00764    public:
00773     static bool Initialize(Properties** properties);
00774 
00783     static bool Terminate(Properties** properties_handle);
00784 
00786     int size() const { return property_vector_.size(); }
00787 
00788     const PropertyBase* property(int index) const {
00789       return property_vector_[index];
00790     }
00791     PropertyBase* property(int index) { return property_vector_[index]; }
00792 
00798     void Merge(Properties* properties);
00799 
00800     void push_back(PropertyBase* p) { property_vector_.push_back(p); }
00801 
00802    private:
00805     Properties();
00806     ~Properties();
00807 
00811     int initialization_count_;
00812 
00817     bool owns_properties_;
00818     PropertyVector property_vector_;
00819   };
00820 
00822   struct FilterEnumToIdAndNameEntry {
00823     RewriteOptions::Filter filter_enum;
00824     const char* filter_id;
00825     const char* filter_name;
00826   };
00827 
00828   static bool ParseRewriteLevel(const StringPiece& in, RewriteLevel* out);
00829 
00833   static bool ParseBeaconUrl(const StringPiece& in, BeaconUrl* out);
00834 
00838   bool ImageOptimizationEnabled() const;
00839 
00840   explicit RewriteOptions(ThreadSystem* thread_system);
00841   virtual ~RewriteOptions();
00842 
00846   static bool Initialize();
00847   static bool Terminate();
00848 
00849 #ifndef NDEBUG
00850 
00851 
00852 
00853 
00854 
00855 
00856   bool ModificationOK() const;
00857 
00864   bool MergeOK() const;
00865 #endif
00866 
00871   void InitializeOptions(const Properties* properties);
00872 
00873   bool modified() const { return modified_; }
00874 
00880   void SetDefaultRewriteLevel(RewriteLevel level) {
00882     level_.set_default(level);
00883   }
00884   void SetRewriteLevel(RewriteLevel level) {
00885     set_option(level, &level_);
00886   }
00887 
00889   void AddCustomFetchHeader(const StringPiece& name, const StringPiece& value);
00890 
00891   const NameValue* custom_fetch_header(int i) const {
00892     return custom_fetch_headers_[i];
00893   }
00894 
00895   int num_custom_fetch_headers() const {
00896     return custom_fetch_headers_.size();
00897   }
00898 
00901   ExperimentSpec* GetExperimentSpec(int id) const;
00902 
00906   bool AvailableExperimentId(int id);
00907 
00910   virtual bool AddExperimentSpec(const StringPiece& spec,
00911                                  MessageHandler* handler);
00912 
00920   virtual bool SetExperimentState(int id);
00921 
00925   void SetExperimentStateStr(const StringPiece& experiment_index);
00926 
00927   int experiment_id() const { return experiment_id_; }
00928 
00929   int experiment_spec_id(int i) const {
00930     return experiment_specs_[i]->id();
00931   }
00932 
00937   GoogleString GetExperimentStateStr() const;
00938 
00939   ExperimentSpec* experiment_spec(int i) const {
00940     return experiment_specs_[i];
00941   }
00942 
00943   int num_experiments() const { return experiment_specs_.size(); }
00944 
00956   void AddUrlValuedAttribute(const StringPiece& element,
00957                              const StringPiece& attribute,
00958                              semantic_type::Category category);
00959 
00962   void UrlValuedAttribute(int index,
00963                           StringPiece* element,
00964                           StringPiece* attribute,
00965                           semantic_type::Category* category) const;
00966 
00967   int num_url_valued_attributes() const {
00968     if (url_valued_attributes_ == NULL) {
00969       return 0;
00970     } else {
00971       return url_valued_attributes_->size();
00972     }
00973   }
00974 
00976   bool RegisterLibrary(
00977       uint64 bytes, StringPiece md5_hash, StringPiece canonical_url) {
00978     return WriteableJavascriptLibraryIdentification()->RegisterLibrary(
00979         bytes, md5_hash, canonical_url);
00980   }
00981 
00984   const JavascriptLibraryIdentification* javascript_library_identification()
00985       const {
00986     if (Enabled(kCanonicalizeJavascriptLibraries)) {
00987       return javascript_library_identification_.get();
00988     } else {
00989       return NULL;
00990     }
00991   }
00992 
00993   RewriteLevel level() const { return level_.value(); }
00994 
00999   bool AdjustFiltersByCommaSeparatedList(const StringPiece& filters,
01000                                          MessageHandler* handler);
01001 
01005   bool EnableFiltersByCommaSeparatedList(const StringPiece& filters,
01006                                          MessageHandler* handler);
01007 
01011   bool DisableFiltersByCommaSeparatedList(const StringPiece& filters,
01012                                           MessageHandler* handler);
01013 
01017   bool ForbidFiltersByCommaSeparatedList(const StringPiece& filters,
01018                                          MessageHandler* handler);
01019 
01021   void DisableAllFilters();
01022 
01030   void DisableAllFiltersNotExplicitlyEnabled();
01031 
01034   void DistributeFiltersByCommaSeparatedList(const StringPiece& filter_ids,
01035                                                MessageHandler* handler);
01038   void DistributeFilter(const StringPiece& filter_id);
01039 
01042   bool Distributable(const StringPiece& filter_id) const;
01043 
01047   void EnableFilter(Filter filter);
01050   void ForceEnableFilter(Filter filter);
01051   void DisableFilter(Filter filter);
01052   void ForbidFilter(Filter filter);
01053   void EnableFilters(const FilterSet& filter_set);
01054   void DisableFilters(const FilterSet& filter_set);
01055   void ForbidFilters(const FilterSet& filter_set);
01058   void ClearFilters();
01059 
01062   void EnableExtendCacheFilters();
01063 
01064   bool Enabled(Filter filter) const;
01065   bool Forbidden(Filter filter) const;
01066   bool Forbidden(StringPiece filter_id) const;
01067 
01069   void GetEnabledFiltersRequiringScriptExecution(FilterVector* filters) const;
01070 
01072   void DisableFiltersRequiringScriptExecution();
01073 
01078   static bool AddCommaSeparatedListToOptionSet(
01079       const StringPiece& options, OptionSet* set, MessageHandler* handler);
01080 
01085   OptionSettingResult SetOptionFromName(
01086       StringPiece name, StringPiece value, GoogleString* msg);
01087 
01092   virtual OptionSettingResult ParseAndSetOptionFromName1(
01093       StringPiece name, StringPiece arg,
01094       GoogleString* msg, MessageHandler* handler);
01095 
01096   virtual OptionSettingResult ParseAndSetOptionFromName2(
01097       StringPiece name, StringPiece arg1, StringPiece arg2,
01098       GoogleString* msg, MessageHandler* handler);
01099 
01100   virtual OptionSettingResult ParseAndSetOptionFromName3(
01101       StringPiece name, StringPiece arg1, StringPiece arg2, StringPiece arg3,
01102       GoogleString* msg, MessageHandler* handler);
01103 
01108   OptionSettingResult SetOptionFromName(StringPiece name, StringPiece value);
01109 
01115   bool OptionValue(StringPiece option_name, const char** id,
01116                    bool* was_set, GoogleString* value) const;
01117 
01120   bool SetOptionsFromName(const OptionSet& option_set);
01121 
01124   bool SetOptionFromNameAndLog(StringPiece name,
01125                                StringPiece value,
01126                                MessageHandler* handler);
01127 
01130   static bool ParseFromString(const GoogleString& value_string, bool* value);
01131   static bool ParseFromString(const GoogleString& value_string,
01132                               EnabledEnum* value);
01133   static bool ParseFromString(const GoogleString& value_string, int* value) {
01134     return StringToInt(value_string, value);
01135   }
01136   static bool ParseFromString(const GoogleString& value_string, int64* value) {
01137     return StringToInt64(value_string, value);
01138   }
01139   static bool ParseFromString(const GoogleString& value_string,
01140                               GoogleString* value) {
01141     *value = value_string;
01142     return true;
01143   }
01144   static bool ParseFromString(const GoogleString& value_string,
01145                               RewriteLevel* value) {
01146     return ParseRewriteLevel(value_string, value);
01147   }
01148   static bool ParseFromString(const GoogleString& value_string,
01149                               BeaconUrl* value) {
01150     return ParseBeaconUrl(value_string, value);
01151   }
01152 
01155   int64 css_outline_min_bytes() const { return css_outline_min_bytes_.value(); }
01156   void set_css_outline_min_bytes(int64 x) {
01157     set_option(x, &css_outline_min_bytes_);
01158   }
01159 
01160   GoogleString ga_id() const { return ga_id_.value(); }
01161   void set_ga_id(GoogleString id) {
01162     set_option(id, &ga_id_);
01163   }
01164 
01165   bool increase_speed_tracking() const {
01166     return increase_speed_tracking_.value();
01167   }
01168   void set_increase_speed_tracking(bool x) {
01169     set_option(x, &increase_speed_tracking_);
01170   }
01171 
01172   int64 js_outline_min_bytes() const { return js_outline_min_bytes_.value(); }
01173   void set_js_outline_min_bytes(int64 x) {
01174     set_option(x, &js_outline_min_bytes_);
01175   }
01176 
01177   int64 progressive_jpeg_min_bytes() const {
01178     return progressive_jpeg_min_bytes_.value();
01179   }
01180   void set_progressive_jpeg_min_bytes(int64 x) {
01181     set_option(x, &progressive_jpeg_min_bytes_);
01182   }
01183 
01184   int64 css_flatten_max_bytes() const { return css_flatten_max_bytes_.value(); }
01185   void set_css_flatten_max_bytes(int64 x) {
01186     set_option(x, &css_flatten_max_bytes_);
01187   }
01188   bool cache_small_images_unrewritten() const {
01189     return cache_small_images_unrewritten_.value();
01190   }
01191   void set_cache_small_images_unrewritten(bool x) {
01192     set_option(x, &cache_small_images_unrewritten_);
01193   }
01194   int64 image_resolution_limit_bytes() const {
01195     return image_resolution_limit_bytes_.value();
01196   }
01197   void set_image_resolution_limit_bytes(int64 x) {
01198     set_option(x, &image_resolution_limit_bytes_);
01199   }
01200 
01202   int64 ImageInlineMaxBytes() const;
01203   void set_image_inline_max_bytes(int64 x);
01205   int64 CssImageInlineMaxBytes() const;
01206   void set_css_image_inline_max_bytes(int64 x) {
01207     set_option(x, &css_image_inline_max_bytes_);
01208   }
01210   int64 MaxImageInlineMaxBytes() const;
01211   int64 css_inline_max_bytes() const { return css_inline_max_bytes_.value(); }
01212   void set_css_inline_max_bytes(int64 x) {
01213     set_option(x, &css_inline_max_bytes_);
01214   }
01215   int64 js_inline_max_bytes() const { return js_inline_max_bytes_.value(); }
01216   void set_js_inline_max_bytes(int64 x) {
01217     set_option(x, &js_inline_max_bytes_);
01218   }
01219   int64 max_html_cache_time_ms() const {
01220     return max_html_cache_time_ms_.value();
01221   }
01222   void set_max_html_cache_time_ms(int64 x) {
01223     set_option(x, &max_html_cache_time_ms_);
01224   }
01225   int64 max_html_parse_bytes() const {
01226     return max_html_parse_bytes_.value();
01227   }
01228   void set_max_html_parse_bytes(int64 x) {
01229     set_option(x, &max_html_parse_bytes_);
01230   }
01231   int64 max_image_bytes_for_webp_in_css() const {
01232     return max_image_bytes_for_webp_in_css_.value();
01233   }
01234   void set_max_image_bytes_for_webp_in_css(int64 x) {
01235     set_option(x, &max_image_bytes_for_webp_in_css_);
01236   }
01237   int64 max_cacheable_response_content_length() const {
01238     return max_cacheable_response_content_length_.value();
01239   }
01240   void set_max_cacheable_response_content_length(int64 x) {
01241     set_option(x, &max_cacheable_response_content_length_);
01242   }
01243   int64 min_resource_cache_time_to_rewrite_ms() const {
01244     return min_resource_cache_time_to_rewrite_ms_.value();
01245   }
01246   void set_min_resource_cache_time_to_rewrite_ms(int64 x) {
01247     set_option(x, &min_resource_cache_time_to_rewrite_ms_);
01248   }
01249   bool need_to_store_experiment_data() const {
01250     return need_to_store_experiment_data_;
01251   }
01252   void set_need_to_store_experiment_data(bool x) {
01253     need_to_store_experiment_data_ = x;
01254   }
01255 
01256   int64 blocking_fetch_timeout_ms() const {
01257     return blocking_fetch_timeout_ms_.value();
01258   }
01259   void set_blocking_fetch_timeout_ms(int64 x) {
01260     set_option(x, &blocking_fetch_timeout_ms_);
01261   }
01262   bool override_ie_document_mode() const {
01263     return override_ie_document_mode_.value();
01264   }
01265   void set_override_ie_document_mode(bool x) {
01266     set_option(x, &override_ie_document_mode_);
01267   }
01268 
01269   int64 blink_blacklist_end_timestamp_ms() const {
01270     return blink_blacklist_end_timestamp_ms_.value();
01271   }
01272   void set_blink_blacklist_end_timestamp_ms(int64 x) {
01273     set_option(x, &blink_blacklist_end_timestamp_ms_);
01274   }
01275 
01276   bool persist_blink_blacklist() const {
01277     return persist_blink_blacklist_.value();
01278   }
01279   void set_persist_blink_blacklist(bool x) {
01280     set_option(x, &persist_blink_blacklist_);
01281   }
01282 
01286   bool IsUrlCacheValid(StringPiece url, int64 time_ms) const;
01287 
01291   bool IsUrlPurged(StringPiece url, int64 time_ms) const;
01292 
01309   void AddUrlCacheInvalidationEntry(StringPiece url_pattern,
01310                                     int64 timestamp_ms,
01311                                     bool ignores_metadata_and_pcache);
01312 
01314   void PurgeUrl(StringPiece url, int64 timestamp_ms);
01315 
01318   bool IsUrlCacheInvalidationEntriesSorted() const;
01319 
01322   void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock* lock) {
01323     cache_invalidation_timestamp_.set_mutex(lock);
01324   }
01325 
01327   int64 cache_invalidation_timestamp() const {
01328     ThreadSystem::ScopedReader lock(cache_invalidation_timestamp_.mutex());
01329     return cache_invalidation_timestamp_.value();
01330   }
01331 
01338   void set_cache_invalidation_timestamp(int64 timestamp_ms) {
01339     cache_invalidation_timestamp_.mutex()->DCheckLocked();
01340     DCHECK_LT(0, timestamp_ms);
01341     set_option(timestamp_ms, &cache_invalidation_timestamp_);
01342   }
01343 
01350   bool UpdateCacheInvalidationTimestampMs(int64 timestamp_ms);
01351 
01354   int64 idle_flush_time_ms() const {
01355     return idle_flush_time_ms_.value();
01356   }
01357   void set_idle_flush_time_ms(int64 x) {
01358     set_option(x, &idle_flush_time_ms_);
01359   }
01360 
01362   int64 flush_buffer_limit_bytes() const {
01363     return flush_buffer_limit_bytes_.value();
01364   }
01365 
01366   void set_flush_buffer_limit_bytes(int64 x) {
01367     set_option(x, &flush_buffer_limit_bytes_);
01368   }
01369 
01372   int max_url_segment_size() const { return max_url_segment_size_.value(); }
01373   void set_max_url_segment_size(int x) {
01374     set_option(x, &max_url_segment_size_);
01375   }
01376 
01377   int image_max_rewrites_at_once() const {
01378     return image_max_rewrites_at_once_.value();
01379   }
01380   void set_image_max_rewrites_at_once(int x) {
01381     set_option(x, &image_max_rewrites_at_once_);
01382   }
01383 
01385   int max_url_size() const { return max_url_size_.value(); }
01386   void set_max_url_size(int x) {
01387     set_option(x, &max_url_size_);
01388   }
01389 
01390   int rewrite_deadline_ms() const { return rewrite_deadline_ms_.value(); }
01391   void set_rewrite_deadline_ms(int x) {
01392     set_option(x, &rewrite_deadline_ms_);
01393   }
01394 
01395   bool test_instant_fetch_rewrite_deadline() const {
01396     return test_instant_fetch_rewrite_deadline_.value();
01397   }
01398   void set_test_instant_fetch_rewrite_deadline(bool x) {
01399     set_option(x, &test_instant_fetch_rewrite_deadline_);
01400   }
01401 
01402   void set_test_only_prioritize_critical_css_dont_apply_original_css(bool x) {
01403     set_option(x, &test_only_prioritize_critical_css_dont_apply_original_css_);
01404   }
01405   bool test_only_prioritize_critical_css_dont_apply_original_css() const {
01406     return test_only_prioritize_critical_css_dont_apply_original_css_.value();
01407   }
01408 
01409   int domain_shard_count() const { return domain_shard_count_.value(); }
01412   void set_domain_shard_count(int64 x) {
01413     int value = x;
01414     set_option(value, &domain_shard_count_);
01415   }
01416 
01417   void set_enabled(EnabledEnum x) {
01418     set_option(x, &enabled_);
01419   }
01420   bool enabled() const {
01421     return enabled_.value() == kEnabledOn;
01422   }
01423   bool unplugged() const {
01424     return enabled_.value() == kEnabledUnplugged;
01425   }
01426 
01427   void set_add_options_to_urls(bool x) {
01428     set_option(x, &add_options_to_urls_);
01429   }
01430 
01431   bool add_options_to_urls() const {
01432     return add_options_to_urls_.value();
01433   }
01434 
01435   void set_in_place_rewriting_enabled(bool x) {
01436     set_option(x, &in_place_rewriting_enabled_);
01437   }
01438 
01439   void set_oblivious_pagespeed_urls(bool x) {
01440     set_option(x, &oblivious_pagespeed_urls_);
01441   }
01442 
01443   bool oblivious_pagespeed_urls() const {
01444     return oblivious_pagespeed_urls_.value();
01445   }
01446 
01447   bool in_place_rewriting_enabled() const {
01448     return in_place_rewriting_enabled_.value();
01449   }
01450 
01451   void set_in_place_wait_for_optimized(bool x) {
01452     set_option(x, &in_place_wait_for_optimized_);
01453   }
01454 
01455   bool in_place_wait_for_optimized() const {
01456     return in_place_wait_for_optimized_.value();
01457   }
01458 
01459   void set_in_place_rewrite_deadline_ms(int x) {
01460     set_option(x, &in_place_rewrite_deadline_ms_);
01461   }
01462 
01463   int in_place_rewrite_deadline_ms() const {
01464     return in_place_rewrite_deadline_ms_.value();
01465   }
01466 
01467   void set_in_place_preemptive_rewrite_css(bool x) {
01468     set_option(x, &in_place_preemptive_rewrite_css_);
01469   }
01470   bool in_place_preemptive_rewrite_css() const {
01471     return in_place_preemptive_rewrite_css_.value();
01472   }
01473 
01474   void set_in_place_preemptive_rewrite_css_images(bool x) {
01475     set_option(x, &in_place_preemptive_rewrite_css_images_);
01476   }
01477   bool in_place_preemptive_rewrite_css_images() const {
01478     return in_place_preemptive_rewrite_css_images_.value();
01479   }
01480 
01481   void set_in_place_preemptive_rewrite_images(bool x) {
01482     set_option(x, &in_place_preemptive_rewrite_images_);
01483   }
01484   bool in_place_preemptive_rewrite_images() const {
01485     return in_place_preemptive_rewrite_images_.value();
01486   }
01487 
01488   void set_in_place_preemptive_rewrite_javascript(bool x) {
01489     set_option(x, &in_place_preemptive_rewrite_javascript_);
01490   }
01491   bool in_place_preemptive_rewrite_javascript() const {
01492     return in_place_preemptive_rewrite_javascript_.value();
01493   }
01494 
01495   void set_combine_across_paths(bool x) {
01496     set_option(x, &combine_across_paths_);
01497   }
01498   bool combine_across_paths() const { return combine_across_paths_.value(); }
01499 
01500   void set_log_background_rewrites(bool x) {
01501     set_option(x, &log_background_rewrites_);
01502   }
01503   bool log_background_rewrites() const {
01504     return log_background_rewrites_.value();
01505   }
01506 
01507   void set_log_rewrite_timing(bool x) {
01508     set_option(x, &log_rewrite_timing_);
01509   }
01510   bool log_rewrite_timing() const { return log_rewrite_timing_.value(); }
01511 
01512   void set_log_url_indices(bool x) {
01513     set_option(x, &log_url_indices_);
01514   }
01515   bool log_url_indices() const { return log_url_indices_.value(); }
01516 
01517   void set_lowercase_html_names(bool x) {
01518     set_option(x, &lowercase_html_names_);
01519   }
01520   bool lowercase_html_names() const { return lowercase_html_names_.value(); }
01521 
01522   void set_always_rewrite_css(bool x) {
01523     set_option(x, &always_rewrite_css_);
01524   }
01525   bool always_rewrite_css() const { return always_rewrite_css_.value(); }
01526 
01527   void set_respect_vary(bool x) {
01528     set_option(x, &respect_vary_);
01529   }
01530   bool respect_vary() const { return respect_vary_.value(); }
01531 
01532   void set_respect_x_forwarded_proto(bool x) {
01533     set_option(x, &respect_x_forwarded_proto_);
01534   }
01535   bool respect_x_forwarded_proto() const {
01536     return respect_x_forwarded_proto_.value();
01537   }
01538 
01539   void set_flush_html(bool x) { set_option(x, &flush_html_); }
01540   bool flush_html() const { return flush_html_.value(); }
01541 
01542   void set_serve_split_html_in_two_chunks(bool x) {
01543     set_option(x, &serve_split_html_in_two_chunks_);
01544   }
01545   bool serve_split_html_in_two_chunks() const {
01546     return serve_split_html_in_two_chunks_.value();
01547   }
01548 
01549   void set_serve_stale_if_fetch_error(bool x) {
01550     set_option(x, &serve_stale_if_fetch_error_);
01551   }
01552   bool serve_stale_if_fetch_error() const {
01553     return serve_stale_if_fetch_error_.value();
01554   }
01555 
01556   void set_serve_ghost_click_buster_with_split_html(bool x) {
01557     set_option(x, &serve_ghost_click_buster_with_split_html_);
01558   }
01559   bool serve_ghost_click_buster_with_split_html() const {
01560     return serve_ghost_click_buster_with_split_html_.value();
01561   }
01562 
01563   void set_serve_xhr_access_control_headers(bool x) {
01564     set_option(x, &serve_xhr_access_control_headers_);
01565   }
01566   bool serve_xhr_access_control_headers() const {
01567     return serve_xhr_access_control_headers_.value();
01568   }
01569 
01570   void set_proactively_freshen_user_facing_request(bool x) {
01571     set_option(x, &proactively_freshen_user_facing_request_);
01572   }
01573   bool proactively_freshen_user_facing_request() const {
01574     return proactively_freshen_user_facing_request_.value();
01575   }
01576 
01577   void set_serve_stale_while_revalidate_threshold_sec(int64 x) {
01578     set_option(x, &serve_stale_while_revalidate_threshold_sec_);
01579   }
01580   int64 serve_stale_while_revalidate_threshold_sec() const {
01581     return serve_stale_while_revalidate_threshold_sec_.value();
01582   }
01583 
01584   void set_enable_flush_early_critical_css(bool x) {
01585     set_option(x, &enable_flush_early_critical_css_);
01586   }
01587   bool enable_flush_early_critical_css() const {
01588     return enable_flush_early_critical_css_.value();
01589   }
01590 
01591   void set_default_cache_html(bool x) { set_option(x, &default_cache_html_); }
01592   bool default_cache_html() const { return default_cache_html_.value(); }
01593 
01594   void set_modify_caching_headers(bool x) {
01595     set_option(x, &modify_caching_headers_);
01596   }
01597   bool modify_caching_headers() const {
01598     return modify_caching_headers_.value();
01599   }
01600 
01601   void set_inline_only_critical_images(bool x) {
01602     set_option(x, &inline_only_critical_images_);
01603   }
01604   bool inline_only_critical_images() const {
01605     return inline_only_critical_images_.value();
01606   }
01607 
01608   void set_critical_images_beacon_enabled(bool x) {
01609     set_option(x, &critical_images_beacon_enabled_);
01610   }
01611   bool critical_images_beacon_enabled() const {
01612     return critical_images_beacon_enabled_.value();
01613   }
01614 
01615   void set_beacon_reinstrument_beacon_time_sec(int x) {
01616     set_option(x, &beacon_reinstrument_time_sec_);
01617   }
01618   int beacon_reinstrument_time_sec() const {
01619     return beacon_reinstrument_time_sec_.value();
01620   }
01621 
01622   void set_lazyload_images_after_onload(bool x) {
01623     set_option(x, &lazyload_images_after_onload_);
01624   }
01625   bool lazyload_images_after_onload() const {
01626     return lazyload_images_after_onload_.value();
01627   }
01628 
01629   void set_lazyload_images_blank_url(const StringPiece& p) {
01630     set_option(GoogleString(p.data(), p.size()), &lazyload_images_blank_url_);
01631   }
01632   const GoogleString& lazyload_images_blank_url() const {
01633     return lazyload_images_blank_url_.value();
01634   }
01635 
01636   void set_max_inlined_preview_images_index(int x) {
01637     set_option(x, &max_inlined_preview_images_index_);
01638   }
01639   int max_inlined_preview_images_index() const {
01640     return max_inlined_preview_images_index_.value();
01641   }
01642 
01643   void set_use_blank_image_for_inline_preview(bool x) {
01644     set_option(x, &use_blank_image_for_inline_preview_);
01645   }
01646   bool use_blank_image_for_inline_preview() const {
01647     return use_blank_image_for_inline_preview_.value();
01648   }
01649 
01650   void set_min_image_size_low_resolution_bytes(int64 x) {
01651     set_option(x, &min_image_size_low_resolution_bytes_);
01652   }
01653   int64 min_image_size_low_resolution_bytes() const {
01654     return min_image_size_low_resolution_bytes_.value();
01655   }
01656 
01657   void set_max_image_size_low_resolution_bytes(int64 x) {
01658     set_option(x, &max_image_size_low_resolution_bytes_);
01659   }
01660   int64 max_image_size_low_resolution_bytes() const {
01661     return max_image_size_low_resolution_bytes_.value();
01662   }
01663 
01664   void set_experiment_cookie_duration_ms(int64 x) {
01665     set_option(x, &experiment_cookie_duration_ms_);
01666   }
01667   int64 experiment_cookie_duration_ms() const {
01668     return experiment_cookie_duration_ms_.value();
01669   }
01670 
01671   void set_finder_properties_cache_expiration_time_ms(int64 x) {
01672     set_option(x, &finder_properties_cache_expiration_time_ms_);
01673   }
01674   int64 finder_properties_cache_expiration_time_ms() const {
01675     return finder_properties_cache_expiration_time_ms_.value();
01676   }
01677 
01678   void set_finder_properties_cache_refresh_time_ms(int64 x) {
01679     set_option(x, &finder_properties_cache_refresh_time_ms_);
01680   }
01681   int64 finder_properties_cache_refresh_time_ms() const {
01682     return finder_properties_cache_refresh_time_ms_.value();
01683   }
01684 
01685   void set_rewrite_random_drop_percentage(int x) {
01686     set_option(x, &rewrite_random_drop_percentage_);
01687   }
01688   int rewrite_random_drop_percentage() const {
01689     return rewrite_random_drop_percentage_.value();
01690   }
01691 
01692   bool css_preserve_urls() const {
01693     return css_preserve_urls_.value();
01694   }
01695   void set_css_preserve_urls(bool x) {
01696     set_option(x, &css_preserve_urls_);
01697   }
01698 
01699   bool image_preserve_urls() const {
01700     return image_preserve_urls_.value();
01701   }
01702   void set_image_preserve_urls(bool x) {
01703     set_option(x, &image_preserve_urls_);
01704   }
01705 
01706   bool js_preserve_urls() const {
01707     return js_preserve_urls_.value();
01708   }
01709   void set_js_preserve_urls(bool x) {
01710     set_option(x, &js_preserve_urls_);
01711   }
01712 
01713   bool rewrite_request_urls_early() const {
01714     return rewrite_request_urls_early_.value();
01715   }
01716   void set_rewrite_request_urls_early(bool x) {
01717     set_option(x, &rewrite_request_urls_early_);
01718   }
01719 
01720   void set_metadata_cache_staleness_threshold_ms(int64 x) {
01721     set_option(x, &metadata_cache_staleness_threshold_ms_);
01722   }
01723   int64 metadata_cache_staleness_threshold_ms() const {
01724     return metadata_cache_staleness_threshold_ms_.value();
01725   }
01726 
01727   void set_metadata_input_errors_cache_ttl_ms(int64 x) {
01728     set_option(x, &metadata_input_errors_cache_ttl_ms_);
01729   }
01730   int64 metadata_input_errors_cache_ttl_ms() const {
01731     return metadata_input_errors_cache_ttl_ms_.value();
01732   }
01733 
01734   void set_downstream_cache_lifetime_ms(int64 x) {
01735     set_option(x, &downstream_cache_lifetime_ms_);
01736   }
01737   int64 downstream_cache_lifetime_ms() const {
01738     return downstream_cache_lifetime_ms_.value();
01739   }
01740 
01741   const GoogleString& downstream_cache_purge_method() const {
01742     return downstream_cache_purge_method_.value();
01743   }
01744   void set_downstream_cache_purge_method(const StringPiece& p) {
01745     set_option(p.as_string(), &downstream_cache_purge_method_);
01746   }
01747 
01748   const GoogleString& downstream_cache_purge_location_prefix() const {
01749     return downstream_cache_purge_location_prefix_.value();
01750   }
01751   void set_downstream_cache_purge_location_prefix(const StringPiece& p) {
01752     set_option(p.as_string(), &downstream_cache_purge_location_prefix_);
01753   }
01754 
01755   void set_downstream_cache_rewritten_percentage_threshold(int64 x) {
01756     set_option(x, &downstream_cache_rewritten_percentage_threshold_);
01757   }
01758   int64 downstream_cache_rewritten_percentage_threshold() const {
01759     return downstream_cache_rewritten_percentage_threshold_.value();
01760   }
01761 
01762   const BeaconUrl& beacon_url() const { return beacon_url_.value(); }
01763   void set_beacon_url(const GoogleString& beacon_url) {
01764     beacon_url_.SetFromString(beacon_url);
01765   }
01766 
01768   virtual bool trim_urls_in_css() const { return true; }
01769 
01770   int64 image_jpeg_recompress_quality() const {
01771     return image_jpeg_recompress_quality_.value();
01772   }
01773   void set_image_jpeg_recompress_quality(int64 x) {
01774     set_option(x, &image_jpeg_recompress_quality_);
01775   }
01776 
01777   int64 image_jpeg_recompress_quality_for_small_screens() const {
01778     return image_jpeg_recompress_quality_for_small_screens_.value();
01779   }
01780   void set_image_jpeg_recompress_quality_for_small_screens(int64 x) {
01781     set_option(x, &image_jpeg_recompress_quality_for_small_screens_);
01782   }
01783 
01784   int64 image_recompress_quality() const {
01785     return image_recompress_quality_.value();
01786   }
01787   void set_image_recompress_quality(int64 x) {
01788     set_option(x, &image_recompress_quality_);
01789   }
01790 
01791   int image_limit_optimized_percent() const {
01792     return image_limit_optimized_percent_.value();
01793   }
01794   void set_image_limit_optimized_percent(int x) {
01795     set_option(x, &image_limit_optimized_percent_);
01796   }
01797   int image_limit_resize_area_percent() const {
01798     return image_limit_resize_area_percent_.value();
01799   }
01800   void set_image_limit_resize_area_percent(int x) {
01801     set_option(x, &image_limit_resize_area_percent_);
01802   }
01803 
01804   int image_limit_rendered_area_percent() const {
01805     return image_limit_rendered_area_percent_.value();
01806   }
01807   void set_image_limit_rendered_area_percent(int x) {
01808     set_option(x, &image_limit_rendered_area_percent_);
01809   }
01810 
01811   int64 image_jpeg_num_progressive_scans() const {
01812     return image_jpeg_num_progressive_scans_.value();
01813   }
01814   void set_image_jpeg_num_progressive_scans(int64 x) {
01815     set_option(x, &image_jpeg_num_progressive_scans_);
01816   }
01817 
01818   int64 image_jpeg_num_progressive_scans_for_small_screens() const {
01819     return image_jpeg_num_progressive_scans_for_small_screens_.value();
01820   }
01821   void set_image_jpeg_num_progressive_scans_for_small_screens(int64 x) {
01822     set_option(x, &image_jpeg_num_progressive_scans_for_small_screens_);
01823   }
01824 
01825   int64 image_webp_recompress_quality() const {
01826     return image_webp_recompress_quality_.value();
01827   }
01828   void set_image_webp_recompress_quality(int64 x) {
01829     set_option(x, &image_webp_recompress_quality_);
01830   }
01831 
01832   int64 image_webp_recompress_quality_for_small_screens() const {
01833     return image_webp_recompress_quality_for_small_screens_.value();
01834   }
01835   void set_image_webp_recompress_quality_for_small_screens(int64 x) {
01836     set_option(x, &image_webp_recompress_quality_for_small_screens_);
01837   }
01838   int64 image_webp_timeout_ms() const {
01839     return image_webp_timeout_ms_.value();
01840   }
01841   void set_image_webp_timeout_ms(int64 x) {
01842     set_option(x, &image_webp_timeout_ms_);
01843   }
01844 
01845   bool domain_rewrite_hyperlinks() const {
01846     return domain_rewrite_hyperlinks_.value();
01847   }
01848   void set_domain_rewrite_hyperlinks(bool x) {
01849     set_option(x, &domain_rewrite_hyperlinks_);
01850   }
01851 
01852   bool client_domain_rewrite() const {
01853     return client_domain_rewrite_.value();
01854   }
01855   void set_client_domain_rewrite(bool x) {
01856     set_option(x, &client_domain_rewrite_);
01857   }
01858 
01859   void set_flush_more_resources_early_if_time_permits(bool x) {
01860     set_option(x, &flush_more_resources_early_if_time_permits_);
01861   }
01862   bool flush_more_resources_early_if_time_permits() const {
01863     return flush_more_resources_early_if_time_permits_.value();
01864   }
01865 
01866   void set_flush_more_resources_in_ie_and_firefox(bool x) {
01867     set_option(x, &flush_more_resources_in_ie_and_firefox_);
01868   }
01869   bool flush_more_resources_in_ie_and_firefox() const {
01870     return flush_more_resources_in_ie_and_firefox_.value();
01871   }
01872 
01873   void set_max_prefetch_js_elements(int x) {
01874     set_option(x, &max_prefetch_js_elements_);
01875   }
01876   int max_prefetch_js_elements() const {
01877     return max_prefetch_js_elements_.value();
01878   }
01879 
01880   void set_enable_defer_js_experimental(bool x) {
01881     set_option(x, &enable_defer_js_experimental_);
01882   }
01883   bool enable_defer_js_experimental() const {
01884     return enable_defer_js_experimental_.value();
01885   }
01886 
01887   void set_disable_rewrite_on_no_transform(bool x) {
01888     set_option(x, &disable_rewrite_on_no_transform_);
01889   }
01890   bool disable_rewrite_on_no_transform() const {
01891     return disable_rewrite_on_no_transform_.value();
01892   }
01893 
01894   void set_enable_cache_purge(bool x) {
01895     set_option(x, &enable_cache_purge_);
01896   }
01897   bool enable_cache_purge() const {
01898     return enable_cache_purge_.value();
01899   }
01900 
01901   void set_lazyload_highres_images(bool x) {
01902     set_option(x, &lazyload_highres_images_);
01903   }
01904   bool lazyload_highres_images() const {
01905     return lazyload_highres_images_.value();
01906   }
01907 
01908   void set_enable_blink_debug_dashboard(bool x) {
01909     set_option(x, &enable_blink_debug_dashboard_);
01910   }
01911   bool enable_blink_debug_dashboard() const {
01912     return enable_blink_debug_dashboard_.value();
01913   }
01914 
01915   void set_enable_blink_html_change_detection(bool x) {
01916     set_option(x, &enable_blink_html_change_detection_);
01917   }
01918   bool enable_blink_html_change_detection() const {
01919     return enable_blink_html_change_detection_.value();
01920   }
01921 
01922   void set_enable_blink_html_change_detection_logging(bool x) {
01923     set_option(x, &enable_blink_html_change_detection_logging_);
01924   }
01925   bool enable_blink_html_change_detection_logging() const {
01926     return enable_blink_html_change_detection_logging_.value();
01927   }
01928 
01929   void set_use_smart_diff_in_blink(bool x) {
01930     set_option(x, &use_smart_diff_in_blink_);
01931   }
01932   bool use_smart_diff_in_blink() const {
01933     return use_smart_diff_in_blink_.value();
01934   }
01935 
01936   void set_use_fallback_property_cache_values(bool x) {
01937     set_option(x, &use_fallback_property_cache_values_);
01938   }
01939   bool use_fallback_property_cache_values() const {
01940     return use_fallback_property_cache_values_.value();
01941   }
01942 
01943   void set_enable_prioritizing_scripts(bool x) {
01944     set_option(x, &enable_prioritizing_scripts_);
01945   }
01946   bool enable_prioritizing_scripts() const {
01947     return enable_prioritizing_scripts_.value();
01948   }
01949 
01950   void set_blink_html_change_detection_time_ms(int64 x) {
01951     set_option(x, &blink_html_change_detection_time_ms_);
01952   }
01953   int64 blink_html_change_detection_time_ms() const {
01954     return blink_html_change_detection_time_ms_.value();
01955   }
01956 
01957   const GoogleString& blocking_rewrite_key() const {
01958     return blocking_rewrite_key_.value();
01959   }
01960   void set_blocking_rewrite_key(const StringPiece& p) {
01961     set_option(p.as_string(), &blocking_rewrite_key_);
01962   }
01963 
01964   void EnableBlockingRewriteForRefererUrlPattern(
01965       const StringPiece& url_pattern) {
01966     Modify();
01967     blocking_rewrite_referer_urls_.Allow(url_pattern);
01968   }
01969 
01970   bool IsBlockingRewriteEnabledForReferer(const StringPiece& url) const {
01971     return blocking_rewrite_referer_urls_.Match(url, false);
01972   }
01973 
01974   bool IsBlockingRewriteRefererUrlPatternPresent() const {
01975     return blocking_rewrite_referer_urls_.num_wildcards() > 0;
01976   }
01977 
01978   bool rewrite_uncacheable_resources() const {
01979     return rewrite_uncacheable_resources_.value();
01980   }
01981 
01982   void set_rewrite_uncacheable_resources(bool x) {
01983     set_option(x, &rewrite_uncacheable_resources_);
01984   }
01985 
01986   void set_running_experiment(bool x) {
01987     set_option(x, &running_experiment_);
01988   }
01989   bool running_experiment() const {
01990     return running_experiment_.value();
01991   }
01992 
01994   void set_experiment_ga_slot(int x) {
01995     set_option(x, &experiment_ga_slot_);
01996   }
01997 
01998   int experiment_ga_slot() const { return experiment_ga_slot_.value(); }
01999 
02000   void set_report_unload_time(bool x) {
02001     set_option(x, &report_unload_time_);
02002   }
02003   bool report_unload_time() const {
02004     return report_unload_time_.value();
02005   }
02006 
02007   void set_implicit_cache_ttl_ms(int64 x) {
02008     set_option(x, &implicit_cache_ttl_ms_);
02009   }
02010   int64 implicit_cache_ttl_ms() const {
02011     return implicit_cache_ttl_ms_.value();
02012   }
02013 
02014   void set_x_header_value(const StringPiece& p) {
02015     set_option(p.as_string(), &x_header_value_);
02016   }
02017   const GoogleString& x_header_value() const {
02018     return x_header_value_.value();
02019   }
02020 
02021   void set_distributed_rewrite_key(const StringPiece& p) {
02022       set_option(p.as_string(), &distributed_rewrite_key_);
02023   }
02024   const GoogleString& distributed_rewrite_key() const {
02025     return distributed_rewrite_key_.value();
02026   }
02027 
02028   void set_distributed_rewrite_servers(const StringPiece& p) {
02029       set_option(p.as_string(), &distributed_rewrite_servers_);
02030   }
02031   const GoogleString& distributed_rewrite_servers() const {
02032     return distributed_rewrite_servers_.value();
02033   }
02034 
02035   void set_distributed_rewrite_timeout_ms(const int64 x) {
02036     set_option(x, &distributed_rewrite_timeout_ms_);
02037   }
02038   int64 distributed_rewrite_timeout_ms() const {
02039     return distributed_rewrite_timeout_ms_.value();
02040   }
02041 
02042   void set_avoid_renaming_introspective_javascript(bool x) {
02043     set_option(x, &avoid_renaming_introspective_javascript_);
02044   }
02045   bool avoid_renaming_introspective_javascript() const {
02046     return avoid_renaming_introspective_javascript_.value();
02047   }
02048 
02049   int64 blink_max_html_size_rewritable() const {
02050     return blink_max_html_size_rewritable_.value();
02051   }
02052   void set_blink_max_html_size_rewritable(int64 x) {
02053     set_option(x, &blink_max_html_size_rewritable_);
02054   }
02055 
02056   void set_critical_line_config(const StringPiece& p) {
02057       set_option(GoogleString(p.data(), p.size()), &critical_line_config_);
02058   }
02059   const GoogleString& critical_line_config() const {
02060     return critical_line_config_.value();
02061   }
02062 
02063   void set_forbid_all_disabled_filters(bool x) {
02064     set_option(x, &forbid_all_disabled_filters_);
02065   }
02066   bool forbid_all_disabled_filters() const {
02067     return forbid_all_disabled_filters_.value();
02068   }
02069 
02070   bool reject_blacklisted() const { return reject_blacklisted_.value(); }
02071   void set_reject_blacklisted(bool x) {
02072     set_option(x, &reject_blacklisted_);
02073   }
02074 
02075   HttpStatus::Code reject_blacklisted_status_code() const {
02076     return static_cast<HttpStatus::Code>(
02077         reject_blacklisted_status_code_.value());
02078   }
02079   void set_reject_blacklisted_status_code(HttpStatus::Code x) {
02080     set_option(static_cast<int>(x), &reject_blacklisted_status_code_);
02081   }
02082 
02083   bool support_noscript_enabled() const {
02084     return support_noscript_enabled_.value();
02085   }
02086   void set_support_noscript_enabled(bool x) {
02087     set_option(x, &support_noscript_enabled_);
02088   }
02089 
02090   bool enable_extended_instrumentation() const {
02091     return enable_extended_instrumentation_.value();
02092   }
02093   void set_enable_extended_instrumentation(bool x) {
02094     set_option(x, &enable_extended_instrumentation_);
02095   }
02096 
02097   void set_max_combined_js_bytes(int64 x) {
02098     set_option(x, &max_combined_js_bytes_);
02099   }
02100   int64 max_combined_js_bytes() const {
02101     return max_combined_js_bytes_.value();
02102   }
02103 
02104   void set_pre_connect_url(const StringPiece& p) {
02105     set_option(GoogleString(p.data(), p.size()), &pre_connect_url_);
02106   }
02107   const GoogleString& pre_connect_url() const {
02108     return pre_connect_url_.value();
02109   }
02110   void set_property_cache_http_status_stability_threshold(int x) {
02111     set_option(x, &property_cache_http_status_stability_threshold_);
02112   }
02113   int property_cache_http_status_stability_threshold() const {
02114     return property_cache_http_status_stability_threshold_.value();
02115   }
02116 
02117   void set_max_rewrite_info_log_size(int x) {
02118     set_option(x, &max_rewrite_info_log_size_);
02119   }
02120   int max_rewrite_info_log_size() const {
02121     return max_rewrite_info_log_size_.value();
02122   }
02123 
02124   void set_enable_aggressive_rewriters_for_mobile(bool x) {
02125     set_option(x, &enable_aggressive_rewriters_for_mobile_);
02126   }
02127   bool enable_aggressive_rewriters_for_mobile() const {
02128     return enable_aggressive_rewriters_for_mobile_.value();
02129   }
02130 
02131   void set_allow_logging_urls_in_log_record(bool x) {
02132     set_option(x, &allow_logging_urls_in_log_record_);
02133   }
02134   bool allow_logging_urls_in_log_record() const {
02135     return allow_logging_urls_in_log_record_.value();
02136   }
02137 
02138   void set_non_cacheables_for_cache_partial_html(const StringPiece& p) {
02139     set_option(p.as_string(), &non_cacheables_for_cache_partial_html_);
02140   }
02141   const GoogleString& non_cacheables_for_cache_partial_html() const {
02142     return non_cacheables_for_cache_partial_html_.value();
02143   }
02144 
02145   void set_access_control_allow_origins(const StringPiece& p) {
02146     set_option(p.as_string(), &access_control_allow_origins_);
02147   }
02148   const GoogleString& access_control_allow_origins() const {
02149     return access_control_allow_origins_.value();
02150   }
02151 
02152   void set_hide_referer_using_meta(bool x) {
02153     set_option(x, &hide_referer_using_meta_);
02154   }
02155   bool hide_referer_using_meta() const {
02156     return hide_referer_using_meta_.value();
02157   }
02158 
02159   void set_enable_fix_reflow(bool x) {
02160     set_option(x, &enable_fix_reflow_);
02161   }
02162   bool enable_fix_reflow() const {
02163     return enable_fix_reflow_.value();
02164   }
02165 
02181   virtual void Merge(const RewriteOptions& src);
02182 
02185   void Allow(const StringPiece& wildcard_pattern) {
02186     Modify();
02187     allow_resources_.Allow(wildcard_pattern);
02188   }
02189 
02192   void Disallow(const StringPiece& wildcard_pattern) {
02193     Modify();
02194     allow_resources_.Disallow(wildcard_pattern);
02195   }
02196 
02200   virtual void DisallowTroublesomeResources();
02201 
02206   virtual void DisallowResourcesForProxy();
02207 
02228   const DomainLawyer* domain_lawyer() const { return domain_lawyer_.get(); }
02229   DomainLawyer* WriteableDomainLawyer();
02230 
02231   FileLoadPolicy* file_load_policy() { return &file_load_policy_; }
02232   const FileLoadPolicy* file_load_policy() const { return &file_load_policy_; }
02233 
02236   bool IsAllowed(const StringPiece& url) const {
02237     return allow_resources_.Match(url, true);
02238   }
02239 
02241   void RetainComment(const StringPiece& comment) {
02242     Modify();
02243     retain_comments_.Allow(comment);
02244   }
02245 
02249   bool IsRetainedComment(const StringPiece& comment) const {
02250     return retain_comments_.Match(comment, false);
02251   }
02252 
02254   void DisableLazyloadForClassName(const StringPiece& class_name) {
02255     Modify();
02256     lazyload_enabled_classes_.Disallow(class_name);
02257   }
02258 
02260   bool IsLazyloadEnabledForClassName(const StringPiece& class_name) const {
02261     return lazyload_enabled_classes_.Match(class_name, true);
02262   }
02263 
02264   void set_override_caching_ttl_ms(int64 x) {
02265     set_option(x, &override_caching_ttl_ms_);
02266   }
02267   int64 override_caching_ttl_ms() const {
02268     return override_caching_ttl_ms_.value();
02269   }
02270 
02273   void AddOverrideCacheTtl(const StringPiece& wildcard) {
02274     Modify();
02275     override_caching_wildcard_.Allow(wildcard);
02276   }
02277 
02279   bool IsCacheTtlOverridden(const StringPiece& url) const {
02280     return override_caching_wildcard_.Match(url, false);
02281   }
02282 
02283   void AddRejectedUrlWildcard(const GoogleString& wildcard) {
02284     AddRejectedHeaderWildcard(kRejectedRequestUrlKeyName, wildcard);
02285   }
02286 
02287   void AddRejectedHeaderWildcard(const StringPiece& header_name,
02288                                  const GoogleString& wildcard) {
02289     Modify();
02290     std::pair<FastWildcardGroupMap::iterator, bool> insert_result =
02291         rejected_request_map_.insert(std::make_pair(
02292             header_name, static_cast<FastWildcardGroup*>(NULL)));
02293 
02294     if (insert_result.second) {
02295       insert_result.first->second = new FastWildcardGroup;
02296     }
02297     insert_result.first->second->Allow(wildcard);
02298   }
02299 
02302   bool IsRequestDeclined(const GoogleString& url,
02303                          const RequestHeaders* request_headers) const;
02304 
02308   virtual RewriteOptions* Clone() const;
02309 
02311   virtual RewriteOptions* NewOptions() const;
02312 
02318   void ComputeSignature();
02319 
02324   void Freeze();
02325 
02332   void ClearSignatureWithCaution();
02333 
02334   bool frozen() const { return frozen_; }
02335 
02339   bool ClearSignatureForTesting() {
02340     bool frozen = frozen_;
02341     ClearSignatureWithCaution();
02342     return frozen;
02343   }
02344 
02346   const GoogleString& signature() const {
02354     ThreadSystem::ScopedReader lock(cache_invalidation_timestamp_.mutex());
02355     DCHECK(frozen_);
02356     DCHECK(!signature_.empty());
02357     return signature_;
02358   }
02359 
02360   virtual GoogleString OptionsToString() const;
02361   GoogleString FilterSetToString(const FilterSet& filter_set) const;
02362 
02365   virtual GoogleString ToExperimentString() const;
02366 
02370   virtual GoogleString ToExperimentDebugString() const;
02371 
02374   static Filter LookupFilterById(const StringPiece& filter_id);
02375 
02377   static Filter LookupFilter(const StringPiece& filter_name);
02378 
02381   static const PropertyBase* LookupOptionById(StringPiece option_id);
02382   static const PropertyBase* LookupOptionByName(StringPiece option_name);
02383 
02386   static const StringPiece LookupOptionNameById(StringPiece option_id);
02387 
02389   static bool IsValidOptionName(StringPiece name);
02390 
02393   const OptionBaseVector& all_options() const {
02394     return all_options_;
02395   }
02396 
02400   bool IsEqual(const RewriteOptions& that) const;
02401 
02403   const Hasher* hasher() const { return &hasher_; }
02404 
02405   ThreadSystem* thread_system() const { return thread_system_; }
02406 
02407  protected:
02411   template<class ValueType>
02412   class Property : public PropertyBase {
02413    public:
02418     Property(ValueType default_value,
02419              const char* id,
02420              StringPiece option_name)
02421         : PropertyBase(id, option_name),
02422           default_value_(default_value) {
02423     }
02424 
02425     void set_default(ValueType value) { default_value_ = value; }
02426     const ValueType& default_value() const { return default_value_; }
02427 
02428    private:
02429     ValueType default_value_;
02430 
02431     DISALLOW_COPY_AND_ASSIGN(Property);
02432   };
02433 
02448   template<class RewriteOptionsSubclass, class OptionClass>
02449   class PropertyLeaf : public Property<typename OptionClass::ValueType> {
02450    public:
02454     typedef OptionClass RewriteOptionsSubclass::*OptionOffset;
02455     typedef typename OptionClass::ValueType ValueType;
02456 
02457     PropertyLeaf(ValueType default_value,
02458                  OptionOffset offset,
02459                  const char* id,
02460                  StringPiece option_name)
02461         : Property<ValueType>(default_value, id, option_name),
02462           offset_(offset) {
02463     }
02464 
02465     virtual void InitializeOption(RewriteOptions* options) const {
02466       RewriteOptionsSubclass* options_subclass =
02467           static_cast<RewriteOptionsSubclass*>(options);
02468       OptionClass& option = options_subclass->*offset_;
02469       option.set_property(this);
02470       DCHECK_NE(-1, this->index()) << "Call Property::set_index first.";
02471       options->set_option_at(this->index(), &option);
02472     }
02473 
02474    private:
02475     OptionOffset offset_;
02476 
02477     DISALLOW_COPY_AND_ASSIGN(PropertyLeaf);
02478   };
02479 
02489   template<class T> class OptionTemplateBase : public OptionBase {
02490    public:
02491     typedef T ValueType;
02492 
02493     OptionTemplateBase() : was_set_(false), property_(NULL) {}
02494 
02495     virtual bool was_set() const { return was_set_; }
02496 
02497     void set(const T& val) {
02498       was_set_ = true;
02499       value_ = val;
02500     }
02501 
02502     void set_default(const T& val) {
02503       if (!was_set_) {
02504         value_ = val;
02505       }
02506     }
02507 
02508     const T& value() const { return value_; }
02509 
02515     virtual void Merge(const OptionBase* src) {
02516       DCHECK(option_name() == src->option_name());
02517       MergeHelper(static_cast<const OptionTemplateBase*>(src));
02518     }
02519 
02520     void MergeHelper(const OptionTemplateBase* src) {
02523       if (src->was_set_ || !was_set_) {
02524         value_ = src->value_;
02525         was_set_ = src->was_set_;
02526       }
02527     }
02528 
02530     void set_property(const Property<T>* property) {
02531       property_ = property;
02532 
02537       value_ = property->default_value();
02538     }
02539     virtual const Property<T>* property() const { return property_; }
02540 
02549     void set_global_default(const T& val) {
02550       Property<T>* property = const_cast<Property<T>*>(property_);
02551       property->set_default(val);
02552     }
02553 
02562     void DoNotUseForSignatureComputation() {
02563       Property<T>* property = const_cast<Property<T>*>(property_);
02564       property->set_do_not_use_for_signature_computation(true);
02565     }
02566 
02567    private:
02568     bool was_set_;
02569     T value_;
02570     const Property<T>* property_;
02571 
02572     DISALLOW_COPY_AND_ASSIGN(OptionTemplateBase);
02573   };
02574 
02579   template<class T> class Option : public OptionTemplateBase<T> {
02580    public:
02581     Option() {}
02582 
02584     virtual bool SetFromString(const GoogleString& value_string) {
02585       T value;
02586       bool success = RewriteOptions::ParseFromString(value_string, &value);
02587       if (success) {
02588         this->set(value);
02589       }
02590       return success;
02591     }
02592 
02593     virtual GoogleString Signature(const Hasher* hasher) const {
02594       return RewriteOptions::OptionSignature(this->value(), hasher);
02595     }
02596 
02597     virtual GoogleString ToString() const {
02598       return RewriteOptions::ToString(this->value());
02599     }
02600 
02601    private:
02602     DISALLOW_COPY_AND_ASSIGN(Option);
02603   };
02604 
02617   class MutexedOptionInt64MergeWithMax : public Option<int64> {
02618    public:
02619     MutexedOptionInt64MergeWithMax();
02620     virtual ~MutexedOptionInt64MergeWithMax();
02621 
02626     virtual void Merge(const OptionBase* src_base);
02627 
02638     void checked_set(const int64& value) {
02639       mutex_->DCheckLocked();
02640       Option<int64>::set(value);
02641     }
02642 
02656     ThreadSystem::RWLock* mutex() const { return mutex_.get(); }
02657 
02663     void set_mutex(ThreadSystem::RWLock* lock) { mutex_.reset(lock); }
02664 
02665    private:
02666     scoped_ptr<ThreadSystem::RWLock> mutex_;
02667   };
02668 
02669  protected:
02671   template<class RewriteOptionsSubclass, class OptionClass>
02672   static PropertyBase* AddProperty(
02673       typename OptionClass::ValueType default_value,
02674       OptionClass RewriteOptionsSubclass::*offset,
02675       const char* id,
02676       StringPiece option_name,
02677       OptionScope scope,
02678       const char* help_text,
02679       Properties* properties) {
02680     PropertyBase* property =
02681         new PropertyLeaf<RewriteOptionsSubclass, OptionClass>(
02682             default_value, offset, id, option_name);
02683     property->set_scope(scope);
02684     property->set_help_text(help_text);
02685     properties->push_back(property);
02686     return property;
02687   }
02688 
02702   static void MergeSubclassProperties(Properties* properties);
02703 
02705   void ForbidFiltersForPreserveUrl();
02706 
02712   void set_option_at(int index, OptionBase* option) {
02713     all_options_[index] = option;
02714   }
02715 
02719   template<class T>
02720   void set_option(const T& new_value, OptionTemplateBase<T>* option) {
02721     option->set(new_value);
02722     Modify();
02723   }
02724 
02726   void Modify();
02727 
02735   void set_default_x_header_value(const StringPiece& x_header_value) {
02736     x_header_value_.set_global_default(x_header_value.as_string());
02737   }
02738 
02742   bool SetupExperimentRewriters();
02743 
02745   virtual void SetRequiredExperimentFilters();
02746 
02750   bool InsertExperimentSpecInVector(ExperimentSpec* spec);
02751 
02753   Option<BeaconUrl> beacon_url_;
02754 
02756   Option<GoogleString> x_header_value_;
02757 
02758  private:
02759   struct OptionIdCompare;
02760 
02761   static Properties* properties_; 
02762   static Properties* all_properties_; 
02763 
02764   FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
02765   FRIEND_TEST(RewriteOptionsTest, LookupOptionByNameTest);
02766 
02768   bool HasRejectedHeader(const StringPiece& header_name,
02769                          const RequestHeaders* request_headers) const;
02770 
02771   bool IsRejectedUrl(const GoogleString& url) const {
02772     return IsRejectedRequest(kRejectedRequestUrlKeyName, url);
02773   }
02774 
02775   bool IsRejectedRequest(const StringPiece& header_name,
02776                          const StringPiece& value) const {
02777     FastWildcardGroupMap::const_iterator it = rejected_request_map_.find(
02778         header_name);
02779     if (it != rejected_request_map_.end()) {
02780       return it->second->Match(value, false);
02781     }
02782     return false;
02783   }
02784 
02787   JavascriptLibraryIdentification* WriteableJavascriptLibraryIdentification();
02788 
02795   struct PrioritizeVisibleContentFamily {
02796     PrioritizeVisibleContentFamily(StringPiece url_pattern_string,
02797                                    int64 cache_time_ms_in,
02798                                    StringPiece non_cacheable_elements_in)
02799         : url_pattern(url_pattern_string),
02800           cache_time_ms(cache_time_ms_in),
02801           non_cacheable_elements(non_cacheable_elements_in.data(),
02802                                  non_cacheable_elements_in.size()) {}
02803 
02804     PrioritizeVisibleContentFamily* Clone() const {
02805       return new PrioritizeVisibleContentFamily(
02806           url_pattern.spec(), cache_time_ms, non_cacheable_elements);
02807     }
02808 
02809     GoogleString ComputeSignature() const {
02810       return StrCat(url_pattern.spec(), ";", Integer64ToString(cache_time_ms),
02811                     ";", non_cacheable_elements);
02812     }
02813 
02814     GoogleString ToString() const {
02815       return StrCat("URL pattern: ", url_pattern.spec(), ",  Cache time (ms): ",
02816                     Integer64ToString(cache_time_ms), ",  Non-cacheable: ",
02817                     non_cacheable_elements);
02818     }
02819 
02820     Wildcard url_pattern;
02821     int64 cache_time_ms;
02822     GoogleString non_cacheable_elements;
02823   };
02824 
02827   struct UrlCacheInvalidationEntry {
02828     UrlCacheInvalidationEntry(StringPiece url_pattern_in,
02829                               int64 timestamp_ms_in,
02830                               bool ignores_metadata_and_pcache_in)
02831         : url_pattern(url_pattern_in),
02832           timestamp_ms(timestamp_ms_in),
02833           ignores_metadata_and_pcache(ignores_metadata_and_pcache_in) {}
02834 
02835     UrlCacheInvalidationEntry* Clone() const {
02836       return new UrlCacheInvalidationEntry(
02837           url_pattern.spec(), timestamp_ms, ignores_metadata_and_pcache);
02838     }
02839 
02840     GoogleString ComputeSignature() const {
02841       if (ignores_metadata_and_pcache) {
02842         return "";
02843       }
02844       return StrCat(url_pattern.spec(), "@", Integer64ToString(timestamp_ms));
02845     }
02846 
02847     GoogleString ToString() const {
02848       return StrCat(
02849           url_pattern.spec(), ", ",
02850           (ignores_metadata_and_pcache ? "STRICT" : "REFERENCE"), " @ ",
02851           Integer64ToString(timestamp_ms));
02852     }
02853 
02854     Wildcard url_pattern;
02855     int64 timestamp_ms;
02856     bool ignores_metadata_and_pcache;
02857   };
02858 
02859   typedef std::vector<UrlCacheInvalidationEntry*>
02860       UrlCacheInvalidationEntryVector;
02861   typedef dense_hash_map<GoogleString, int64> UrlCacheInvalidationMap;
02862 
02866   typedef rde::hash_map<StringPiece, const PropertyBase*,
02867                         CaseFoldStringPieceHash,  6,
02868                         CaseFoldStringPieceEqual> PropertyNameMap;
02869 
02882   template<class OptionClass, class RewriteOptionsSubclass>
02883   static void AddRequestProperty(typename OptionClass::ValueType default_value,
02884                                  OptionClass RewriteOptionsSubclass::*offset,
02885                                  const char* id) {
02886     AddProperty(default_value, offset, id, kNullOption, kProcessScope,
02887                 NULL, properties_);
02888   }
02889 
02892   template<class RewriteOptionsSubclass, class OptionClass>
02893   static void AddBaseProperty(typename OptionClass::ValueType default_value,
02894                               OptionClass RewriteOptionsSubclass::*offset,
02895                               const char* id,
02896                               StringPiece option_name,
02897                               OptionScope scope,
02898                               const char* help) {
02899     AddProperty(default_value, offset, id, option_name, scope, help,
02900                 properties_);
02901   }
02902 
02903   static void AddProperties();
02904   bool AddCommaSeparatedListToFilterSetState(
02905       const StringPiece& filters, FilterSet* set, MessageHandler* handler);
02906   static bool AddCommaSeparatedListToFilterSet(
02907       const StringPiece& filters, FilterSet* set, MessageHandler* handler);
02910   void ResolveConflicts();
02912   static void InitFilterIdToEnumArray();
02913   static void InitOptionIdToPropertyArray();
02914   static void InitOptionNameToPropertyArray();
02917   const PrioritizeVisibleContentFamily* FindPrioritizeVisibleContentFamily(
02918       const StringPiece str) const;
02919 
02923   OptionSettingResult FormatSetOptionMessage(
02924       OptionSettingResult result, StringPiece name, StringPiece value,
02925       GoogleString* msg);
02926 
02929   static GoogleString OptionSignature(bool x, const Hasher* hasher) {
02930     return x ? "T" : "F";
02931   }
02932   static GoogleString OptionSignature(int x, const Hasher* hasher) {
02933     return IntegerToString(x);
02934   }
02935   static GoogleString OptionSignature(int64 x, const Hasher* hasher) {
02936     return Integer64ToString(x);
02937   }
02938   static GoogleString OptionSignature(const GoogleString& x,
02939                                       const Hasher* hasher);
02940   static GoogleString OptionSignature(RewriteLevel x,
02941                                       const Hasher* hasher);
02942   static GoogleString OptionSignature(const BeaconUrl& beacon_url,
02943                                       const Hasher* hasher);
02944 
02947   static GoogleString ToString(bool x) {
02948     return x ? "True" : "False";
02949   }
02950   static GoogleString ToString(int x) {
02951     return IntegerToString(x);
02952   }
02953   static GoogleString ToString(int64 x) {
02954     return Integer64ToString(x);
02955   }
02956   static GoogleString ToString(const GoogleString& x) {
02957     return x;
02958   }
02959   static GoogleString ToString(RewriteLevel x);
02960   static GoogleString ToString(const BeaconUrl& beacon_url);
02961 
02964   static bool PropertyLessThanByOptionName(PropertyBase* p1, PropertyBase* p2) {
02965     return StringCaseCompare(p1->option_name(), p2->option_name()) < 0;
02966   }
02967 
02969   static bool OptionNameLessThanArg(OptionBase* option, StringPiece arg) {
02970     return StringCaseCompare(option->option_name(), arg) < 0;
02971   }
02972 
02974   static bool CompareUrlCacheInvalidationEntry(UrlCacheInvalidationEntry* e1,
02975                                                UrlCacheInvalidationEntry* e2) {
02976     return e1->timestamp_ms < e2->timestamp_ms;
02977   }
02978 
02980   static bool FilterEnumToIdAndNameEntryLessThanById(
02981       const FilterEnumToIdAndNameEntry* e1,
02982       const FilterEnumToIdAndNameEntry* e2) {
02983     return strcmp(e1->filter_id, e2->filter_id) < 0;
02984   }
02985 
02986   bool modified_;
02987   bool frozen_;
02988   FilterSet enabled_filters_;
02989   FilterSet disabled_filters_;
02990   FilterSet forbidden_filters_;
02991 
02994   FilterIdSet distributable_filters_;
02995 
03001   Option<RewriteLevel> level_;
03002 
03005   UrlCacheInvalidationEntryVector url_cache_invalidation_entries_;
03006 
03008   UrlCacheInvalidationMap url_cache_invalidation_map_;
03009 
03010   MutexedOptionInt64MergeWithMax cache_invalidation_timestamp_;
03011   Option<int64> css_flatten_max_bytes_;
03012   Option<bool> cache_small_images_unrewritten_;
03014   Option<int64> image_resolution_limit_bytes_;
03015   Option<int64> css_image_inline_max_bytes_;
03016   Option<int64> css_inline_max_bytes_;
03017   Option<int64> css_outline_min_bytes_;
03018 
03020   Option<bool> css_preserve_urls_;
03021   Option<bool> js_preserve_urls_;
03022   Option<bool> image_preserve_urls_;
03023 
03026   Option<bool> rewrite_request_urls_early_;
03027 
03028   Option<int64> image_inline_max_bytes_;
03029   Option<int64> js_inline_max_bytes_;
03030   Option<int64> js_outline_min_bytes_;
03031   Option<int64> progressive_jpeg_min_bytes_;
03033   Option<int64> max_html_cache_time_ms_;
03036   Option<int64> max_html_parse_bytes_;
03038   Option<int64> max_image_bytes_for_webp_in_css_;
03040   Option<int64> min_resource_cache_time_to_rewrite_ms_;
03041   Option<int64> idle_flush_time_ms_;
03042   Option<int64> flush_buffer_limit_bytes_;
03043 
03047   Option<int64> blocking_fetch_timeout_ms_;
03048 
03051   Option<int64> image_recompress_quality_;
03052 
03054   Option<int64> image_jpeg_recompress_quality_;
03055   Option<int64> image_jpeg_recompress_quality_for_small_screens_;
03056   Option<int64> image_jpeg_num_progressive_scans_;
03057   Option<int64> image_jpeg_num_progressive_scans_for_small_screens_;
03058 
03060   Option<int> image_limit_optimized_percent_;
03061   Option<int> image_limit_resize_area_percent_;
03062   Option<int> image_limit_rendered_area_percent_;
03063 
03065   Option<int64> image_webp_recompress_quality_;
03066   Option<int64> image_webp_recompress_quality_for_small_screens_;
03067   Option<int64> image_webp_timeout_ms_;
03068 
03069   Option<int> image_max_rewrites_at_once_;
03070   Option<int> max_url_segment_size_; 
03071   Option<int> max_url_size_; 
03072 
03073 
03074   Option<int> rewrite_deadline_ms_;
03076   Option<int> domain_shard_count_;
03077 
03078   Option<EnabledEnum> enabled_;
03079 
03080   Option<bool> distributable_;
03081 
03084   Option<bool> add_options_to_urls_;
03085 
03087   Option<bool> in_place_rewriting_enabled_;
03089   Option<bool> in_place_wait_for_optimized_;
03092   Option<int> in_place_rewrite_deadline_ms_;
03095   Option<bool> in_place_preemptive_rewrite_css_;
03097   Option<bool> in_place_preemptive_rewrite_css_images_;
03100   Option<bool> in_place_preemptive_rewrite_images_;
03103   Option<bool> in_place_preemptive_rewrite_javascript_;
03104   Option<bool> combine_across_paths_;
03105   Option<bool> log_background_rewrites_;
03106   Option<bool> log_rewrite_timing_; 
03107   Option<bool> log_url_indices_;
03108   Option<bool> lowercase_html_names_;
03109   Option<bool> always_rewrite_css_; 
03110   Option<bool> respect_vary_;
03111   Option<bool> respect_x_forwarded_proto_;
03112   Option<bool> flush_html_;
03116   Option<bool> serve_split_html_in_two_chunks_;
03119   Option<bool> serve_stale_if_fetch_error_;
03121   Option<bool> serve_ghost_click_buster_with_split_html_;
03123   Option<bool> serve_xhr_access_control_headers_;
03126   Option<bool> proactively_freshen_user_facing_request_;
03129   Option<int64> serve_stale_while_revalidate_threshold_sec_;
03131   Option<bool> enable_flush_early_critical_css_;
03136   Option<bool> default_cache_html_;
03141   Option<bool> modify_caching_headers_;
03145   Option<bool> lazyload_images_after_onload_;
03148   Option<GoogleString> lazyload_images_blank_url_;
03151   Option<bool> use_blank_image_for_inline_preview_;
03155   Option<bool> inline_only_critical_images_;
03158   Option<bool> critical_images_beacon_enabled_;
03161   Option<bool> client_domain_rewrite_;
03164   Option<bool> domain_rewrite_hyperlinks_;
03167   Option<bool> running_experiment_;
03170   Option<int> experiment_ga_slot_;
03171 
03174   Option<bool> increase_speed_tracking_;
03175 
03179   Option<bool> report_unload_time_;
03180 
03182   Option<bool> flush_more_resources_early_if_time_permits_;
03183 
03185   Option<bool> flush_more_resources_in_ie_and_firefox_;
03186 
03189   Option<int> max_prefetch_js_elements_;
03190 
03192   Option<bool> enable_defer_js_experimental_;
03193 
03195   Option<bool> disable_rewrite_on_no_transform_;
03196 
03206   Option<bool> enable_cache_purge_;
03207 
03209   Option<bool> lazyload_highres_images_;
03210 
03213   Option<bool> avoid_renaming_introspective_javascript_;
03214 
03216   Option<bool> override_ie_document_mode_;
03217 
03219   Option<bool> test_instant_fetch_rewrite_deadline_;
03220 
03224   Option<bool> test_only_prioritize_critical_css_dont_apply_original_css_;
03225 
03231   Option<GoogleString> blocking_rewrite_key_;
03232 
03236   Option<int> beacon_reinstrument_time_sec_;
03237 
03240   Option<int> max_inlined_preview_images_index_;
03242   Option<int64> min_image_size_low_resolution_bytes_;
03244   Option<int64> max_image_size_low_resolution_bytes_;
03247   Option<int> rewrite_random_drop_percentage_;
03248 
03251   Option<bool> oblivious_pagespeed_urls_;
03252 
03254   Option<int64> finder_properties_cache_expiration_time_ms_;
03255 
03259   Option<int64> finder_properties_cache_refresh_time_ms_;
03262   Option<int64> experiment_cookie_duration_ms_;
03263 
03266   Option<int64> metadata_cache_staleness_threshold_ms_;
03267 
03269   Option<int64> metadata_input_errors_cache_ttl_ms_;
03270 
03276   Option<int64> downstream_cache_lifetime_ms_;
03277 
03280   Option<GoogleString> downstream_cache_purge_method_;
03281 
03283   Option<GoogleString> downstream_cache_purge_location_prefix_;
03284 
03290   Option<int64> downstream_cache_rewritten_percentage_threshold_;
03291 
03295   Option<int64> implicit_cache_ttl_ms_;
03296 
03298   Option<int64> max_cacheable_response_content_length_;
03299 
03301   Option<int64> blink_blacklist_end_timestamp_ms_;
03303   Option<bool> persist_blink_blacklist_;
03304 
03305   Option<GoogleString> ga_id_;
03306 
03307   Option<int64> blink_max_html_size_rewritable_;
03310   Option<int64> blink_html_change_detection_time_ms_;
03312   Option<bool> enable_blink_debug_dashboard_;
03314   Option<bool> enable_blink_html_change_detection_;
03316   Option<bool> enable_blink_html_change_detection_logging_;
03318   Option<bool> use_smart_diff_in_blink_;
03320   Option<bool> use_fallback_property_cache_values_;
03322   Option<bool> enable_prioritizing_scripts_;
03324   Option<bool> rewrite_uncacheable_resources_;
03326   Option<GoogleString> critical_line_config_;
03329   Option<GoogleString> distributed_rewrite_key_;
03331   Option<GoogleString> distributed_rewrite_servers_;
03334   Option<int64> distributed_rewrite_timeout_ms_;
03340   Option<bool> forbid_all_disabled_filters_;
03342   Option<bool> enable_aggressive_rewriters_for_mobile_;
03343 
03349   Option<bool> reject_blacklisted_;
03350   Option<int> reject_blacklisted_status_code_;
03351 
03355   Option<bool> support_noscript_enabled_;
03356 
03359   Option<bool> enable_extended_instrumentation_;
03360 
03363   Option<int64> max_combined_js_bytes_;
03364 
03366   Option<GoogleString> pre_connect_url_;
03369   Option<int> property_cache_http_status_stability_threshold_;
03371   Option<int> max_rewrite_info_log_size_;
03372 
03377   Option<int64> override_caching_ttl_ms_;
03378   FastWildcardGroup override_caching_wildcard_;
03379 
03381   Option<bool> allow_logging_urls_in_log_record_;
03382 
03384   Option<GoogleString> non_cacheables_for_cache_partial_html_;
03385 
03389   Option<GoogleString> access_control_allow_origins_;
03390 
03392   Option<bool> hide_referer_using_meta_;
03393 
03395   Option<bool> enable_fix_reflow_;
03396 
03399   OptionBaseVector all_options_;
03400   size_t initialized_options_; 
03401 
03404   static const FilterEnumToIdAndNameEntry* filter_id_to_enum_array_[
03405       kEndOfFilters];
03406 
03408   static PropertyNameMap* option_name_to_property_map_;
03409 
03411   static const PropertyBase** option_id_to_property_array_;
03412 
03419   bool options_uniqueness_checked_;
03420 
03421   bool need_to_store_experiment_data_;
03422   int experiment_id_; 
03423   int experiment_percent_; 
03424   std::vector<ExperimentSpec*> experiment_specs_;
03425 
03427   std::vector<NameValue*> custom_fetch_headers_;
03428 
03431   scoped_ptr<std::vector<ElementAttributeCategory> > url_valued_attributes_;
03432 
03433   CopyOnWrite<JavascriptLibraryIdentification>
03434       javascript_library_identification_;
03435 
03436   CopyOnWrite<DomainLawyer> domain_lawyer_;
03437   FileLoadPolicy file_load_policy_;
03438 
03439   FastWildcardGroup allow_resources_;
03440   FastWildcardGroup retain_comments_;
03441   FastWildcardGroup lazyload_enabled_classes_;
03444   FastWildcardGroup blocking_rewrite_referer_urls_;
03445 
03448   typedef std::map<StringPiece, FastWildcardGroup*> FastWildcardGroupMap;
03449   FastWildcardGroupMap rejected_request_map_;
03450 
03451   GoogleString signature_;
03452   MD5Hasher hasher_; 
03453 
03454   ThreadSystem* thread_system_;
03455 
03468   scoped_ptr<ThreadSystem::ThreadId> last_thread_id_;
03469 
03470   DISALLOW_COPY_AND_ASSIGN(RewriteOptions);
03471 };
03472 
03473 }  
03474 
03475 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines