Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rewrite_options.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_OPTIONS_H_
21 
22 #include <cstddef>
23 #include <map>
24 #include <set>
25 #include <utility>
26 #include <vector>
27 
28 #include "base/logging.h"
29 #include "net/instaweb/http/public/meta_data.h"
30 #include "net/instaweb/http/public/semantic_type.h"
36 #include "net/instaweb/util/public/enum_set.h"
37 #include "net/instaweb/util/public/gtest_prod.h"
38 #include "net/instaweb/util/public/md5_hasher.h"
39 #include "net/instaweb/util/public/proto_util.h"
42 #include "pagespeed/kernel/base/dense_hash_map.h"
43 #include "pagespeed/kernel/base/fast_wildcard_group.h"
44 #include "pagespeed/kernel/base/rde_hash_map.h"
45 #include "pagespeed/kernel/base/sha1_signature.h"
46 #include "pagespeed/kernel/base/string.h"
47 #include "pagespeed/kernel/base/string_hash.h"
48 #include "pagespeed/kernel/base/string_util.h"
49 #include "pagespeed/kernel/base/thread_annotations.h"
50 #include "pagespeed/kernel/base/wildcard.h"
51 #include "pagespeed/kernel/util/copy_on_write.h"
52 
53 namespace net_instaweb {
54 
55 class Hasher;
56 class HttpOptions;
57 class MessageHandler;
58 class PurgeSet;
59 class RequestHeaders;
60 
82  private:
87  class PropertyBase;
88  template<class ValueType> class Property;
89  template<class RewriteOptionsSubclass, class OptionClass> class PropertyLeaf;
90 
91  public:
104  enum Filter {
106  kAddHead,
107  kAddInstrumentation,
108  kComputeStatistics,
109  kCachePartialHtml,
110  kCanonicalizeJavascriptLibraries,
111  kCollapseWhitespace,
112  kCollectFlushEarlyContentFilter,
113  kCombineCss,
114  kCombineHeads,
115  kCombineJavascript,
116  kComputeCriticalCss,
117  kComputeVisibleText,
118  kConvertGifToPng,
119  kConvertJpegToProgressive,
120  kConvertJpegToWebp,
121  kConvertMetaTags,
122  kConvertPngToJpeg,
123  kConvertToWebpLossless,
124  kDebug,
125  kDecodeRewrittenUrls,
126  kDedupInlinedImages,
127  kDeferIframe,
128  kDeferJavascript,
129  kDelayImages,
130  kDeterministicJs,
131  kDisableJavascript,
132  kDivStructure,
133  kElideAttributes,
135  kExplicitCloseTags,
136  kExtendCacheCss,
137  kExtendCacheImages,
138  kExtendCachePdfs,
139  kExtendCacheScripts,
140  kFallbackRewriteCssUrls,
141  kFixReflows,
142  kFlattenCssImports,
143  kFlushSubresources,
144  kHandleNoscriptRedirect,
145  kHtmlWriterFilter,
146  kIncludeJsSourceMaps,
147  kInlineCss,
148  kInlineGoogleFontCss,
149  kInlineImages,
150  kInlineImportToLink,
151  kInlineJavascript,
152  kInPlaceOptimizeForBrowser,
153  kInsertDnsPrefetch,
154  kInsertGA,
155  kInsertImageDimensions,
156  kJpegSubsampling,
157  kLazyloadImages,
158  kLeftTrimUrls,
159  kLocalStorageCache,
160  kMakeGoogleAnalyticsAsync,
161  kMobilize,
162  kMoveCssAboveScripts,
163  kMoveCssToHead,
164  kOutlineCss,
165  kOutlineJavascript,
166  kPedantic,
167  kPrioritizeCriticalCss,
168  kRecompressJpeg,
169  kRecompressPng,
170  kRecompressWebp,
171  kRemoveComments,
172  kRemoveQuotes,
173  kResizeImages,
174  kResizeMobileImages,
175  kResizeToRenderedImageDimensions,
176  kRewriteCss,
177  kRewriteDomains,
178  kRewriteJavascriptExternal,
179  kRewriteJavascriptInline,
180  kRewriteStyleAttributes,
181  kRewriteStyleAttributesWithUrl,
182  kSplitHtml,
183  kSplitHtmlHelper,
184  kSpriteImages,
185  kSquashImagesForMobileScreen,
186  kStripImageColorProfile,
187  kStripImageMetaData,
188  kStripNonCacheable,
189  kStripScripts,
190  kEndOfFilters
191  };
192 
193  enum EnabledEnum {
202  };
203 
210  static const char kAcceptInvalidSignatures[];
211  static const char kAccessControlAllowOrigins[];
212  static const char kAddOptionsToUrls[];
213  static const char kAllowLoggingUrlsInLogRecord[];
214  static const char kAllowOptionsToBeSetByCookies[];
215  static const char kAlwaysRewriteCss[];
216  static const char kAnalyticsID[];
217  static const char kAvoidRenamingIntrospectiveJavascript[];
218  static const char kAwaitPcacheLookup[];
219  static const char kBeaconReinstrumentTimeSec[];
220  static const char kBeaconUrl[];
221  static const char kBlinkMaxHtmlSizeRewritable[];
222  static const char kCacheFragment[];
223  static const char kCacheSmallImagesUnrewritten[];
224  static const char kClientDomainRewrite[];
225  static const char kCombineAcrossPaths[];
226  static const char kCriticalImagesBeaconEnabled[];
227  static const char kCriticalLineConfig[];
228  static const char kCssFlattenMaxBytes[];
229  static const char kCssImageInlineMaxBytes[];
230  static const char kCssInlineMaxBytes[];
231  static const char kCssOutlineMinBytes[];
232  static const char kCssPreserveURLs[];
233  static const char kDefaultCacheHtml[];
234  static const char kDisableBackgroundFetchesForBots[];
235  static const char kDisableRewriteOnNoTransform[];
236  static const char kDistributeFetches[];
237  static const char kDistributedRewriteKey[];
238  static const char kDistributedRewriteServers[];
239  static const char kDistributedRewriteTimeoutMs[];
240  static const char kDomainRewriteHyperlinks[];
241  static const char kDomainShardCount[];
242  static const char kDownstreamCachePurgeMethod[];
243  static const char kDownstreamCacheRebeaconingKey[];
244  static const char kDownstreamCacheRewrittenPercentageThreshold[];
245  static const char kEnableAggressiveRewritersForMobile[];
246  static const char kEnableBlinkHtmlChangeDetection[];
247  static const char kEnableBlinkHtmlChangeDetectionLogging[];
248  static const char kEnableCachePurge[];
249  static const char kEnableDeferJsExperimental[];
250  static const char kEnableExtendedInstrumentation[];
251  static const char kEnableFlushEarlyCriticalCss[];
252  static const char kEnableLazyLoadHighResImages[];
253  static const char kEnablePrioritizingScripts[];
254  static const char kEnabled[];
255  static const char kEnrollExperiment[];
256  static const char kExperimentCookieDurationMs[];
257  static const char kExperimentSlot[];
258  static const char kFetcherTimeOutMs[];
259  static const char kFinderPropertiesCacheExpirationTimeMs[];
260  static const char kFinderPropertiesCacheRefreshTimeMs[];
261  static const char kFlushBufferLimitBytes[];
262  static const char kFlushHtml[];
263  static const char kFlushMoreResourcesEarlyIfTimePermits[];
264  static const char kForbidAllDisabledFilters[];
265  static const char kHideRefererUsingMeta[];
266  static const char kIdleFlushTimeMs[];
267  static const char kImageInlineMaxBytes[];
268  static const char kImageJpegNumProgressiveScans[];
269  static const char kImageJpegNumProgressiveScansForSmallScreens[];
270  static const char kImageJpegRecompressionQuality[];
271  static const char kImageJpegRecompressionQualityForSmallScreens[];
272  static const char kImageLimitOptimizedPercent[];
273  static const char kImageLimitRenderedAreaPercent[];
274  static const char kImageLimitResizeAreaPercent[];
275  static const char kImageMaxRewritesAtOnce[];
276  static const char kImagePreserveURLs[];
277  static const char kImageRecompressionQuality[];
278  static const char kImageResolutionLimitBytes[];
279  static const char kImageWebpRecompressionQuality[];
280  static const char kImageWebpRecompressionQualityForSmallScreens[];
281  static const char kImageWebpTimeoutMs[];
282  static const char kImplicitCacheTtlMs[];
283  static const char kIncreaseSpeedTracking[];
284  static const char kInlineOnlyCriticalImages[];
285  static const char kInPlacePreemptiveRewriteCss[];
286  static const char kInPlacePreemptiveRewriteCssImages[];
287  static const char kInPlacePreemptiveRewriteImages[];
288  static const char kInPlacePreemptiveRewriteJavascript[];
289  static const char kInPlaceResourceOptimization[];
290  static const char kInPlaceRewriteDeadlineMs[];
291  static const char kInPlaceWaitForOptimized[];
292  static const char kJsInlineMaxBytes[];
293  static const char kJsOutlineMinBytes[];
294  static const char kJsPreserveURLs[];
295  static const char kLazyloadImagesAfterOnload[];
296  static const char kLazyloadImagesBlankUrl[];
297  static const char kLogBackgroundRewrite[];
298  static const char kLogRewriteTiming[];
299  static const char kLogUrlIndices[];
300  static const char kLowercaseHtmlNames[];
301  static const char kMaxCacheableResponseContentLength[];
302  static const char kMaxCombinedCssBytes[];
303  static const char kMaxCombinedJsBytes[];
304  static const char kMaxHtmlCacheTimeMs[];
305  static const char kMaxHtmlParseBytes[];
306  static const char kMaxImageBytesForWebpInCss[];
307  static const char kMaxImageSizeLowResolutionBytes[];
308  static const char kMaxInlinedPreviewImagesIndex[];
309  static const char kMaxLowResImageSizeBytes[];
310  static const char kMaxLowResToHighResImageSizePercentage[];
311  static const char kMaxPrefetchJsElements[];
312  static const char kMaxRewriteInfoLogSize[];
313  static const char kMaxUrlSegmentSize[];
314  static const char kMaxUrlSize[];
315  static const char kMetadataCacheStalenessThresholdMs[];
316  static const char kMinCacheTtlMs[];
317  static const char kMinImageSizeLowResolutionBytes[];
318  static const char kMinResourceCacheTimeToRewriteMs[];
319  static const char kModifyCachingHeaders[];
320  static const char kNoTransformOptimizedImages[];
321  static const char kNonCacheablesForCachePartialHtml[];
322  static const char kObliviousPagespeedUrls[];
323  static const char kOptionCookiesDurationMs[];
324  static const char kOverrideCachingTtlMs[];
325  static const char kPersistBlinkBlacklist[];
326  static const char kPreserveUrlRelativity[];
327  static const char kPrivateNotVaryForIE[];
328  static const char kPubliclyCacheMismatchedHashesExperimental[];
329  static const char kProactivelyFreshenUserFacingRequest[];
330  static const char kProactiveResourceFreshening[];
331  static const char kProgressiveJpegMinBytes[];
332  static const char kRejectBlacklisted[];
333  static const char kRejectBlacklistedStatusCode[];
334  static const char kReportUnloadTime[];
335  static const char kRequestOptionOverride[];
336  static const char kRespectVary[];
337  static const char kRespectXForwardedProto[];
338  static const char kRewriteDeadlineMs[];
339  static const char kRewriteLevel[];
340  static const char kRewriteRandomDropPercentage[];
341  static const char kRewriteUncacheableResources[];
342  static const char kRunningExperiment[];
343  static const char kServeGhostClickBusterWithSplitHtml[];
344  static const char kServeSplitHtmlInTwoChunks[];
345  static const char kServeStaleIfFetchError[];
346  static const char kServeStaleWhileRevalidateThresholdSec[];
347  static const char kServeXhrAccessControlHeaders[];
348  static const char kStickyQueryParameters[];
349  static const char kSupportNoScriptEnabled[];
350  static const char kTestOnlyPrioritizeCriticalCssDontApplyOriginalCss[];
351  static const char kUrlSigningKey[];
352  static const char kUseBlankImageForInlinePreview[];
353  static const char kUseExperimentalJsMinifier[];
354  static const char kUseFallbackPropertyCacheValues[];
355  static const char kUseImageScanlineApi[];
356  static const char kUseSelectorsForCriticalCss[];
357  static const char kUseSmartDiffInBlink[];
358  static const char kXModPagespeedHeaderValue[];
359  static const char kXPsaBlockingRewrite[];
361  static const char kAllow[];
362  static const char kBlockingRewriteRefererUrls[];
363  static const char kDisableFilters[];
364  static const char kDisallow[];
365  static const char kDistributableFilters[];
366  static const char kDomain[];
367  static const char kDownstreamCachePurgeLocationPrefix[];
368  static const char kEnableFilters[];
369  static const char kExperimentVariable[];
370  static const char kExperimentSpec[];
371  static const char kForbidFilters[];
372  static const char kInlineResourcesWithoutExplicitAuthorization[];
373  static const char kRetainComment[];
375  static const char kCustomFetchHeader[];
376  static const char kLoadFromFile[];
377  static const char kLoadFromFileMatch[];
378  static const char kLoadFromFileRule[];
379  static const char kLoadFromFileRuleMatch[];
380  static const char kMapOriginDomain[];
381  static const char kMapProxyDomain[];
382  static const char kMapRewriteDomain[];
383  static const char kShardDomain[];
385  static const char kLibrary[];
386  static const char kUrlValuedAttribute[];
389  static const char kCacheFlushFilename[];
390  static const char kCacheFlushPollIntervalSec[];
391  static const char kCompressMetadataCache[];
392  static const char kFetcherProxy[];
393  static const char kFetchFromModSpdy[];
394  static const char kFetchHttps[];
395  static const char kFileCacheCleanInodeLimit[];
396  static const char kFileCacheCleanIntervalMs[];
397  static const char kFileCacheCleanSizeKb[];
398  static const char kFileCachePath[];
399  static const char kLogDir[];
400  static const char kLruCacheByteLimit[];
401  static const char kLruCacheKbPerProcess[];
402  static const char kMemcachedServers[];
403  static const char kMemcachedThreads[];
404  static const char kMemcachedTimeoutUs[];
405  static const char kRateLimitBackgroundFetches[];
406  static const char kServeWebpToAnyAgent[];
407  static const char kSlurpDirectory[];
408  static const char kSlurpFlushLimit[];
409  static const char kSlurpReadOnly[];
410  static const char kSslCertDirectory[];
411  static const char kSslCertFile[];
412  static const char kStatisticsEnabled[];
413  static const char kStatisticsLoggingChartsCSS[];
414  static const char kStatisticsLoggingChartsJS[];
415  static const char kStatisticsLoggingEnabled[];
416  static const char kStatisticsLoggingIntervalMs[];
417  static const char kStatisticsLoggingMaxFileSizeKb[];
418  static const char kTestProxy[];
419  static const char kTestProxySlurp[];
420  static const char kUseSharedMemLocking[];
422  static const char kNullOption[];
423 
431  struct BeaconUrl {
432  GoogleString http;
433  GoogleString https;
434  GoogleString http_in;
435  GoogleString https_in;
436  };
437 
438  struct NameValue {
439  NameValue(const StringPiece& name_in, const StringPiece& value_in) {
440  name_in.CopyToString(&name);
441  value_in.CopyToString(&value);
442  }
443  GoogleString name;
444  GoogleString value;
445  };
446 
462  static const int kOptionsVersion = 13;
463 
465  static const int kHashBytes = 20;
466 
468  static const int kCachePurgeBytes = 25000;
469 
476  enum OptionScope {
483  };
484 
485  static const char kCacheExtenderId[];
486  static const char kCollectFlushEarlyContentFilterId[];
487  static const char kCssCombinerId[];
488  static const char kCssFilterId[];
489  static const char kCssImportFlattenerId[];
490  static const char kCssInlineId[];
491  static const char kGoogleFontCssInlineId[];
492  static const char kImageCombineId[];
493  static const char kImageCompressionId[];
494  static const char kInPlaceRewriteId[];
495  static const char kJavascriptCombinerId[];
496  static const char kJavascriptInlineId[];
497  static const char kJavascriptMinId[];
498  static const char kJavascriptMinSourceMapId[];
499  static const char kLocalStorageCacheId[];
500  static const char kPrioritizeCriticalCssId[];
501 
502  static const char kPanelCommentPrefix[];
503 
506  static const char* FilterName(Filter filter);
507 
510  static const char* FilterId(Filter filter);
511 
514  static int NumFilterIds();
515 
518 
519  typedef EnumSet<Filter, kEndOfFilters> FilterSet;
520  typedef std::vector<Filter> FilterVector;
521 
523  typedef std::set<GoogleString> FilterIdSet;
524 
530  static bool AddByNameToFilterSet(const StringPiece& option, FilterSet* set,
531  MessageHandler* handler);
532 
535  typedef std::pair<GoogleString, GoogleString> OptionStringPair;
536  typedef std::set<OptionStringPair> OptionSet;
537 
538  typedef std::vector<PropertyBase*> PropertyVector;
539 
542  class OptionBase {
543  public:
544  OptionBase() {}
545  virtual ~OptionBase();
546 
550  virtual bool SetFromString(StringPiece value_string,
551  GoogleString* error_detail) = 0;
552  virtual void Merge(const OptionBase* src) = 0;
553  virtual bool was_set() const = 0;
554  virtual GoogleString Signature(const Hasher* hasher) const = 0;
555  virtual GoogleString ToString() const = 0;
556  const char* id() const { return property()->id(); }
557  const char* help_text() const { return property()->help_text(); }
558  OptionScope scope() const { return property()->scope(); }
559  StringPiece option_name() const { return property()->option_name(); }
560  bool is_used_for_signature_computation() const {
561  return property()->is_used_for_signature_computation();
562  }
563  virtual const PropertyBase* property() const = 0;
564  };
565 
567  typedef std::vector<OptionBase*> OptionBaseVector;
568 
575 
580 
587 
592 
596  };
597 
600  kOptionOk,
601  kOptionNameUnknown,
602  kOptionValueInvalid
603  };
604 
605  static const int kDefaultBeaconReinstrumentTimeSec;
606  static const int64 kDefaultBlinkMaxHtmlSizeRewritable;
607  static const int64 kDefaultCssFlattenMaxBytes;
608  static const int64 kDefaultCssImageInlineMaxBytes;
609  static const int64 kDefaultCssInlineMaxBytes;
610  static const int64 kDefaultCssOutlineMinBytes;
611  static const int64 kDefaultImageInlineMaxBytes;
612  static const int64 kDefaultJsInlineMaxBytes;
613  static const int64 kDefaultJsOutlineMinBytes;
614  static const int64 kDefaultProgressiveJpegMinBytes;
615  static const int64 kDefaultMaxCacheableResponseContentLength;
616  static const int64 kDefaultMaxHtmlCacheTimeMs;
617  static const int64 kDefaultMaxHtmlParseBytes;
618  static const int64 kDefaultMaxImageBytesForWebpInCss;
619  static const int64 kDefaultMaxLowResImageSizeBytes;
620  static const int kDefaultMaxLowResToFullResImageSizePercentage;
621  static const int64 kDefaultMetadataInputErrorsCacheTtlMs;
622  static const int64 kDefaultMinResourceCacheTimeToRewriteMs;
623  static const char kDefaultDownstreamCachePurgeMethod[];
624  static const int64 kDefaultDownstreamCacheRewrittenPercentageThreshold;
625  static const int64 kDefaultIdleFlushTimeMs;
626  static const int64 kDefaultFlushBufferLimitBytes;
627  static const int64 kDefaultImplicitCacheTtlMs;
628  static const int64 kDefaultMinCacheTtlMs;
629  static const int64 kDefaultPrioritizeVisibleContentCacheTimeMs;
630  static const char kDefaultBeaconUrl[];
631  static const int64 kDefaultImageRecompressQuality;
632  static const int64 kDefaultImageJpegRecompressQuality;
633  static const int64 kDefaultImageJpegRecompressQualityForSmallScreens;
634  static const int kDefaultImageLimitOptimizedPercent;
635  static const int kDefaultImageLimitRenderedAreaPercent;
636  static const int kDefaultImageLimitResizeAreaPercent;
637  static const int64 kDefaultImageResolutionLimitBytes;
638  static const int64 kDefaultImageJpegNumProgressiveScans;
639  static const int64 kDefaultImageWebpRecompressQuality;
640  static const int64 kDefaultImageWebpRecompressQualityForSmallScreens;
641  static const int64 kDefaultImageWebpTimeoutMs;
642  static const int kDefaultDomainShardCount;
643  static const int64 kDefaultBlinkHtmlChangeDetectionTimeMs;
644  static const int kDefaultMaxPrefetchJsElements;
645  static const int64 kDefaultOptionCookiesDurationMs;
646 
649  static const int kDefaultMaxUrlSize;
650 
651  static const int kDefaultImageMaxRewritesAtOnce;
652 
657  static const int kDefaultMaxUrlSegmentSize;
658 
660  static const int kDefaultRewriteDeadlineMs;
661 
663  static const int64 kDefaultDistributedTimeoutMs;
664 
678 
682 
686 
688  static const int64 kDefaultMaxCombinedCssBytes;
689 
691  static const int64 kDefaultMaxCombinedJsBytes;
692 
693  static const int kDefaultExperimentTrafficPercent;
695  static const int kDefaultExperimentSlot;
696 
697  static const char kDefaultBlockingRewriteKey[];
698 
699  static const char kRejectedRequestUrlKeyName[];
700 
701  static const int kDefaultPropertyCacheHttpStatusStabilityThreshold;
702 
703  static const int kDefaultMaxRewriteInfoLogSize;
704 
712  public:
717  ExperimentSpec(const StringPiece& spec, RewriteOptions* options,
718  MessageHandler* handler);
719 
723  explicit ExperimentSpec(int id);
724 
725  virtual ~ExperimentSpec();
726 
728  virtual ExperimentSpec* Clone();
729 
730  bool is_valid() const { return id_ >= 0; }
731 
733  int id() const { return id_; }
734  int percent() const { return percent_; }
735  GoogleString ga_id() const { return ga_id_; }
736  int slot() const { return ga_variable_slot_; }
737  RewriteLevel rewrite_level() const { return rewrite_level_; }
738  FilterSet enabled_filters() const { return enabled_filters_; }
739  FilterSet disabled_filters() const { return disabled_filters_; }
740  OptionSet filter_options() const { return filter_options_; }
741  bool use_default() const { return use_default_; }
742  GoogleString ToString() const;
743 
744  protected:
749  void Merge(const ExperimentSpec& spec);
750 
751  private:
752  FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
753 
756  void Initialize(const StringPiece& spec, MessageHandler* handler);
757 
758  int id_;
759  GoogleString ga_id_;
760  int ga_variable_slot_;
761  int percent_;
762  RewriteLevel rewrite_level_;
763  FilterSet enabled_filters_;
764  FilterSet disabled_filters_;
765  OptionSet filter_options_;
768  bool use_default_;
769  DISALLOW_COPY_AND_ASSIGN(ExperimentSpec);
770  };
771 
774  GoogleString element;
775  GoogleString attribute;
776  semantic_type::Category category;
777  };
778 
785  class Properties {
786  public:
795  static bool Initialize(Properties** properties);
796 
805  static bool Terminate(Properties** properties_handle);
806 
808  int size() const { return property_vector_.size(); }
809 
810  const PropertyBase* property(int index) const {
811  return property_vector_[index];
812  }
813  PropertyBase* property(int index) { return property_vector_[index]; }
814 
820  void Merge(Properties* properties);
821 
822  void push_back(PropertyBase* p) { property_vector_.push_back(p); }
823 
824  private:
827  Properties();
828  ~Properties();
829 
833  int initialization_count_;
834 
839  bool owns_properties_;
840  PropertyVector property_vector_;
841  };
842 
845  RewriteOptions::Filter filter_enum;
846  const char* filter_id;
847  const char* filter_name;
848  };
849 
850  static bool ParseRewriteLevel(const StringPiece& in, RewriteLevel* out);
851 
852  typedef std::set<semantic_type::Category> ResourceCategorySet;
853 
854  static bool ParseInlineUnauthorizedResourceType(
855  const StringPiece& in,
856  ResourceCategorySet* resource_types);
857 
861  static bool ParseBeaconUrl(const StringPiece& in, BeaconUrl* out);
862 
866  bool ImageOptimizationEnabled() const;
867 
868  explicit RewriteOptions(ThreadSystem* thread_system);
869  virtual ~RewriteOptions();
870 
874  static bool Initialize();
875  static bool Terminate();
876 
877 #ifndef NDEBUG
878  bool ModificationOK() const;
885 
892  bool MergeOK() const;
893 #endif
894 
899  void InitializeOptions(const Properties* properties);
900 
901  bool modified() const { return modified_; }
902 
910  level_.set_default(level);
911  }
912  void SetRewriteLevel(RewriteLevel level) {
913  set_option(level, &level_);
914  }
915 
917  void AddCustomFetchHeader(const StringPiece& name, const StringPiece& value);
918 
919  const NameValue* custom_fetch_header(int i) const {
920  return custom_fetch_headers_[i];
921  }
922 
923  int num_custom_fetch_headers() const {
924  return custom_fetch_headers_.size();
925  }
926 
929  ExperimentSpec* GetExperimentSpec(int id) const;
930 
934  bool AvailableExperimentId(int id);
935 
938  virtual ExperimentSpec* AddExperimentSpec(const StringPiece& spec,
939  MessageHandler* handler);
940 
948  virtual bool SetExperimentState(int id);
949 
953  void SetExperimentStateStr(const StringPiece& experiment_index);
954 
955  int experiment_id() const { return experiment_id_; }
956 
957  int experiment_spec_id(int i) const {
958  return experiment_specs_[i]->id();
959  }
960 
965  GoogleString GetExperimentStateStr() const;
966 
967  ExperimentSpec* experiment_spec(int i) const {
968  return experiment_specs_[i];
969  }
970 
971  int num_experiments() const { return experiment_specs_.size(); }
972 
973  bool enroll_experiment() const {
974  return enroll_experiment_id() != experiment::kForceNoExperiment;
975  }
976 
988  void AddUrlValuedAttribute(const StringPiece& element,
989  const StringPiece& attribute,
990  semantic_type::Category category);
991 
994  void UrlValuedAttribute(int index,
995  StringPiece* element,
996  StringPiece* attribute,
997  semantic_type::Category* category) const;
998 
999  int num_url_valued_attributes() const {
1000  if (url_valued_attributes_ == NULL) {
1001  return 0;
1002  } else {
1003  return url_valued_attributes_->size();
1004  }
1005  }
1006 
1007  void AddInlineUnauthorizedResourceType(semantic_type::Category category);
1008  bool HasInlineUnauthorizedResourceType(
1009  semantic_type::Category category) const;
1010  void ClearInlineUnauthorizedResourceTypes();
1011  void set_inline_unauthorized_resource_types(ResourceCategorySet x);
1012 
1015  uint64 bytes, StringPiece md5_hash, StringPiece canonical_url) {
1016  return WriteableJavascriptLibraryIdentification()->RegisterLibrary(
1017  bytes, md5_hash, canonical_url);
1018  }
1019 
1023  const {
1024  if (Enabled(kCanonicalizeJavascriptLibraries)) {
1025  return javascript_library_identification_.get();
1026  } else {
1027  return NULL;
1028  }
1029  }
1030 
1031  RewriteLevel level() const { return level_.value(); }
1032 
1037  bool AdjustFiltersByCommaSeparatedList(const StringPiece& filters,
1038  MessageHandler* handler);
1039 
1043  bool EnableFiltersByCommaSeparatedList(const StringPiece& filters,
1044  MessageHandler* handler);
1045 
1049  bool DisableFiltersByCommaSeparatedList(const StringPiece& filters,
1050  MessageHandler* handler);
1051 
1055  bool ForbidFiltersByCommaSeparatedList(const StringPiece& filters,
1056  MessageHandler* handler);
1057 
1059  void DisableAllFilters();
1060 
1069 
1072  void DistributeFiltersByCommaSeparatedList(const StringPiece& filter_ids,
1073  MessageHandler* handler);
1076  void DistributeFilter(const StringPiece& filter_id);
1077 
1080  bool Distributable(const StringPiece& filter_id) const;
1081 
1085  void EnableFilter(Filter filter);
1088  void ForceEnableFilter(Filter filter);
1089  void DisableFilter(Filter filter);
1090  void DisableIfNotExplictlyEnabled(Filter filter);
1091  void ForbidFilter(Filter filter);
1092  void EnableFilters(const FilterSet& filter_set);
1093  void DisableFilters(const FilterSet& filter_set);
1094  void ForbidFilters(const FilterSet& filter_set);
1097  void ClearFilters();
1098 
1116  void SoftEnableFilterForTesting(Filter filter);
1117 
1120  void EnableExtendCacheFilters();
1121 
1122  bool Enabled(Filter filter) const;
1123  bool Forbidden(Filter filter) const;
1124  bool Forbidden(StringPiece filter_id) const;
1125 
1127  void GetEnabledFiltersRequiringScriptExecution(FilterVector* filters) const;
1128 
1131 
1137  const StringPiece& options, OptionSet* set, MessageHandler* handler);
1138 
1144  StringPiece name, StringPiece value, GoogleString* msg);
1145 
1148  StringPiece name, StringPiece value);
1149 
1153  OptionSettingResult SetOptionFromQuery(StringPiece name, StringPiece value);
1154 
1160  StringPiece name, StringPiece arg,
1161  GoogleString* msg, MessageHandler* handler);
1162 
1163  virtual OptionSettingResult ParseAndSetOptionFromName2(
1164  StringPiece name, StringPiece arg1, StringPiece arg2,
1165  GoogleString* msg, MessageHandler* handler);
1166 
1167  virtual OptionSettingResult ParseAndSetOptionFromName3(
1168  StringPiece name, StringPiece arg1, StringPiece arg2, StringPiece arg3,
1169  GoogleString* msg, MessageHandler* handler);
1170 
1176  bool OptionValue(StringPiece option_name, const char** id,
1177  bool* was_set, GoogleString* value) const;
1178 
1181  bool SetOptionsFromName(const OptionSet& option_set, MessageHandler* handler);
1182 
1185  bool SetOptionFromNameAndLog(StringPiece name,
1186  StringPiece value,
1187  MessageHandler* handler);
1188 
1191  static bool ParseFromString(StringPiece value_string, bool* value);
1192  static bool ParseFromString(StringPiece value_string, EnabledEnum* value);
1193  static bool ParseFromString(StringPiece value_string, int* value) {
1194  return StringToInt(value_string, value);
1195  }
1196  static bool ParseFromString(StringPiece value_string, int64* value) {
1197  return StringToInt64(value_string, value);
1198  }
1199  static bool ParseFromString(StringPiece value_string, GoogleString* value) {
1200  value_string.CopyToString(value);
1201  return true;
1202  }
1203  static bool ParseFromString(StringPiece value_string, RewriteLevel* value) {
1204  return ParseRewriteLevel(value_string, value);
1205  }
1206  static bool ParseFromString(StringPiece value_string,
1207  ResourceCategorySet* value) {
1208  return ParseInlineUnauthorizedResourceType(value_string, value);
1209  }
1210  static bool ParseFromString(StringPiece value_string, BeaconUrl* value) {
1211  return ParseBeaconUrl(value_string, value);
1212  }
1213  static bool ParseFromString(StringPiece value_string,
1214  protobuf::MessageLite* proto);
1215 
1218  int64 css_outline_min_bytes() const { return css_outline_min_bytes_.value(); }
1219  void set_css_outline_min_bytes(int64 x) {
1220  set_option(x, &css_outline_min_bytes_);
1221  }
1222 
1223  GoogleString ga_id() const { return ga_id_.value(); }
1224  void set_ga_id(GoogleString id) {
1225  set_option(id, &ga_id_);
1226  }
1227 
1228  bool increase_speed_tracking() const {
1229  return increase_speed_tracking_.value();
1230  }
1231  void set_increase_speed_tracking(bool x) {
1232  set_option(x, &increase_speed_tracking_);
1233  }
1234 
1235  int64 js_outline_min_bytes() const { return js_outline_min_bytes_.value(); }
1236  void set_js_outline_min_bytes(int64 x) {
1237  set_option(x, &js_outline_min_bytes_);
1238  }
1239 
1240  int64 progressive_jpeg_min_bytes() const {
1241  return progressive_jpeg_min_bytes_.value();
1242  }
1243  void set_progressive_jpeg_min_bytes(int64 x) {
1244  set_option(x, &progressive_jpeg_min_bytes_);
1245  }
1246 
1247  int64 css_flatten_max_bytes() const { return css_flatten_max_bytes_.value(); }
1248  void set_css_flatten_max_bytes(int64 x) {
1249  set_option(x, &css_flatten_max_bytes_);
1250  }
1251  bool cache_small_images_unrewritten() const {
1252  return cache_small_images_unrewritten_.value();
1253  }
1254  void set_cache_small_images_unrewritten(bool x) {
1255  set_option(x, &cache_small_images_unrewritten_);
1256  }
1257  int64 image_resolution_limit_bytes() const {
1258  return image_resolution_limit_bytes_.value();
1259  }
1260  void set_image_resolution_limit_bytes(int64 x) {
1261  set_option(x, &image_resolution_limit_bytes_);
1262  }
1263 
1265  int64 ImageInlineMaxBytes() const;
1266  void set_image_inline_max_bytes(int64 x);
1268  int64 CssImageInlineMaxBytes() const;
1269  void set_css_image_inline_max_bytes(int64 x) {
1270  set_option(x, &css_image_inline_max_bytes_);
1271  }
1273  int64 MaxImageInlineMaxBytes() const;
1274  int64 css_inline_max_bytes() const { return css_inline_max_bytes_.value(); }
1275  void set_css_inline_max_bytes(int64 x) {
1276  set_option(x, &css_inline_max_bytes_);
1277  }
1278  int64 js_inline_max_bytes() const { return js_inline_max_bytes_.value(); }
1279  void set_js_inline_max_bytes(int64 x) {
1280  set_option(x, &js_inline_max_bytes_);
1281  }
1282  int64 max_html_cache_time_ms() const {
1283  return max_html_cache_time_ms_.value();
1284  }
1285  void set_max_html_cache_time_ms(int64 x) {
1286  set_option(x, &max_html_cache_time_ms_);
1287  }
1288  int64 max_html_parse_bytes() const {
1289  return max_html_parse_bytes_.value();
1290  }
1291  void set_max_html_parse_bytes(int64 x) {
1292  set_option(x, &max_html_parse_bytes_);
1293  }
1294  int64 max_image_bytes_for_webp_in_css() const {
1295  return max_image_bytes_for_webp_in_css_.value();
1296  }
1297  void set_max_image_bytes_for_webp_in_css(int64 x) {
1298  set_option(x, &max_image_bytes_for_webp_in_css_);
1299  }
1300  int64 max_cacheable_response_content_length() const {
1301  return max_cacheable_response_content_length_.value();
1302  }
1303  void set_max_cacheable_response_content_length(int64 x) {
1304  set_option(x, &max_cacheable_response_content_length_);
1305  }
1306  int64 min_resource_cache_time_to_rewrite_ms() const {
1307  return min_resource_cache_time_to_rewrite_ms_.value();
1308  }
1309  void set_min_resource_cache_time_to_rewrite_ms(int64 x) {
1310  set_option(x, &min_resource_cache_time_to_rewrite_ms_);
1311  }
1312  bool need_to_store_experiment_data() const {
1313  return need_to_store_experiment_data_;
1314  }
1315  void set_need_to_store_experiment_data(bool x) {
1316  need_to_store_experiment_data_ = x;
1317  }
1318 
1319  int64 blocking_fetch_timeout_ms() const {
1320  return blocking_fetch_timeout_ms_.value();
1321  }
1322  void set_blocking_fetch_timeout_ms(int64 x) {
1323  set_option(x, &blocking_fetch_timeout_ms_);
1324  }
1325  bool override_ie_document_mode() const {
1326  return override_ie_document_mode_.value();
1327  }
1328  void set_override_ie_document_mode(bool x) {
1329  set_option(x, &override_ie_document_mode_);
1330  }
1331 
1332  int64 blink_blacklist_end_timestamp_ms() const {
1333  return blink_blacklist_end_timestamp_ms_.value();
1334  }
1335  void set_blink_blacklist_end_timestamp_ms(int64 x) {
1336  set_option(x, &blink_blacklist_end_timestamp_ms_);
1337  }
1338 
1339  bool persist_blink_blacklist() const {
1340  return persist_blink_blacklist_.value();
1341  }
1342  void set_persist_blink_blacklist(bool x) {
1343  set_option(x, &persist_blink_blacklist_);
1344  }
1345 
1346  bool preserve_url_relativity() const {
1347  return preserve_url_relativity_.value();
1348  }
1349  void set_preserve_url_relativity(bool x) {
1350  set_option(x, &preserve_url_relativity_);
1351  }
1352 
1369  bool IsUrlCacheValid(StringPiece url, int64 time_ms,
1370  bool search_wildcards) const;
1371 
1388  void AddUrlCacheInvalidationEntry(StringPiece url_pattern,
1389  int64 timestamp_ms,
1390  bool ignores_metadata_and_pcache);
1391 
1393  void PurgeUrl(StringPiece url, int64 timestamp_ms);
1394 
1398 
1401  void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock* lock) {
1402  cache_purge_mutex_.reset(lock);
1403  }
1404 
1409  int64 cache_invalidation_timestamp() const;
1410 
1415 
1424  bool UpdateCacheInvalidationTimestampMs(int64 timestamp_ms)
1425  LOCKS_EXCLUDED(cache_purge_mutex_.get());
1426 
1430  bool UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set)
1431  LOCKS_EXCLUDED(cache_purge_mutex_.get());
1432 
1435  GoogleString PurgeSetString() const;
1436 
1439  int64 idle_flush_time_ms() const {
1440  return idle_flush_time_ms_.value();
1441  }
1442  void set_idle_flush_time_ms(int64 x) {
1443  set_option(x, &idle_flush_time_ms_);
1444  }
1445 
1448  return flush_buffer_limit_bytes_.value();
1449  }
1450 
1451  void set_flush_buffer_limit_bytes(int64 x) {
1452  set_option(x, &flush_buffer_limit_bytes_);
1453  }
1454 
1457  int max_url_segment_size() const { return max_url_segment_size_.value(); }
1458  void set_max_url_segment_size(int x) {
1459  set_option(x, &max_url_segment_size_);
1460  }
1461 
1462  int image_max_rewrites_at_once() const {
1463  return image_max_rewrites_at_once_.value();
1464  }
1465  void set_image_max_rewrites_at_once(int x) {
1466  set_option(x, &image_max_rewrites_at_once_);
1467  }
1468 
1470  int max_url_size() const { return max_url_size_.value(); }
1471  void set_max_url_size(int x) {
1472  set_option(x, &max_url_size_);
1473  }
1474 
1475  int rewrite_deadline_ms() const { return rewrite_deadline_ms_.value(); }
1476  void set_rewrite_deadline_ms(int x) {
1477  set_option(x, &rewrite_deadline_ms_);
1478  }
1479 
1480  bool test_instant_fetch_rewrite_deadline() const {
1481  return test_instant_fetch_rewrite_deadline_.value();
1482  }
1483  void set_test_instant_fetch_rewrite_deadline(bool x) {
1484  set_option(x, &test_instant_fetch_rewrite_deadline_);
1485  }
1486 
1487  void set_test_only_prioritize_critical_css_dont_apply_original_css(bool x) {
1488  set_option(x, &test_only_prioritize_critical_css_dont_apply_original_css_);
1489  }
1490  bool test_only_prioritize_critical_css_dont_apply_original_css() const {
1491  return test_only_prioritize_critical_css_dont_apply_original_css_.value();
1492  }
1493 
1494  int domain_shard_count() const { return domain_shard_count_.value(); }
1497  void set_domain_shard_count(int64 x) {
1498  int value = x;
1499  set_option(value, &domain_shard_count_);
1500  }
1501 
1502  void set_enabled(EnabledEnum x) {
1503  set_option(x, &enabled_);
1504  }
1505  bool enabled() const {
1506  return enabled_.value() == kEnabledOn;
1507  }
1508  bool unplugged() const {
1509  return enabled_.value() == kEnabledUnplugged;
1510  }
1511 
1512  void set_add_options_to_urls(bool x) {
1513  set_option(x, &add_options_to_urls_);
1514  }
1515 
1516  bool add_options_to_urls() const {
1517  return add_options_to_urls_.value();
1518  }
1519 
1520  void set_publicly_cache_mismatched_hashes_experimental(bool x) {
1521  set_option(x, &publicly_cache_mismatched_hashes_experimental_);
1522  }
1523 
1524  bool publicly_cache_mismatched_hashes_experimental() const {
1525  return publicly_cache_mismatched_hashes_experimental_.value();
1526  }
1527 
1528  void set_oblivious_pagespeed_urls(bool x) {
1529  set_option(x, &oblivious_pagespeed_urls_);
1530  }
1531 
1532  bool oblivious_pagespeed_urls() const {
1533  return oblivious_pagespeed_urls_.value();
1534  }
1535 
1536  void set_in_place_rewriting_enabled(bool x) {
1537  set_option(x, &in_place_rewriting_enabled_);
1538  }
1539 
1540  bool in_place_rewriting_enabled() const {
1541  return CheckBandwidthOption(in_place_rewriting_enabled_);
1542  }
1543 
1544  void set_in_place_wait_for_optimized(bool x) {
1545  set_option(x, &in_place_wait_for_optimized_);
1546  }
1547 
1548  bool in_place_wait_for_optimized() const {
1549  return (in_place_wait_for_optimized_.value() ||
1550  (in_place_rewrite_deadline_ms() < 0));
1551  }
1552 
1553  void set_in_place_rewrite_deadline_ms(int x) {
1554  set_option(x, &in_place_rewrite_deadline_ms_);
1555  }
1556 
1557  int in_place_rewrite_deadline_ms() const {
1558  return in_place_rewrite_deadline_ms_.value();
1559  }
1560 
1561  void set_in_place_preemptive_rewrite_css(bool x) {
1562  set_option(x, &in_place_preemptive_rewrite_css_);
1563  }
1564  bool in_place_preemptive_rewrite_css() const {
1565  return CheckBandwidthOption(in_place_preemptive_rewrite_css_);
1566  }
1567 
1568  void set_in_place_preemptive_rewrite_css_images(bool x) {
1569  set_option(x, &in_place_preemptive_rewrite_css_images_);
1570  }
1571  bool in_place_preemptive_rewrite_css_images() const {
1572  return CheckBandwidthOption(in_place_preemptive_rewrite_css_images_);
1573  }
1574 
1575  void set_in_place_preemptive_rewrite_images(bool x) {
1576  set_option(x, &in_place_preemptive_rewrite_images_);
1577  }
1578  bool in_place_preemptive_rewrite_images() const {
1579  return CheckBandwidthOption(in_place_preemptive_rewrite_images_);
1580  }
1581 
1582  void set_in_place_preemptive_rewrite_javascript(bool x) {
1583  set_option(x, &in_place_preemptive_rewrite_javascript_);
1584  }
1585  bool in_place_preemptive_rewrite_javascript() const {
1586  return CheckBandwidthOption(in_place_preemptive_rewrite_javascript_);
1587  }
1588 
1589  void set_private_not_vary_for_ie(bool x) {
1590  set_option(x, &private_not_vary_for_ie_);
1591  }
1592  bool private_not_vary_for_ie() const {
1593  return private_not_vary_for_ie_.value();
1594  }
1595 
1596  void set_combine_across_paths(bool x) {
1597  set_option(x, &combine_across_paths_);
1598  }
1599  bool combine_across_paths() const { return combine_across_paths_.value(); }
1600 
1601  void set_log_background_rewrites(bool x) {
1602  set_option(x, &log_background_rewrites_);
1603  }
1604  bool log_background_rewrites() const {
1605  return log_background_rewrites_.value();
1606  }
1607 
1608  void set_log_rewrite_timing(bool x) {
1609  set_option(x, &log_rewrite_timing_);
1610  }
1611  bool log_rewrite_timing() const { return log_rewrite_timing_.value(); }
1612 
1613  void set_log_url_indices(bool x) {
1614  set_option(x, &log_url_indices_);
1615  }
1616  bool log_url_indices() const { return log_url_indices_.value(); }
1617 
1618  void set_lowercase_html_names(bool x) {
1619  set_option(x, &lowercase_html_names_);
1620  }
1621  bool lowercase_html_names() const { return lowercase_html_names_.value(); }
1622 
1623  void set_always_rewrite_css(bool x) {
1624  set_option(x, &always_rewrite_css_);
1625  }
1626  bool always_rewrite_css() const { return always_rewrite_css_.value(); }
1627 
1628  void set_respect_vary(bool x) {
1629  set_option(x, &respect_vary_);
1630  }
1631  bool respect_vary() const { return respect_vary_.value(); }
1632 
1633  void set_respect_x_forwarded_proto(bool x) {
1634  set_option(x, &respect_x_forwarded_proto_);
1635  }
1636  bool respect_x_forwarded_proto() const {
1637  return respect_x_forwarded_proto_.value();
1638  }
1639 
1640  void set_flush_html(bool x) { set_option(x, &flush_html_); }
1641  bool flush_html() const { return flush_html_.value(); }
1642 
1643  void set_serve_split_html_in_two_chunks(bool x) {
1644  set_option(x, &serve_split_html_in_two_chunks_);
1645  }
1646  bool serve_split_html_in_two_chunks() const {
1647  return serve_split_html_in_two_chunks_.value();
1648  }
1649 
1650  void set_serve_stale_if_fetch_error(bool x) {
1651  set_option(x, &serve_stale_if_fetch_error_);
1652  }
1653  bool serve_stale_if_fetch_error() const {
1654  return serve_stale_if_fetch_error_.value();
1655  }
1656 
1657  void set_serve_ghost_click_buster_with_split_html(bool x) {
1658  set_option(x, &serve_ghost_click_buster_with_split_html_);
1659  }
1660  bool serve_ghost_click_buster_with_split_html() const {
1661  return serve_ghost_click_buster_with_split_html_.value();
1662  }
1663 
1664  void set_serve_xhr_access_control_headers(bool x) {
1665  set_option(x, &serve_xhr_access_control_headers_);
1666  }
1667  bool serve_xhr_access_control_headers() const {
1668  return serve_xhr_access_control_headers_.value();
1669  }
1670 
1671  void set_proactively_freshen_user_facing_request(bool x) {
1672  set_option(x, &proactively_freshen_user_facing_request_);
1673  }
1674  bool proactively_freshen_user_facing_request() const {
1675  return proactively_freshen_user_facing_request_.value();
1676  }
1677 
1678  void set_serve_stale_while_revalidate_threshold_sec(int64 x) {
1679  set_option(x, &serve_stale_while_revalidate_threshold_sec_);
1680  }
1681  int64 serve_stale_while_revalidate_threshold_sec() const {
1682  return serve_stale_while_revalidate_threshold_sec_.value();
1683  }
1684 
1685  void set_enable_flush_early_critical_css(bool x) {
1686  set_option(x, &enable_flush_early_critical_css_);
1687  }
1688  bool enable_flush_early_critical_css() const {
1689  return enable_flush_early_critical_css_.value();
1690  }
1691 
1692  void set_use_selectors_for_critical_css(bool x) {
1693  set_option(x, &use_selectors_for_critical_css_);
1694  }
1695  bool use_selectors_for_critical_css() const {
1696  return use_selectors_for_critical_css_.value();
1697  }
1698 
1699  void set_default_cache_html(bool x) { set_option(x, &default_cache_html_); }
1700  bool default_cache_html() const { return default_cache_html_.value(); }
1701 
1702  void set_modify_caching_headers(bool x) {
1703  set_option(x, &modify_caching_headers_);
1704  }
1705  bool modify_caching_headers() const {
1706  return modify_caching_headers_.value();
1707  }
1708 
1709  void set_inline_only_critical_images(bool x) {
1710  set_option(x, &inline_only_critical_images_);
1711  }
1712  bool inline_only_critical_images() const {
1713  return inline_only_critical_images_.value();
1714  }
1715 
1716  void set_critical_images_beacon_enabled(bool x) {
1717  set_option(x, &critical_images_beacon_enabled_);
1718  }
1719  bool critical_images_beacon_enabled() const {
1720  return critical_images_beacon_enabled_.value();
1721  }
1722 
1723  void set_beacon_reinstrument_time_sec(int x) {
1724  set_option(x, &beacon_reinstrument_time_sec_);
1725  }
1726  int beacon_reinstrument_time_sec() const {
1727  return beacon_reinstrument_time_sec_.value();
1728  }
1729 
1730  void set_accept_invalid_signatures(bool x) {
1731  set_option(x, &accept_invalid_signatures_);
1732  }
1733  bool accept_invalid_signatures() const {
1734  return accept_invalid_signatures_.value();
1735  }
1736 
1737  void set_request_option_override(StringPiece p) {
1738  set_option(GoogleString(p.data(), p.size()), &request_option_override_);
1739  }
1740  const GoogleString& request_option_override() const {
1741  return request_option_override_.value();
1742  }
1743 
1744  void set_url_signing_key(StringPiece p) {
1745  set_option(GoogleString(p.data(), p.size()), &url_signing_key_);
1746  }
1747  const GoogleString& url_signing_key() const {
1748  return url_signing_key_.value();
1749  }
1750 
1751  void set_lazyload_images_after_onload(bool x) {
1752  set_option(x, &lazyload_images_after_onload_);
1753  }
1754  bool lazyload_images_after_onload() const {
1755  return lazyload_images_after_onload_.value();
1756  }
1757 
1758  void set_lazyload_images_blank_url(const StringPiece& p) {
1759  set_option(GoogleString(p.data(), p.size()), &lazyload_images_blank_url_);
1760  }
1761  const GoogleString& lazyload_images_blank_url() const {
1762  return lazyload_images_blank_url_.value();
1763  }
1764 
1765  void set_max_inlined_preview_images_index(int x) {
1766  set_option(x, &max_inlined_preview_images_index_);
1767  }
1768  int max_inlined_preview_images_index() const {
1769  return max_inlined_preview_images_index_.value();
1770  }
1771 
1772  void set_use_blank_image_for_inline_preview(bool x) {
1773  set_option(x, &use_blank_image_for_inline_preview_);
1774  }
1775  bool use_blank_image_for_inline_preview() const {
1776  return use_blank_image_for_inline_preview_.value();
1777  }
1778 
1779  void set_min_image_size_low_resolution_bytes(int64 x) {
1780  set_option(x, &min_image_size_low_resolution_bytes_);
1781  }
1782  int64 min_image_size_low_resolution_bytes() const {
1783  return min_image_size_low_resolution_bytes_.value();
1784  }
1785 
1786  void set_max_image_size_low_resolution_bytes(int64 x) {
1787  set_option(x, &max_image_size_low_resolution_bytes_);
1788  }
1789  int64 max_image_size_low_resolution_bytes() const {
1790  return max_image_size_low_resolution_bytes_.value();
1791  }
1792 
1793  void set_experiment_cookie_duration_ms(int64 x) {
1794  set_option(x, &experiment_cookie_duration_ms_);
1795  }
1796  int64 experiment_cookie_duration_ms() const {
1797  return experiment_cookie_duration_ms_.value();
1798  }
1799 
1800  void set_finder_properties_cache_expiration_time_ms(int64 x) {
1801  set_option(x, &finder_properties_cache_expiration_time_ms_);
1802  }
1803  int64 finder_properties_cache_expiration_time_ms() const {
1804  return finder_properties_cache_expiration_time_ms_.value();
1805  }
1806 
1807  void set_finder_properties_cache_refresh_time_ms(int64 x) {
1808  set_option(x, &finder_properties_cache_refresh_time_ms_);
1809  }
1810  int64 finder_properties_cache_refresh_time_ms() const {
1811  return finder_properties_cache_refresh_time_ms_.value();
1812  }
1813 
1814  void set_rewrite_random_drop_percentage(int x) {
1815  set_option(x, &rewrite_random_drop_percentage_);
1816  }
1817  int rewrite_random_drop_percentage() const {
1818  return rewrite_random_drop_percentage_.value();
1819  }
1820 
1821  bool css_preserve_urls() const {
1822  return CheckBandwidthOption(css_preserve_urls_);
1823  }
1824  void set_css_preserve_urls(bool x) {
1825  set_option(x, &css_preserve_urls_);
1826  }
1827 
1828  bool image_preserve_urls() const {
1829  return CheckBandwidthOption(image_preserve_urls_);
1830  }
1831  void set_image_preserve_urls(bool x) {
1832  set_option(x, &image_preserve_urls_);
1833  }
1834 
1835  bool js_preserve_urls() const {
1836  return CheckBandwidthOption(js_preserve_urls_);
1837  }
1838  void set_js_preserve_urls(bool x) {
1839  set_option(x, &js_preserve_urls_);
1840  }
1841 
1842  void set_metadata_cache_staleness_threshold_ms(int64 x) {
1843  set_option(x, &metadata_cache_staleness_threshold_ms_);
1844  }
1845  int64 metadata_cache_staleness_threshold_ms() const {
1846  return metadata_cache_staleness_threshold_ms_.value();
1847  }
1848 
1849  void set_metadata_input_errors_cache_ttl_ms(int64 x) {
1850  set_option(x, &metadata_input_errors_cache_ttl_ms_);
1851  }
1852  int64 metadata_input_errors_cache_ttl_ms() const {
1853  return metadata_input_errors_cache_ttl_ms_.value();
1854  }
1855 
1856  const GoogleString& downstream_cache_purge_method() const {
1857  return downstream_cache_purge_method_.value();
1858  }
1859  void set_downstream_cache_purge_method(const StringPiece& p) {
1860  set_option(p.as_string(), &downstream_cache_purge_method_);
1861  }
1862 
1863  const GoogleString& downstream_cache_purge_location_prefix() const {
1864  return downstream_cache_purge_location_prefix_.value();
1865  }
1869  while (p.ends_with("/")) {
1870  p.remove_suffix(1);
1871  }
1872  set_option(p.as_string(), &downstream_cache_purge_location_prefix_);
1873  }
1874  bool IsDownstreamCacheIntegrationEnabled() const {
1875  return !downstream_cache_purge_location_prefix().empty();
1876  }
1877 
1878  void set_downstream_cache_rebeaconing_key(const StringPiece& p) {
1879  set_option(p.as_string(), &downstream_cache_rebeaconing_key_);
1880  }
1881  const GoogleString& downstream_cache_rebeaconing_key() const {
1882  return downstream_cache_rebeaconing_key_.value();
1883  }
1884  bool IsDownstreamCacheRebeaconingKeyConfigured() const {
1885  return !downstream_cache_rebeaconing_key().empty();
1886  }
1889  bool MatchesDownstreamCacheRebeaconingKey(StringPiece key) const {
1890  if (!IsDownstreamCacheRebeaconingKeyConfigured()) {
1891  return false;
1892  }
1893  return StringCaseEqual(key, downstream_cache_rebeaconing_key());
1894  }
1895 
1896  void set_downstream_cache_rewritten_percentage_threshold(int64 x) {
1897  set_option(x, &downstream_cache_rewritten_percentage_threshold_);
1898  }
1899  int64 downstream_cache_rewritten_percentage_threshold() const {
1900  return downstream_cache_rewritten_percentage_threshold_.value();
1901  }
1902 
1903  const BeaconUrl& beacon_url() const { return beacon_url_.value(); }
1904  void set_beacon_url(const GoogleString& beacon_url) {
1905  GoogleString ignored_error_detail;
1906  beacon_url_.SetFromString(beacon_url, &ignored_error_detail);
1907  }
1908 
1910  virtual bool trim_urls_in_css() const { return true; }
1911 
1912  int64 image_jpeg_recompress_quality() const {
1913  return image_jpeg_recompress_quality_.value();
1914  }
1915  void set_image_jpeg_recompress_quality(int64 x) {
1916  set_option(x, &image_jpeg_recompress_quality_);
1917  }
1918 
1919  int64 image_jpeg_recompress_quality_for_small_screens() const {
1920  return image_jpeg_recompress_quality_for_small_screens_.value();
1921  }
1922  void set_image_jpeg_recompress_quality_for_small_screens(int64 x) {
1923  set_option(x, &image_jpeg_recompress_quality_for_small_screens_);
1924  }
1925 
1926  int64 image_recompress_quality() const {
1927  return image_recompress_quality_.value();
1928  }
1929  void set_image_recompress_quality(int64 x) {
1930  set_option(x, &image_recompress_quality_);
1931  }
1932 
1933  int image_limit_optimized_percent() const {
1934  return image_limit_optimized_percent_.value();
1935  }
1936  void set_image_limit_optimized_percent(int x) {
1937  set_option(x, &image_limit_optimized_percent_);
1938  }
1939  int image_limit_resize_area_percent() const {
1940  return image_limit_resize_area_percent_.value();
1941  }
1942  void set_image_limit_resize_area_percent(int x) {
1943  set_option(x, &image_limit_resize_area_percent_);
1944  }
1945 
1946  int image_limit_rendered_area_percent() const {
1947  return image_limit_rendered_area_percent_.value();
1948  }
1949  void set_image_limit_rendered_area_percent(int x) {
1950  set_option(x, &image_limit_rendered_area_percent_);
1951  }
1952 
1953  int64 image_jpeg_num_progressive_scans() const {
1954  return image_jpeg_num_progressive_scans_.value();
1955  }
1956  void set_image_jpeg_num_progressive_scans(int64 x) {
1957  set_option(x, &image_jpeg_num_progressive_scans_);
1958  }
1959 
1960  int64 image_jpeg_num_progressive_scans_for_small_screens() const {
1961  return image_jpeg_num_progressive_scans_for_small_screens_.value();
1962  }
1963  void set_image_jpeg_num_progressive_scans_for_small_screens(int64 x) {
1964  set_option(x, &image_jpeg_num_progressive_scans_for_small_screens_);
1965  }
1966 
1967  int64 image_webp_recompress_quality() const {
1968  return image_webp_recompress_quality_.value();
1969  }
1970  void set_image_webp_recompress_quality(int64 x) {
1971  set_option(x, &image_webp_recompress_quality_);
1972  }
1973 
1974  int64 image_webp_recompress_quality_for_small_screens() const {
1975  return image_webp_recompress_quality_for_small_screens_.value();
1976  }
1977  void set_image_webp_recompress_quality_for_small_screens(int64 x) {
1978  set_option(x, &image_webp_recompress_quality_for_small_screens_);
1979  }
1980  int64 image_webp_timeout_ms() const {
1981  return image_webp_timeout_ms_.value();
1982  }
1983  void set_image_webp_timeout_ms(int64 x) {
1984  set_option(x, &image_webp_timeout_ms_);
1985  }
1986 
1987  bool domain_rewrite_hyperlinks() const {
1988  return domain_rewrite_hyperlinks_.value();
1989  }
1990  void set_domain_rewrite_hyperlinks(bool x) {
1991  set_option(x, &domain_rewrite_hyperlinks_);
1992  }
1993 
1994  bool client_domain_rewrite() const {
1995  return client_domain_rewrite_.value();
1996  }
1997  void set_client_domain_rewrite(bool x) {
1998  set_option(x, &client_domain_rewrite_);
1999  }
2000 
2001  void set_flush_more_resources_early_if_time_permits(bool x) {
2002  set_option(x, &flush_more_resources_early_if_time_permits_);
2003  }
2004  bool flush_more_resources_early_if_time_permits() const {
2005  return flush_more_resources_early_if_time_permits_.value();
2006  }
2007 
2008  void set_flush_more_resources_in_ie_and_firefox(bool x) {
2009  set_option(x, &flush_more_resources_in_ie_and_firefox_);
2010  }
2011  bool flush_more_resources_in_ie_and_firefox() const {
2012  return flush_more_resources_in_ie_and_firefox_.value();
2013  }
2014 
2015  void set_max_prefetch_js_elements(int x) {
2016  set_option(x, &max_prefetch_js_elements_);
2017  }
2018  int max_prefetch_js_elements() const {
2019  return max_prefetch_js_elements_.value();
2020  }
2021 
2022  void set_enable_defer_js_experimental(bool x) {
2023  set_option(x, &enable_defer_js_experimental_);
2024  }
2025  bool enable_defer_js_experimental() const {
2026  return enable_defer_js_experimental_.value();
2027  }
2028 
2029  void set_disable_rewrite_on_no_transform(bool x) {
2030  set_option(x, &disable_rewrite_on_no_transform_);
2031  }
2032  bool disable_rewrite_on_no_transform() const {
2033  return disable_rewrite_on_no_transform_.value();
2034  }
2035 
2036  void set_disable_background_fetches_for_bots(bool x) {
2037  set_option(x, &disable_background_fetches_for_bots_);
2038  }
2039  bool disable_background_fetches_for_bots() const {
2040  return disable_background_fetches_for_bots_.value();
2041  }
2042 
2043  void set_enable_cache_purge(bool x) {
2044  set_option(x, &enable_cache_purge_);
2045  }
2046  bool enable_cache_purge() const {
2047  return enable_cache_purge_.value();
2048  }
2049 
2050  void set_proactive_resource_freshening(bool x) {
2051  set_option(x, &proactive_resource_freshening_);
2052  }
2053  bool proactive_resource_freshening() const {
2054  return proactive_resource_freshening_.value();
2055  }
2056 
2057  void set_lazyload_highres_images(bool x) {
2058  set_option(x, &lazyload_highres_images_);
2059  }
2060  bool lazyload_highres_images() const {
2061  return lazyload_highres_images_.value();
2062  }
2063 
2064  void set_enable_blink_debug_dashboard(bool x) {
2065  set_option(x, &enable_blink_debug_dashboard_);
2066  }
2067  bool enable_blink_debug_dashboard() const {
2068  return enable_blink_debug_dashboard_.value();
2069  }
2070 
2071  void set_enable_blink_html_change_detection(bool x) {
2072  set_option(x, &enable_blink_html_change_detection_);
2073  }
2074  bool enable_blink_html_change_detection() const {
2075  return enable_blink_html_change_detection_.value();
2076  }
2077 
2078  void set_enable_blink_html_change_detection_logging(bool x) {
2079  set_option(x, &enable_blink_html_change_detection_logging_);
2080  }
2081  bool enable_blink_html_change_detection_logging() const {
2082  return enable_blink_html_change_detection_logging_.value();
2083  }
2084 
2085  void set_use_smart_diff_in_blink(bool x) {
2086  set_option(x, &use_smart_diff_in_blink_);
2087  }
2088  bool use_smart_diff_in_blink() const {
2089  return use_smart_diff_in_blink_.value();
2090  }
2091 
2092  void set_use_fallback_property_cache_values(bool x) {
2093  set_option(x, &use_fallback_property_cache_values_);
2094  }
2095  bool use_fallback_property_cache_values() const {
2096  return use_fallback_property_cache_values_.value();
2097  }
2098 
2099  void set_await_pcache_lookup(bool x) {
2100  set_option(x, &await_pcache_lookup_);
2101  }
2102  bool await_pcache_lookup() const {
2103  return await_pcache_lookup_.value();
2104  }
2105 
2106  void set_enable_prioritizing_scripts(bool x) {
2107  set_option(x, &enable_prioritizing_scripts_);
2108  }
2109  bool enable_prioritizing_scripts() const {
2110  return enable_prioritizing_scripts_.value();
2111  }
2112 
2113  void set_blink_html_change_detection_time_ms(int64 x) {
2114  set_option(x, &blink_html_change_detection_time_ms_);
2115  }
2116  int64 blink_html_change_detection_time_ms() const {
2117  return blink_html_change_detection_time_ms_.value();
2118  }
2119 
2120  const GoogleString& blocking_rewrite_key() const {
2121  return blocking_rewrite_key_.value();
2122  }
2123  void set_blocking_rewrite_key(const StringPiece& p) {
2124  set_option(p.as_string(), &blocking_rewrite_key_);
2125  }
2126 
2127  void EnableBlockingRewriteForRefererUrlPattern(
2128  const StringPiece& url_pattern) {
2129  Modify();
2130  blocking_rewrite_referer_urls_.MakeWriteable()->Allow(url_pattern);
2131  }
2132 
2133  bool IsBlockingRewriteEnabledForReferer(const StringPiece& url) const {
2134  return blocking_rewrite_referer_urls_->Match(url, false);
2135  }
2136 
2137  bool IsBlockingRewriteRefererUrlPatternPresent() const {
2138  return blocking_rewrite_referer_urls_->num_wildcards() > 0;
2139  }
2140 
2141  bool rewrite_uncacheable_resources() const {
2142  return rewrite_uncacheable_resources_.value();
2143  }
2144 
2145  void set_rewrite_uncacheable_resources(bool x) {
2146  set_option(x, &rewrite_uncacheable_resources_);
2147  }
2148 
2149  void set_running_experiment(bool x) {
2150  set_option(x, &running_experiment_);
2151  }
2152  bool running_experiment() const {
2153  return running_experiment_.value();
2154  }
2155 
2158  set_option(x, &experiment_ga_slot_);
2159  }
2160  int experiment_ga_slot() const { return experiment_ga_slot_.value(); }
2161 
2162  void set_enroll_experiment_id(int x) {
2163  set_option(x, &enroll_experiment_id_);
2164  }
2165  int enroll_experiment_id() const { return enroll_experiment_id_.value(); }
2166 
2167  void set_report_unload_time(bool x) {
2168  set_option(x, &report_unload_time_);
2169  }
2170  bool report_unload_time() const {
2171  return report_unload_time_.value();
2172  }
2173 
2174  void set_implicit_cache_ttl_ms(int64 x) {
2175  set_option(x, &implicit_cache_ttl_ms_);
2176  }
2177  int64 implicit_cache_ttl_ms() const {
2178  return implicit_cache_ttl_ms_.value();
2179  }
2180 
2181  void set_x_header_value(const StringPiece& p) {
2182  set_option(p.as_string(), &x_header_value_);
2183  }
2184  const GoogleString& x_header_value() const {
2185  return x_header_value_.value();
2186  }
2187 
2188  void set_distributed_rewrite_key(const StringPiece& p) {
2189  set_option(p.as_string(), &distributed_rewrite_key_);
2190  }
2191  const GoogleString& distributed_rewrite_key() const {
2192  return distributed_rewrite_key_.value();
2193  }
2194 
2195  void set_distribute_fetches(bool x) {
2196  set_option(x, &distribute_fetches_);
2197  }
2198  bool distribute_fetches() const {
2199  return distribute_fetches_.value();
2200  }
2201 
2202  void set_distributed_rewrite_servers(const StringPiece& p) {
2203  set_option(p.as_string(), &distributed_rewrite_servers_);
2204  }
2205  const GoogleString& distributed_rewrite_servers() const {
2206  return distributed_rewrite_servers_.value();
2207  }
2208 
2209  void set_distributed_rewrite_timeout_ms(const int64 x) {
2210  set_option(x, &distributed_rewrite_timeout_ms_);
2211  }
2212  int64 distributed_rewrite_timeout_ms() const {
2213  return distributed_rewrite_timeout_ms_.value();
2214  }
2215 
2216  void set_avoid_renaming_introspective_javascript(bool x) {
2217  set_option(x, &avoid_renaming_introspective_javascript_);
2218  }
2219  bool avoid_renaming_introspective_javascript() const {
2220  return avoid_renaming_introspective_javascript_.value();
2221  }
2222 
2223  int64 blink_max_html_size_rewritable() const {
2224  return blink_max_html_size_rewritable_.value();
2225  }
2226  void set_blink_max_html_size_rewritable(int64 x) {
2227  set_option(x, &blink_max_html_size_rewritable_);
2228  }
2229 
2230  void set_critical_line_config(const StringPiece& p) {
2231  set_option(GoogleString(p.data(), p.size()), &critical_line_config_);
2232  }
2233  const GoogleString& critical_line_config() const {
2234  return critical_line_config_.value();
2235  }
2236 
2237  void set_forbid_all_disabled_filters(bool x) {
2238  set_option(x, &forbid_all_disabled_filters_);
2239  }
2240  bool forbid_all_disabled_filters() const {
2241  return forbid_all_disabled_filters_.value();
2242  }
2243 
2244  bool reject_blacklisted() const { return reject_blacklisted_.value(); }
2245  void set_reject_blacklisted(bool x) {
2246  set_option(x, &reject_blacklisted_);
2247  }
2248 
2249  HttpStatus::Code reject_blacklisted_status_code() const {
2250  return static_cast<HttpStatus::Code>(
2251  reject_blacklisted_status_code_.value());
2252  }
2253  void set_reject_blacklisted_status_code(HttpStatus::Code x) {
2254  set_option(static_cast<int>(x), &reject_blacklisted_status_code_);
2255  }
2256 
2257  bool support_noscript_enabled() const {
2258  return support_noscript_enabled_.value();
2259  }
2260  void set_support_noscript_enabled(bool x) {
2261  set_option(x, &support_noscript_enabled_);
2262  }
2263 
2264  bool enable_extended_instrumentation() const {
2265  return enable_extended_instrumentation_.value();
2266  }
2267  void set_enable_extended_instrumentation(bool x) {
2268  set_option(x, &enable_extended_instrumentation_);
2269  }
2270 
2271  bool use_experimental_js_minifier() const {
2272  return use_experimental_js_minifier_.value();
2273  }
2274  void set_use_experimental_js_minifier(bool x) {
2275  set_option(x, &use_experimental_js_minifier_);
2276  }
2277 
2278  void set_max_combined_css_bytes(int64 x) {
2279  set_option(x, &max_combined_css_bytes_);
2280  }
2281  int64 max_combined_css_bytes() const {
2282  return max_combined_css_bytes_.value();
2283  }
2284 
2285  void set_max_combined_js_bytes(int64 x) {
2286  set_option(x, &max_combined_js_bytes_);
2287  }
2288  int64 max_combined_js_bytes() const {
2289  return max_combined_js_bytes_.value();
2290  }
2291 
2292  void set_pre_connect_url(const StringPiece& p) {
2293  set_option(GoogleString(p.data(), p.size()), &pre_connect_url_);
2294  }
2295  const GoogleString& pre_connect_url() const {
2296  return pre_connect_url_.value();
2297  }
2298  void set_property_cache_http_status_stability_threshold(int x) {
2299  set_option(x, &property_cache_http_status_stability_threshold_);
2300  }
2301  int property_cache_http_status_stability_threshold() const {
2302  return property_cache_http_status_stability_threshold_.value();
2303  }
2304 
2305  void set_max_rewrite_info_log_size(int x) {
2306  set_option(x, &max_rewrite_info_log_size_);
2307  }
2308  int max_rewrite_info_log_size() const {
2309  return max_rewrite_info_log_size_.value();
2310  }
2311 
2312  void set_enable_aggressive_rewriters_for_mobile(bool x) {
2313  set_option(x, &enable_aggressive_rewriters_for_mobile_);
2314  }
2315  bool enable_aggressive_rewriters_for_mobile() const {
2316  return enable_aggressive_rewriters_for_mobile_.value();
2317  }
2318 
2319  void set_allow_logging_urls_in_log_record(bool x) {
2320  set_option(x, &allow_logging_urls_in_log_record_);
2321  }
2322  bool allow_logging_urls_in_log_record() const {
2323  return allow_logging_urls_in_log_record_.value();
2324  }
2325 
2326  void set_allow_options_to_be_set_by_cookies(bool x) {
2327  set_option(x, &allow_options_to_be_set_by_cookies_);
2328  }
2329  bool allow_options_to_be_set_by_cookies() const {
2330  return allow_options_to_be_set_by_cookies_.value();
2331  }
2332 
2333  void set_non_cacheables_for_cache_partial_html(const StringPiece& p) {
2334  set_option(p.as_string(), &non_cacheables_for_cache_partial_html_);
2335  }
2336  const GoogleString& non_cacheables_for_cache_partial_html() const {
2337  return non_cacheables_for_cache_partial_html_.value();
2338  }
2339 
2340  void set_no_transform_optimized_images(bool x) {
2341  set_option(x, &no_transform_optimized_images_);
2342  }
2343  bool no_transform_optimized_images() const {
2344  return no_transform_optimized_images_.value();
2345  }
2346 
2347  void set_access_control_allow_origins(const StringPiece& p) {
2348  set_option(p.as_string(), &access_control_allow_origins_);
2349  }
2350  const GoogleString& access_control_allow_origins() const {
2351  return access_control_allow_origins_.value();
2352  }
2353 
2354  void set_hide_referer_using_meta(bool x) {
2355  set_option(x, &hide_referer_using_meta_);
2356  }
2357  bool hide_referer_using_meta() const {
2358  return hide_referer_using_meta_.value();
2359  }
2360 
2361  void set_max_low_res_image_size_bytes(int64 x) {
2362  set_option(x, &max_low_res_image_size_bytes_);
2363  }
2364  int64 max_low_res_image_size_bytes() const {
2365  return max_low_res_image_size_bytes_.value();
2366  }
2367 
2368  void set_max_low_res_to_full_res_image_size_percentage(int x) {
2369  set_option(x, &max_low_res_to_full_res_image_size_percentage_);
2370  }
2371  int max_low_res_to_full_res_image_size_percentage() const {
2372  return max_low_res_to_full_res_image_size_percentage_.value();
2373  }
2374 
2375  void set_serve_rewritten_webp_urls_to_any_agent(bool x) {
2376  set_option(x, &serve_rewritten_webp_urls_to_any_agent_);
2377  }
2378  bool serve_rewritten_webp_urls_to_any_agent() const {
2379  return serve_rewritten_webp_urls_to_any_agent_.value();
2380  }
2381 
2382  void set_cache_fragment(const StringPiece& p) {
2383  set_option(p.as_string(), &cache_fragment_);
2384  }
2385  const GoogleString& cache_fragment() const {
2386  return cache_fragment_.value();
2387  }
2388 
2389  void set_sticky_query_parameters(StringPiece p) {
2390  set_option(p.as_string(), &sticky_query_parameters_);
2391  }
2392  const GoogleString& sticky_query_parameters() const {
2393  return sticky_query_parameters_.value();
2394  }
2395 
2396  void set_option_cookies_duration_ms(int64 x) {
2397  set_option(x, &option_cookies_duration_ms_);
2398  }
2399  int64 option_cookies_duration_ms() const {
2400  return option_cookies_duration_ms_.value();
2401  }
2402 
2418  virtual void Merge(const RewriteOptions& src);
2419 
2422  void Allow(const StringPiece& wildcard_pattern) {
2423  Modify();
2424  allow_resources_.MakeWriteable()->Allow(wildcard_pattern);
2425  }
2426 
2429  void Disallow(const StringPiece& wildcard_pattern) {
2430  Modify();
2431  allow_resources_.MakeWriteable()->Disallow(wildcard_pattern);
2432  }
2433 
2435  void AllowWhenInlining(const StringPiece& wildcard_pattern) {
2436  Modify();
2437  allow_when_inlining_resources_.MakeWriteable()->Allow(wildcard_pattern);
2438  }
2439 
2443  void AllowOnlyWhenInlining(const StringPiece& wildcard_pattern) {
2444  Disallow(wildcard_pattern);
2445  AllowWhenInlining(wildcard_pattern);
2446  }
2447 
2449  void DisallowWhenInlining(const StringPiece& wildcard_pattern) {
2450  Modify();
2451  allow_when_inlining_resources_.MakeWriteable()->Disallow(wildcard_pattern);
2452  }
2453 
2457  virtual void DisallowTroublesomeResources();
2458 
2463  virtual void DisallowResourcesForProxy();
2464 
2485  const DomainLawyer* domain_lawyer() const { return domain_lawyer_.get(); }
2486  DomainLawyer* WriteableDomainLawyer();
2487 
2488  FileLoadPolicy* file_load_policy() { return &file_load_policy_; }
2489  const FileLoadPolicy* file_load_policy() const { return &file_load_policy_; }
2490 
2493  bool IsAllowed(const StringPiece& url) const {
2494  return allow_resources_->Match(url, true );
2495  }
2496 
2504  bool IsAllowedWhenInlining(const StringPiece& url) const {
2505  return allow_when_inlining_resources_->Match(
2506  url, false );
2507  }
2508 
2510  void RetainComment(const StringPiece& comment) {
2511  Modify();
2512  retain_comments_.MakeWriteable()->Allow(comment);
2513  }
2514 
2518  bool IsRetainedComment(const StringPiece& comment) const {
2519  return retain_comments_->Match(comment, false);
2520  }
2521 
2523  void DisableLazyloadForClassName(const StringPiece& class_name) {
2524  Modify();
2525  lazyload_enabled_classes_.MakeWriteable()->Disallow(class_name);
2526  }
2527 
2529  bool IsLazyloadEnabledForClassName(const StringPiece& class_name) const {
2530  return lazyload_enabled_classes_->Match(class_name, true);
2531  }
2532 
2533  void set_override_caching_ttl_ms(int64 x) {
2534  set_option(x, &override_caching_ttl_ms_);
2535  }
2536  int64 override_caching_ttl_ms() const {
2537  return override_caching_ttl_ms_.value();
2538  }
2539 
2542  void AddOverrideCacheTtl(const StringPiece& wildcard) {
2543  Modify();
2544  override_caching_wildcard_.MakeWriteable()->Allow(wildcard);
2545  }
2546 
2548  bool IsCacheTtlOverridden(const StringPiece& url) const {
2549  return override_caching_wildcard_->Match(url, false);
2550  }
2551 
2552  void AddRejectedUrlWildcard(const GoogleString& wildcard) {
2553  AddRejectedHeaderWildcard(kRejectedRequestUrlKeyName, wildcard);
2554  }
2555 
2556  void AddRejectedHeaderWildcard(const StringPiece& header_name,
2557  const GoogleString& wildcard) {
2558  Modify();
2559  std::pair<FastWildcardGroupMap::iterator, bool> insert_result =
2560  rejected_request_map_.insert(std::make_pair(
2561  header_name, static_cast<FastWildcardGroup*>(NULL)));
2562 
2563  if (insert_result.second) {
2564  insert_result.first->second = new FastWildcardGroup;
2565  }
2566  insert_result.first->second->Allow(wildcard);
2567  }
2568 
2569  void set_min_cache_ttl_ms(int64 x) {
2570  set_option(x, &min_cache_ttl_ms_);
2571  }
2572  int64 min_cache_ttl_ms() const {
2573  return min_cache_ttl_ms_.value();
2574  }
2575 
2578  bool IsRequestDeclined(const GoogleString& url,
2579  const RequestHeaders* request_headers) const;
2580 
2584  virtual RewriteOptions* Clone() const;
2585 
2587  virtual RewriteOptions* NewOptions() const;
2588 
2594  void ComputeSignature() LOCKS_EXCLUDED(cache_purge_mutex_.get());
2595  void ComputeSignatureLockHeld() SHARED_LOCKS_REQUIRED(cache_purge_mutex_);
2596 
2601  void Freeze();
2602 
2613 
2614  bool frozen() const { return frozen_; }
2615 
2620  bool frozen = frozen_;
2622  return frozen;
2623  }
2624 
2626  const GoogleString& signature() const {
2634  ThreadSystem::ScopedReader lock(cache_purge_mutex_.get());
2635  DCHECK(frozen_);
2636  DCHECK(!signature_.empty());
2637  return signature_;
2638  }
2639 
2640  virtual GoogleString OptionsToString() const;
2641  GoogleString FilterSetToString(const FilterSet& filter_set) const;
2642  GoogleString EnabledFiltersToString() const;
2645  GoogleString SafeEnabledOptionsToString() const;
2646 
2649  virtual GoogleString ToExperimentString() const;
2650 
2654  virtual GoogleString ToExperimentDebugString() const;
2655 
2658  static Filter LookupFilterById(const StringPiece& filter_id);
2659 
2661  static Filter LookupFilter(const StringPiece& filter_name);
2662 
2665  static const PropertyBase* LookupOptionById(StringPiece option_id);
2666  static const PropertyBase* LookupOptionByName(StringPiece option_name);
2667 
2670  static const StringPiece LookupOptionNameById(StringPiece option_id);
2671 
2673  static bool IsValidOptionName(StringPiece name);
2674 
2678  return all_options_;
2679  }
2680 
2684  bool IsEqual(const RewriteOptions& that) const;
2685 
2687  const Hasher* hasher() const { return &hasher_; }
2688 
2689  const SHA1Signature* sha1signature() const { return &sha1signature_; }
2690 
2691  ThreadSystem* thread_system() const { return thread_system_; }
2692 
2696  HttpOptions ComputeHttpOptions() const;
2697 
2698  protected:
2708  template<class T> class OptionTemplateBase : public OptionBase {
2709  public:
2710  typedef T ValueType;
2711 
2712  OptionTemplateBase() : was_set_(false), property_(NULL) {}
2713 
2714  virtual bool was_set() const { return was_set_; }
2715 
2716  void set(const T& val) {
2717  was_set_ = true;
2718  value_ = val;
2719  }
2720 
2721  void set_default(const T& val) {
2722  if (!was_set_) {
2723  value_ = val;
2724  }
2725  }
2726 
2727  const T& value() const { return value_; }
2728  T& mutable_value() { was_set_ = true; return value_; }
2729 
2735  virtual void Merge(const OptionBase* src) {
2736  DCHECK(option_name() == src->option_name());
2737  MergeHelper(static_cast<const OptionTemplateBase*>(src));
2738  }
2739 
2740  void MergeHelper(const OptionTemplateBase* src) {
2743  if (src->was_set_ || !was_set_) {
2744  value_ = src->value_;
2745  was_set_ = src->was_set_;
2746  }
2747  }
2748 
2750  void set_property(const Property<T>* property) {
2751  property_ = property;
2752 
2757  value_ = property->default_value();
2758  }
2759  virtual const PropertyBase* property() const { return property_; }
2760 
2769  void set_global_default(const T& val) {
2770  Property<T>* property = const_cast<Property<T>*>(property_);
2771  property->set_default(val);
2772  }
2773 
2783  Property<T>* property = const_cast<Property<T>*>(property_);
2784  property->set_do_not_use_for_signature_computation(true);
2785  }
2786 
2787  private:
2788  bool was_set_;
2789  T value_;
2790  const Property<T>* property_;
2791 
2792  DISALLOW_COPY_AND_ASSIGN(OptionTemplateBase);
2793  };
2794 
2799  template<class T> class Option : public OptionTemplateBase<T> {
2800  public:
2801  Option() {}
2802 
2804  virtual bool SetFromString(StringPiece value_string,
2805  GoogleString* error_detail) {
2806  T value;
2807  bool success = RewriteOptions::ParseFromString(value_string, &value);
2808  if (success) {
2809  this->set(value);
2810  }
2811  return success;
2812  }
2813 
2814  virtual GoogleString Signature(const Hasher* hasher) const {
2815  return RewriteOptions::OptionSignature(this->value(), hasher);
2816  }
2817 
2818  virtual GoogleString ToString() const {
2819  return RewriteOptions::ToString(this->value());
2820  }
2821 
2822  private:
2823  DISALLOW_COPY_AND_ASSIGN(Option);
2824  };
2825 
2826  protected:
2828  template<class RewriteOptionsSubclass, class OptionClass>
2829  static void AddProperty(
2830  typename OptionClass::ValueType default_value,
2831  OptionClass RewriteOptionsSubclass::*offset,
2832  const char* id,
2833  StringPiece option_name,
2834  OptionScope scope,
2835  const char* help_text,
2836  bool safe_to_print,
2837  Properties* properties) {
2838  PropertyBase* property =
2839  new PropertyLeaf<RewriteOptionsSubclass, OptionClass>(
2840  default_value, offset, id, option_name);
2841  property->set_scope(scope);
2842  property->set_help_text(help_text);
2843  property->set_safe_to_print(safe_to_print);
2844  properties->push_back(property);
2845  }
2846 
2860  static void MergeSubclassProperties(Properties* properties);
2861 
2867  void set_option_at(int index, OptionBase* option) {
2868  all_options_[index] = option;
2869  }
2870 
2874  template<class T>
2875  void set_option(const T& new_value, OptionTemplateBase<T>* option) {
2876  option->set(new_value);
2877  Modify();
2878  }
2879 
2881  void Modify();
2882 
2890  void set_default_x_header_value(const StringPiece& x_header_value) {
2891  x_header_value_.set_global_default(x_header_value.as_string());
2892  }
2893 
2897  bool SetupExperimentRewriters();
2898 
2900  virtual void SetRequiredExperimentFilters();
2901 
2905  bool InsertExperimentSpecInVector(ExperimentSpec* spec);
2906 
2909 
2912 
2913  private:
2915  class CacheFragmentOption : public Option<GoogleString> {
2916  public:
2917  virtual bool SetFromString(StringPiece value_string,
2918  GoogleString* error_detail);
2919  };
2920 
2921  struct OptionIdCompare;
2922 
2927  enum MergeOverride { kNoAction, kDisablePreserve, kDisableFilter };
2928 
2931  class PropertyBase {
2932  public:
2933  PropertyBase(const char* id, StringPiece option_name)
2934  : id_(id),
2935  help_text_(NULL),
2936  option_name_(option_name),
2937  scope_(kDirectoryScope),
2938  do_not_use_for_signature_computation_(false),
2939  index_(-1) {
2940  }
2941  virtual ~PropertyBase();
2942 
2945  virtual void InitializeOption(RewriteOptions* options) const = 0;
2946 
2947  void set_do_not_use_for_signature_computation(bool x) {
2948  do_not_use_for_signature_computation_ = x;
2949  }
2950  bool is_used_for_signature_computation() const {
2951  return !do_not_use_for_signature_computation_;
2952  }
2953 
2954  void set_scope(OptionScope x) { scope_ = x; }
2955  OptionScope scope() const { return scope_; }
2956 
2957  void set_help_text(const char* x) { help_text_ = x; }
2958  const char* help_text() const { return help_text_; }
2959 
2960  void set_index(int index) { index_ = index; }
2961  const char* id() const { return id_; }
2962  StringPiece option_name() const { return option_name_; }
2963  int index() const { return index_; }
2964 
2965  bool safe_to_print() const { return safe_to_print_; }
2966  void set_safe_to_print(bool safe_to_print) {
2967  safe_to_print_ = safe_to_print;
2968  }
2969 
2970  private:
2971  const char* id_;
2972  const char* help_text_;
2973  StringPiece option_name_;
2974  OptionScope scope_;
2975  bool do_not_use_for_signature_computation_;
2976  bool safe_to_print_;
2977  int index_;
2978 
2979  DISALLOW_COPY_AND_ASSIGN(PropertyBase);
2980  };
2981 
2985  template<class ValueType>
2986  class Property : public PropertyBase {
2987  public:
2992  Property(ValueType default_value,
2993  const char* id,
2994  StringPiece option_name)
2995  : PropertyBase(id, option_name),
2996  default_value_(default_value) {
2997  }
2998 
2999  void set_default(ValueType value) { default_value_ = value; }
3000  const ValueType& default_value() const { return default_value_; }
3001 
3002  private:
3003  ValueType default_value_;
3004 
3005  DISALLOW_COPY_AND_ASSIGN(Property);
3006  };
3007 
3022  template<class RewriteOptionsSubclass, class OptionClass>
3023  class PropertyLeaf : public Property<typename OptionClass::ValueType> {
3024  public:
3028  typedef OptionClass RewriteOptionsSubclass::*OptionOffset;
3029  typedef typename OptionClass::ValueType ValueType;
3030 
3031  PropertyLeaf(ValueType default_value,
3032  OptionOffset offset,
3033  const char* id,
3034  StringPiece option_name)
3035  : Property<ValueType>(default_value, id, option_name),
3036  offset_(offset) {
3037  }
3038 
3039  virtual void InitializeOption(RewriteOptions* options) const {
3040  RewriteOptionsSubclass* options_subclass =
3041  static_cast<RewriteOptionsSubclass*>(options);
3042  OptionClass& option = options_subclass->*offset_;
3043  option.set_property(this);
3044  DCHECK_NE(-1, this->index()) << "Call Property::set_index first.";
3045  options->set_option_at(this->index(), &option);
3046  }
3047 
3048  private:
3049  OptionOffset offset_;
3050 
3051  DISALLOW_COPY_AND_ASSIGN(PropertyLeaf);
3052  };
3053 
3054  static Properties* properties_;
3055  static Properties* all_properties_;
3056 
3057  FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
3058  FRIEND_TEST(RewriteOptionsTest, LookupOptionByNameTest);
3059 
3061  bool HasRejectedHeader(const StringPiece& header_name,
3062  const RequestHeaders* request_headers) const;
3063 
3064  bool IsRejectedUrl(const GoogleString& url) const {
3065  return IsRejectedRequest(kRejectedRequestUrlKeyName, url);
3066  }
3067 
3068  bool IsRejectedRequest(const StringPiece& header_name,
3069  const StringPiece& value) const {
3070  FastWildcardGroupMap::const_iterator it = rejected_request_map_.find(
3071  header_name);
3072  if (it != rejected_request_map_.end()) {
3073  return it->second->Match(value, false);
3074  }
3075  return false;
3076  }
3077 
3080  JavascriptLibraryIdentification* WriteableJavascriptLibraryIdentification();
3081 
3088  struct PrioritizeVisibleContentFamily {
3089  PrioritizeVisibleContentFamily(StringPiece url_pattern_string,
3090  int64 cache_time_ms_in,
3091  StringPiece non_cacheable_elements_in)
3092  : url_pattern(url_pattern_string),
3093  cache_time_ms(cache_time_ms_in),
3094  non_cacheable_elements(non_cacheable_elements_in.data(),
3095  non_cacheable_elements_in.size()) {}
3096 
3097  PrioritizeVisibleContentFamily* Clone() const {
3098  return new PrioritizeVisibleContentFamily(
3099  url_pattern.spec(), cache_time_ms, non_cacheable_elements);
3100  }
3101 
3102  GoogleString ComputeSignature() const {
3103  return StrCat(url_pattern.spec(), ";", Integer64ToString(cache_time_ms),
3104  ";", non_cacheable_elements);
3105  }
3106 
3107  GoogleString ToString() const {
3108  return StrCat("URL pattern: ", url_pattern.spec(), ", Cache time (ms): ",
3109  Integer64ToString(cache_time_ms), ", Non-cacheable: ",
3110  non_cacheable_elements);
3111  }
3112 
3113  Wildcard url_pattern;
3114  int64 cache_time_ms;
3115  GoogleString non_cacheable_elements;
3116  };
3117 
3120  struct UrlCacheInvalidationEntry {
3121  UrlCacheInvalidationEntry(StringPiece url_pattern_in,
3122  int64 timestamp_ms_in,
3123  bool ignores_metadata_and_pcache_in)
3124  : url_pattern(url_pattern_in),
3125  timestamp_ms(timestamp_ms_in),
3126  ignores_metadata_and_pcache(ignores_metadata_and_pcache_in) {}
3127 
3128  UrlCacheInvalidationEntry* Clone() const {
3129  return new UrlCacheInvalidationEntry(
3130  url_pattern.spec(), timestamp_ms, ignores_metadata_and_pcache);
3131  }
3132 
3133  GoogleString ComputeSignature() const {
3134  if (ignores_metadata_and_pcache) {
3135  return "";
3136  }
3137  return StrCat(url_pattern.spec(), "@", Integer64ToString(timestamp_ms));
3138  }
3139 
3140  GoogleString ToString() const {
3141  return StrCat(
3142  url_pattern.spec(), ", ",
3143  (ignores_metadata_and_pcache ? "STRICT" : "REFERENCE"), " @ ",
3144  Integer64ToString(timestamp_ms));
3145  }
3146 
3147  Wildcard url_pattern;
3148  int64 timestamp_ms;
3149  bool ignores_metadata_and_pcache;
3150  };
3151 
3152  typedef std::vector<UrlCacheInvalidationEntry*>
3153  UrlCacheInvalidationEntryVector;
3154  typedef dense_hash_map<GoogleString, int64> UrlCacheInvalidationMap;
3155 
3159  typedef rde::hash_map<StringPiece, const PropertyBase*,
3160  CaseFoldStringPieceHash, 6,
3161  CaseFoldStringPieceEqual> PropertyNameMap;
3162 
3175  template<class OptionClass>
3176  static void AddRequestProperty(typename OptionClass::ValueType default_value,
3177  OptionClass RewriteOptions::*offset,
3178  const char* id, bool safe_to_print) {
3179  AddProperty(default_value, offset, id, kNullOption, kProcessScope,
3180  NULL, safe_to_print, properties_);
3181  }
3182 
3185  template<class OptionClass>
3186  static void AddBaseProperty(typename OptionClass::ValueType default_value,
3187  OptionClass RewriteOptions::*offset,
3188  const char* id,
3189  StringPiece option_name,
3190  OptionScope scope,
3191  const char* help,
3192  bool safe_to_print) {
3193  AddProperty(default_value, offset, id, option_name, scope, help,
3194  safe_to_print, properties_);
3195  }
3196 
3197  static void AddProperties();
3198  bool AddCommaSeparatedListToFilterSetState(
3199  const StringPiece& filters, FilterSet* set, MessageHandler* handler);
3200  static bool AddCommaSeparatedListToFilterSet(
3201  const StringPiece& filters, FilterSet* set, MessageHandler* handler);
3203  static void InitFilterIdToEnumArray();
3204  static void InitOptionIdToPropertyArray();
3205  static void InitOptionNameToPropertyArray();
3206 
3210  OptionSettingResult FormatSetOptionMessage(
3211  OptionSettingResult result, StringPiece name, StringPiece value,
3212  StringPiece error_detail, GoogleString* msg);
3213 
3216  OptionSettingResult SetOptionFromNameInternal(
3217  StringPiece name, StringPiece value, bool from_query,
3218  GoogleString* error_detail);
3219 
3222  static GoogleString OptionSignature(bool x, const Hasher* hasher) {
3223  return x ? "T" : "F";
3224  }
3225  static GoogleString OptionSignature(int x, const Hasher* hasher) {
3226  return IntegerToString(x);
3227  }
3228  static GoogleString OptionSignature(int64 x, const Hasher* hasher) {
3229  return Integer64ToString(x);
3230  }
3231  static GoogleString OptionSignature(const GoogleString& x,
3232  const Hasher* hasher);
3233  static GoogleString OptionSignature(RewriteLevel x,
3234  const Hasher* hasher);
3235  static GoogleString OptionSignature(ResourceCategorySet x,
3236  const Hasher* hasher);
3237  static GoogleString OptionSignature(const BeaconUrl& beacon_url,
3238  const Hasher* hasher);
3239  static GoogleString OptionSignature(
3240  const protobuf::MessageLite& proto,
3241  const Hasher* hasher);
3242 
3245  static GoogleString ToString(bool x) {
3246  return x ? "True" : "False";
3247  }
3248  static GoogleString ToString(int x) {
3249  return IntegerToString(x);
3250  }
3251  static GoogleString ToString(int64 x) {
3252  return Integer64ToString(x);
3253  }
3254  static GoogleString ToString(const GoogleString& x) {
3255  return x;
3256  }
3257  static GoogleString ToString(RewriteLevel x);
3258  static GoogleString ToString(const ResourceCategorySet &x);
3259  static GoogleString ToString(const BeaconUrl& beacon_url);
3260  static GoogleString ToString(const protobuf::MessageLite& proto);
3261 
3264  static bool PropertyLessThanByOptionName(PropertyBase* p1, PropertyBase* p2) {
3265  return StringCaseCompare(p1->option_name(), p2->option_name()) < 0;
3266  }
3267 
3269  static bool OptionNameLessThanArg(OptionBase* option, StringPiece arg) {
3270  return StringCaseCompare(option->option_name(), arg) < 0;
3271  }
3272 
3274  static bool CompareUrlCacheInvalidationEntry(UrlCacheInvalidationEntry* e1,
3275  UrlCacheInvalidationEntry* e2) {
3276  return e1->timestamp_ms < e2->timestamp_ms;
3277  }
3278 
3280  static bool FilterEnumToIdAndNameEntryLessThanById(
3281  const FilterEnumToIdAndNameEntry* e1,
3282  const FilterEnumToIdAndNameEntry* e2) {
3283  return strcmp(e1->filter_id, e2->filter_id) < 0;
3284  }
3285 
3288  static StringPiece GetEffectiveOptionName(StringPiece name);
3289 
3292  bool CheckBandwidthOption(const Option<bool>& option) const {
3293  if (option.was_set() || (level() != kOptimizeForBandwidth)) {
3294  return option.value();
3295  }
3296  return true;
3297  }
3298 
3305  MergeOverride ComputeMergeOverride(
3306  Filter filter,
3307  const Option<bool>& src_preserve_option,
3308  const Option<bool>& preserve_option,
3309  const RewriteOptions& src);
3310 
3312  void ApplyMergeOverride(
3313  MergeOverride merge_override,
3314  Filter filter,
3315  Option<bool>* preserve_option);
3316 
3317  bool modified_;
3318  bool frozen_;
3319  FilterSet enabled_filters_;
3320  FilterSet disabled_filters_;
3321  FilterSet forbidden_filters_;
3322 
3325  FilterIdSet distributable_filters_;
3326 
3332  Option<RewriteLevel> level_;
3333 
3336  UrlCacheInvalidationEntryVector url_cache_invalidation_entries_;
3337 
3344  CopyOnWrite<PurgeSet> purge_set_ GUARDED_BY(cache_purge_mutex_);
3345 
3346  scoped_ptr<ThreadSystem::RWLock> cache_purge_mutex_;
3347  Option<int64> css_flatten_max_bytes_;
3348  Option<bool> cache_small_images_unrewritten_;
3349  Option<bool> no_transform_optimized_images_;
3350 
3352  Option<int64> image_resolution_limit_bytes_;
3353  Option<int64> css_image_inline_max_bytes_;
3354  Option<int64> css_inline_max_bytes_;
3355  Option<int64> css_outline_min_bytes_;
3356 
3358  Option<bool> css_preserve_urls_;
3359  Option<bool> js_preserve_urls_;
3360  Option<bool> image_preserve_urls_;
3361 
3362  Option<int64> image_inline_max_bytes_;
3363  Option<int64> js_inline_max_bytes_;
3364  Option<int64> js_outline_min_bytes_;
3365  Option<int64> progressive_jpeg_min_bytes_;
3367  Option<int64> max_html_cache_time_ms_;
3370  Option<int64> max_html_parse_bytes_;
3372  Option<int64> max_image_bytes_for_webp_in_css_;
3374  Option<int64> min_resource_cache_time_to_rewrite_ms_;
3375  Option<int64> idle_flush_time_ms_;
3376  Option<int64> flush_buffer_limit_bytes_;
3377 
3381  Option<int64> blocking_fetch_timeout_ms_;
3382 
3385  Option<int64> image_recompress_quality_;
3386 
3388  Option<int64> image_jpeg_recompress_quality_;
3389  Option<int64> image_jpeg_recompress_quality_for_small_screens_;
3390  Option<int64> image_jpeg_num_progressive_scans_;
3391  Option<int64> image_jpeg_num_progressive_scans_for_small_screens_;
3392 
3394  Option<int> image_limit_optimized_percent_;
3395  Option<int> image_limit_resize_area_percent_;
3396  Option<int> image_limit_rendered_area_percent_;
3397 
3399  Option<int64> image_webp_recompress_quality_;
3400  Option<int64> image_webp_recompress_quality_for_small_screens_;
3401  Option<int64> image_webp_timeout_ms_;
3402 
3403  Option<int> image_max_rewrites_at_once_;
3404  Option<int> max_url_segment_size_;
3405  Option<int> max_url_size_;
3406  Option<int> rewrite_deadline_ms_;
3410  Option<int> domain_shard_count_;
3411 
3412  Option<EnabledEnum> enabled_;
3413 
3414  Option<bool> distributable_;
3415 
3418  Option<bool> add_options_to_urls_;
3419 
3425  Option<bool> publicly_cache_mismatched_hashes_experimental_;
3426 
3428  Option<bool> in_place_rewriting_enabled_;
3430  Option<bool> in_place_wait_for_optimized_;
3433  Option<int> in_place_rewrite_deadline_ms_;
3436  Option<bool> in_place_preemptive_rewrite_css_;
3438  Option<bool> in_place_preemptive_rewrite_css_images_;
3441  Option<bool> in_place_preemptive_rewrite_images_;
3444  Option<bool> in_place_preemptive_rewrite_javascript_;
3450  Option<bool> private_not_vary_for_ie_;
3451  Option<bool> combine_across_paths_;
3452  Option<bool> log_background_rewrites_;
3453  Option<bool> log_rewrite_timing_;
3454  Option<bool> log_url_indices_;
3455  Option<bool> lowercase_html_names_;
3456  Option<bool> always_rewrite_css_;
3457  Option<bool> respect_vary_;
3458  Option<bool> respect_x_forwarded_proto_;
3459  Option<bool> flush_html_;
3463  Option<bool> serve_split_html_in_two_chunks_;
3466  Option<bool> serve_stale_if_fetch_error_;
3468  Option<bool> serve_ghost_click_buster_with_split_html_;
3470  Option<bool> serve_xhr_access_control_headers_;
3473  Option<bool> proactively_freshen_user_facing_request_;
3476  Option<int64> serve_stale_while_revalidate_threshold_sec_;
3478  Option<bool> enable_flush_early_critical_css_;
3480  Option<bool> use_selectors_for_critical_css_;
3485  Option<bool> default_cache_html_;
3490  Option<bool> modify_caching_headers_;
3494  Option<bool> lazyload_images_after_onload_;
3497  Option<GoogleString> lazyload_images_blank_url_;
3500  Option<bool> use_blank_image_for_inline_preview_;
3504  Option<bool> inline_only_critical_images_;
3507  Option<bool> critical_images_beacon_enabled_;
3510  Option<bool> client_domain_rewrite_;
3513  Option<bool> domain_rewrite_hyperlinks_;
3516  Option<bool> running_experiment_;
3519  Option<int> experiment_ga_slot_;
3522  Option<int> enroll_experiment_id_;
3523 
3526  Option<bool> increase_speed_tracking_;
3527 
3531  Option<bool> report_unload_time_;
3532 
3533  Option<bool> serve_rewritten_webp_urls_to_any_agent_;
3534 
3536  Option<bool> flush_more_resources_early_if_time_permits_;
3537 
3539  Option<bool> flush_more_resources_in_ie_and_firefox_;
3540 
3543  Option<int> max_prefetch_js_elements_;
3544 
3546  Option<bool> enable_defer_js_experimental_;
3547 
3549  Option<bool> disable_rewrite_on_no_transform_;
3550 
3552  Option<bool> disable_background_fetches_for_bots_;
3553 
3563  Option<bool> enable_cache_purge_;
3564 
3568  Option<bool> proactive_resource_freshening_;
3569 
3571  Option<bool> lazyload_highres_images_;
3572 
3575  Option<bool> avoid_renaming_introspective_javascript_;
3576 
3578  Option<bool> override_ie_document_mode_;
3579 
3581  Option<bool> test_instant_fetch_rewrite_deadline_;
3582 
3586  Option<bool> test_only_prioritize_critical_css_dont_apply_original_css_;
3587 
3593  Option<GoogleString> blocking_rewrite_key_;
3594 
3598  Option<int> beacon_reinstrument_time_sec_;
3599 
3602  Option<int> max_inlined_preview_images_index_;
3604  Option<int64> min_image_size_low_resolution_bytes_;
3606  Option<int64> max_image_size_low_resolution_bytes_;
3609  Option<int> rewrite_random_drop_percentage_;
3610 
3613  Option<bool> oblivious_pagespeed_urls_;
3614 
3616  Option<int64> finder_properties_cache_expiration_time_ms_;
3617 
3621  Option<int64> finder_properties_cache_refresh_time_ms_;
3624  Option<int64> experiment_cookie_duration_ms_;
3625 
3628  Option<int64> metadata_cache_staleness_threshold_ms_;
3629 
3631  Option<int64> metadata_input_errors_cache_ttl_ms_;
3632 
3635  Option<GoogleString> downstream_cache_purge_method_;
3636 
3638  Option<GoogleString> downstream_cache_purge_location_prefix_;
3639 
3642  Option<GoogleString> downstream_cache_rebeaconing_key_;
3643 
3649  Option<int64> downstream_cache_rewritten_percentage_threshold_;
3650 
3654  Option<int64> implicit_cache_ttl_ms_;
3655 
3657  Option<int64> max_cacheable_response_content_length_;
3658 
3660  Option<int64> blink_blacklist_end_timestamp_ms_;
3662  Option<bool> persist_blink_blacklist_;
3663 
3666  Option<bool> preserve_url_relativity_;
3667 
3668  Option<GoogleString> ga_id_;
3669 
3670  Option<int64> blink_max_html_size_rewritable_;
3673  Option<int64> blink_html_change_detection_time_ms_;
3675  Option<bool> enable_blink_debug_dashboard_;
3677  Option<bool> enable_blink_html_change_detection_;
3679  Option<bool> enable_blink_html_change_detection_logging_;
3681  Option<bool> use_smart_diff_in_blink_;
3683  Option<bool> use_fallback_property_cache_values_;
3685  Option<bool> await_pcache_lookup_;
3687  Option<bool> enable_prioritizing_scripts_;
3689  Option<bool> rewrite_uncacheable_resources_;
3691  Option<GoogleString> critical_line_config_;
3694  Option<GoogleString> distributed_rewrite_key_;
3696  Option<GoogleString> distributed_rewrite_servers_;
3701  Option<bool> distribute_fetches_;
3704  Option<int64> distributed_rewrite_timeout_ms_;
3710  Option<bool> forbid_all_disabled_filters_;
3712  Option<bool> enable_aggressive_rewriters_for_mobile_;
3713 
3719  Option<bool> reject_blacklisted_;
3720  Option<int> reject_blacklisted_status_code_;
3721 
3725  Option<bool> support_noscript_enabled_;
3726 
3729  Option<bool> enable_extended_instrumentation_;
3730 
3731  Option<bool> use_experimental_js_minifier_;
3732 
3735  Option<int64> max_combined_css_bytes_;
3736 
3739  Option<int64> max_combined_js_bytes_;
3740 
3742  Option<GoogleString> pre_connect_url_;
3745  Option<int> property_cache_http_status_stability_threshold_;
3747  Option<int> max_rewrite_info_log_size_;
3748 
3753  Option<int64> override_caching_ttl_ms_;
3754  CopyOnWrite<FastWildcardGroup> override_caching_wildcard_;
3755 
3759  Option<int64> min_cache_ttl_ms_;
3760 
3762  Option<bool> allow_logging_urls_in_log_record_;
3763 
3765  Option<bool> allow_options_to_be_set_by_cookies_;
3766 
3768  Option<GoogleString> non_cacheables_for_cache_partial_html_;
3769 
3773  Option<GoogleString> access_control_allow_origins_;
3774 
3776  Option<bool> hide_referer_using_meta_;
3777 
3782  Option<int64> max_low_res_image_size_bytes_;
3783  Option<int> max_low_res_to_full_res_image_size_percentage_;
3784 
3786  Option<GoogleString> request_option_override_;
3787 
3789  Option<GoogleString> url_signing_key_;
3790 
3792  Option<bool> accept_invalid_signatures_;
3793 
3798  Option<GoogleString> sticky_query_parameters_;
3799  Option<int64> option_cookies_duration_ms_;
3800 
3803  CacheFragmentOption cache_fragment_;
3804 
3807  OptionBaseVector all_options_;
3808  size_t initialized_options_;
3809 
3812  static const FilterEnumToIdAndNameEntry* filter_id_to_enum_array_[
3813  kEndOfFilters];
3814 
3816  static PropertyNameMap* option_name_to_property_map_;
3817 
3819  static const PropertyBase** option_id_to_property_array_;
3820 
3827  bool options_uniqueness_checked_;
3828 
3829  bool need_to_store_experiment_data_;
3830  int experiment_id_;
3831  int experiment_percent_;
3832  std::vector<ExperimentSpec*> experiment_specs_;
3833 
3835  std::vector<NameValue*> custom_fetch_headers_;
3836 
3839  scoped_ptr<std::vector<ElementAttributeCategory> > url_valued_attributes_;
3840 
3841  Option<ResourceCategorySet> inline_unauthorized_resource_types_;
3842 
3843  CopyOnWrite<JavascriptLibraryIdentification>
3844  javascript_library_identification_;
3845 
3846  CopyOnWrite<DomainLawyer> domain_lawyer_;
3847  FileLoadPolicy file_load_policy_;
3848 
3849  CopyOnWrite<FastWildcardGroup> allow_resources_;
3850  CopyOnWrite<FastWildcardGroup> allow_when_inlining_resources_;
3851  CopyOnWrite<FastWildcardGroup> retain_comments_;
3852  CopyOnWrite<FastWildcardGroup> lazyload_enabled_classes_;
3853 
3856  CopyOnWrite<FastWildcardGroup> blocking_rewrite_referer_urls_;
3857 
3860  typedef std::map<StringPiece, FastWildcardGroup*> FastWildcardGroupMap;
3861  FastWildcardGroupMap rejected_request_map_;
3862 
3863  GoogleString signature_;
3864  MD5Hasher hasher_;
3865  SHA1Signature sha1signature_;
3866 
3867  ThreadSystem* thread_system_;
3868 
3881  scoped_ptr<ThreadSystem::ThreadId> last_thread_id_;
3882 
3883  DISALLOW_COPY_AND_ASSIGN(RewriteOptions);
3884 };
3885 
3886 }
3887 
3888 #endif
void set_experiment_ga_slot(int x)
x should be between 1 and 5 inclusive.
Definition: rewrite_options.h:2157
int64 CssImageInlineMaxBytes() const
Retrieve the css image inlining threshold, but return 0 if it's disabled.
void AddUrlValuedAttribute(const StringPiece &element, const StringPiece &attribute, semantic_type::Category category)
EnabledEnum
Definition: rewrite_options.h:193
void DisallowWhenInlining(const StringPiece &wildcard_pattern)
Like Disallow(). See IsAllowedWhenInlining().
Definition: rewrite_options.h:2449
bool AdjustFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
static const int64 kDefaultMaxCombinedCssBytes
Default maximum size of the combined CSS resource.
Definition: rewrite_options.h:688
static const PropertyBase * LookupOptionById(StringPiece option_id)
static void AddProperty(typename OptionClass::ValueType default_value, OptionClass RewriteOptionsSubclass::*offset, const char *id, StringPiece option_name, OptionScope scope, const char *help_text, bool safe_to_print, Properties *properties)
Adds a new Property to 'properties' (the last argument).
Definition: rewrite_options.h:2829
bool ClearSignatureForTesting()
Definition: rewrite_options.h:2619
int64 idle_flush_time_ms() const
Definition: rewrite_options.h:1439
void DisableLazyloadForClassName(const StringPiece &class_name)
Adds a new class name for which lazyload should be disabled.
Definition: rewrite_options.h:2523
ExperimentSpec(const StringPiece &spec, RewriteOptions *options, MessageHandler *handler)
static bool Initialize(Properties **properties)
bool MatchesDownstreamCacheRebeaconingKey(StringPiece key) const
Definition: rewrite_options.h:1889
customized at directory level (.htaccess, <Directory>)
Definition: rewrite_options.h:479
Definition: rewrite_options.h:477
void AddUrlCacheInvalidationEntry(StringPiece url_pattern, int64 timestamp_ms, bool ignores_metadata_and_pcache)
static bool IsValidOptionName(StringPiece name)
Determine if the given option name is valid/known.
static const int kDefaultMaxUrlSize
Definition: rewrite_options.h:649
static const int64 kDefaultExperimentCookieDurationMs
Definition: rewrite_options.h:681
void set_downstream_cache_purge_location_prefix(StringPiece p)
Definition: rewrite_options.h:1866
Definition: rewrite_options.h:438
Maps a filter's enum (kAddHead) to its id ("ah") and name ("Add Head").
Definition: rewrite_options.h:844
void Allow(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2422
Definition: rewrite_options.h:542
bool OptionValue(StringPiece option_name, const char **id, bool *was_set, GoogleString *value) const
bool IsLazyloadEnabledForClassName(const StringPiece &class_name) const
Checks if lazyload images is enabled for the specified class.
Definition: rewrite_options.h:2529
Definition: rewrite_options.h:201
static bool Terminate(Properties **properties_handle)
void RetainComment(const StringPiece &comment)
Adds a new comment wildcard pattern to be retained.
Definition: rewrite_options.h:2510
bool IsAllowed(const StringPiece &url) const
Definition: rewrite_options.h:2493
int max_url_segment_size() const
Definition: rewrite_options.h:1457
bool InsertExperimentSpecInVector(ExperimentSpec *spec)
bool ImageOptimizationEnabled() const
std::pair< GoogleString, GoogleString > OptionStringPair
Definition: rewrite_options.h:535
Definition: rewrite_options.h:2799
Definition: rewrite_options.h:2708
virtual void DisallowTroublesomeResources()
static const char kAcceptInvalidSignatures[]
Definition: rewrite_options.h:210
static const char kCacheFlushFilename[]
Definition: rewrite_options.h:389
void DistributeFiltersByCommaSeparatedList(const StringPiece &filter_ids, MessageHandler *handler)
virtual bool trim_urls_in_css() const
Return false in a subclass if you want to disallow all URL trimming in CSS.
Definition: rewrite_options.h:1910
Option< BeaconUrl > beacon_url_
Protected option values so that derived class can modify.
Definition: rewrite_options.h:2908
void DisableAllFilters()
Set rewrite level to kPassThrough and explicitly disable all filters.
static Filter LookupFilter(const StringPiece &filter_name)
Convert the filter name to a Filter.
bool EnableFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
static const char * FilterName(Filter filter)
ExperimentSpec * GetExperimentSpec(int id) const
static bool AddByNameToFilterSet(const StringPiece &option, FilterSet *set, MessageHandler *handler)
GoogleString PurgeSetString() const
Update kFirstFilter if you add something before this.
Definition: rewrite_options.h:105
static const int kDefaultExperimentSlot
Default Custom Variable slot in which to put Experiment information.
Definition: rewrite_options.h:695
void Modify()
Marks the config as modified.
virtual RewriteOptions * Clone() const
int64 flush_buffer_limit_bytes() const
How much accumulated HTML will result in PSA introducing a flush.
Definition: rewrite_options.h:1447
static bool ParseBeaconUrl(const StringPiece &in, BeaconUrl *out)
int64 cache_invalidation_timestamp() const
const DomainLawyer * domain_lawyer() const
Definition: rewrite_options.h:2485
Definition: rewrite_options.h:431
void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock *lock)
Definition: rewrite_options.h:1401
static void MergeSubclassProperties(Properties *properties)
void set_domain_shard_count(int64 x)
Definition: rewrite_options.h:1497
int64 css_outline_min_bytes() const
Definition: rewrite_options.h:1218
void DisableFiltersRequiringScriptExecution()
Disables all filters that depend on executing custom javascript.
void set_global_default(const T &val)
Definition: rewrite_options.h:2769
bool IsUrlCacheInvalidationEntriesSorted() const
static const int64 kDefaultMetadataCacheStalenessThresholdMs
Definition: rewrite_options.h:685
virtual GoogleString ToExperimentString() const
static const int kOptionsVersion
Definition: rewrite_options.h:462
void MergeHelper(const OptionTemplateBase *src)
Definition: rewrite_options.h:2740
int64 ImageInlineMaxBytes() const
Retrieve the image inlining threshold, but return 0 if it's disabled.
void EnableFilter(Filter filter)
void GetEnabledFiltersRequiringScriptExecution(FilterVector *filters) const
Returns the set of enabled filters that require JavaScript for execution.
virtual void DisallowResourcesForProxy()
virtual GoogleString ToExperimentDebugString() const
std::vector< OptionBase * > OptionBaseVector
Convenience name for a set of rewrite options.
Definition: rewrite_options.h:567
OptionScope
Definition: rewrite_options.h:476
void Disallow(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2429
Definition: javascript_library_identification.h:34
OptionSettingResult SetOptionFromName(StringPiece name, StringPiece value, GoogleString *msg)
static const int64 kDefaultFinderPropertiesCacheExpirationTimeMs
Default cache expiration value for finder properties in pcache.
Definition: rewrite_options.h:675
bool RegisterLibrary(SizeInBytes bytes, StringPiece md5_hash, StringPiece canonical_url)
Represents the content type of user-defined url-valued attributes.
Definition: rewrite_options.h:773
Option< GoogleString > x_header_value_
The value we put for the X-Mod-Pagespeed header. Default is our version.
Definition: rewrite_options.h:2911
void set_option(const T &new_value, OptionTemplateBase< T > *option)
Definition: rewrite_options.h:2875
static bool AddCommaSeparatedListToOptionSet(const StringPiece &options, OptionSet *set, MessageHandler *handler)
bool Distributable(const StringPiece &filter_id) const
int max_url_size() const
The maximum size of the entire URL. If '0', this is left unlimited.
Definition: rewrite_options.h:1470
virtual OptionSettingResult ParseAndSetOptionFromName1(StringPiece name, StringPiece arg, GoogleString *msg, MessageHandler *handler)
Definition: rewrite_options.h:785
Definition: rewrite_options.h:711
void DoNotUseForSignatureComputation()
Definition: rewrite_options.h:2782
bool IsRetainedComment(const StringPiece &comment) const
Definition: rewrite_options.h:2518
void AddCustomFetchHeader(const StringPiece &name, const StringPiece &value)
Specify a header to insert when fetching subresources.
virtual bool SetFromString(StringPiece value_string, GoogleString *error_detail)=0
static const int kDefaultMaxInlinedPreviewImagesIndex
Definition: rewrite_options.h:667
static const char kAllow[]
Options that require special handling, e.g. non-scalar values.
Definition: rewrite_options.h:361
void set_property(const Property< T > *property)
The static properties of an Option are held in a Property<T>*.
Definition: rewrite_options.h:2750
static const char * FilterId(Filter filter)
Definition: file_load_policy.h:41
HttpOptions ComputeHttpOptions() const
bool RegisterLibrary(uint64 bytes, StringPiece md5_hash, StringPiece canonical_url)
Store size, md5 hash and canonical url for library recognition.
Definition: rewrite_options.h:1014
virtual ExperimentSpec * AddExperimentSpec(const StringPiece &spec, MessageHandler *handler)
const Hasher * hasher() const
Returns the hasher used for signatures and URLs to purge.
Definition: rewrite_options.h:2687
static const int64 kDefaultMaxCombinedJsBytes
Default maximum size of the combined js resource generated by JsCombiner.
Definition: rewrite_options.h:691
std::set< GoogleString > FilterIdSet
Convenience name for a set of rewrite filter ids.
Definition: rewrite_options.h:523
customized at server level (e.g. VirtualHost)
Definition: rewrite_options.h:480
bool SetOptionFromNameAndLog(StringPiece name, StringPiece value, MessageHandler *handler)
customized at process level only (command-line flags)
Definition: rewrite_options.h:481
static const char kLibrary[]
3-argument ones:
Definition: rewrite_options.h:385
virtual void Merge(const RewriteOptions &src)
void SetDefaultRewriteLevel(RewriteLevel level)
Definition: rewrite_options.h:908
void PurgeUrl(StringPiece url, int64 timestamp_ms)
Purge a cache entry for an exact URL, not a wildcard.
static const int64 kDefaultDistributedTimeoutMs
Default time to wait for a distributed rewrite to return.
Definition: rewrite_options.h:663
GoogleString SafeEnabledOptionsToString() const
virtual bool SetExperimentState(int id)
void SoftEnableFilterForTesting(Filter filter)
Definition: domain_lawyer.h:47
void Merge(Properties *properties)
const OptionBaseVector & all_options() const
Definition: rewrite_options.h:2677
Filter
Definition: rewrite_options.h:104
virtual RewriteOptions * NewOptions() const
Make an empty options object of the same type as this.
OptionSettingResult SetOptionFromQuery(StringPiece name, StringPiece value)
bool IsUrlCacheValid(StringPiece url, int64 time_ms, bool search_wildcards) const
Pagespeed runs normally. Can be overridden via query param.
Definition: rewrite_options.h:198
static const int kDefaultMaxUrlSegmentSize
Definition: rewrite_options.h:657
virtual void SetRequiredExperimentFilters()
Enables filters needed by Experiment regardless of experiment.
bool DisableFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
void SetExperimentStateStr(const StringPiece &experiment_index)
void AllowWhenInlining(const StringPiece &wildcard_pattern)
Like Allow(). See IsAllowedWhenInlining().
Definition: rewrite_options.h:2435
static const int kDefaultRewriteDeadlineMs
Default time to wait for rewrite before returning original resource.
Definition: rewrite_options.h:660
void InitializeOptions(const Properties *properties)
void AddOverrideCacheTtl(const StringPiece &wildcard)
Definition: rewrite_options.h:2542
void set_default_x_header_value(const StringPiece &x_header_value)
Definition: rewrite_options.h:2890
static const int64 kDefaultMaxImageSizeLowResolutionBytes
Definition: rewrite_options.h:673
bool IsCacheTtlOverridden(const StringPiece &url) const
Is the cache TTL overridden for the given url?
Definition: rewrite_options.h:2548
static const StringPiece LookupOptionNameById(StringPiece option_id)
bool UpdateCachePurgeSet(const CopyOnWrite< PurgeSet > &purge_set) LOCKS_EXCLUDED(cache_purge_mutex_.get())
static const char kCustomFetchHeader[]
2-argument ones:
Definition: rewrite_options.h:375
virtual bool SetFromString(StringPiece value_string, GoogleString *error_detail)
Sets value_ from value_string.
Definition: rewrite_options.h:2804
OptionSettingResult
Used for return value of SetOptionFromName.
Definition: rewrite_options.h:599
static const char kDistributableFilters[]
For experimentation.
Definition: rewrite_options.h:365
Temporary and will be removed soon.
Definition: rewrite_options.h:134
void DistributeFilter(const StringPiece &filter_id)
static const int64 kDefaultMinImageSizeLowResolutionBytes
Definition: rewrite_options.h:670
as above, but fail startup if included in vhost
Definition: rewrite_options.h:482
static Filter LookupFilterById(const StringPiece &filter_id)
GoogleString GetExperimentStateStr() const
bool UpdateCacheInvalidationTimestampMs(int64 timestamp_ms) LOCKS_EXCLUDED(cache_purge_mutex_.get())
static const char kNullOption[]
The option name you have when you don't have an option name.
Definition: rewrite_options.h:422
Definition: rewrite_options.h:196
void AllowOnlyWhenInlining(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2443
void ForceEnableFilter(Filter filter)
bool IsAllowedWhenInlining(const StringPiece &url) const
Definition: rewrite_options.h:2504
bool SetOptionsFromName(const OptionSet &option_set, MessageHandler *handler)
Definition: rewrite_options.h:574
const JavascriptLibraryIdentification * javascript_library_identification() const
Definition: rewrite_options.h:1022
bool ForbidFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
Definition: rewrite_options.h:586
void UrlValuedAttribute(int index, StringPiece *element, StringPiece *attribute, semantic_type::Category *category) const
int id() const
Accessors.
Definition: rewrite_options.h:733
void Merge(const ExperimentSpec &spec)
bool AvailableExperimentId(int id)
Definition: rewrite_options.h:81
bool IsRequestDeclined(const GoogleString &url, const RequestHeaders *request_headers) const
bool IsEqual(const RewriteOptions &that) const
RewriteLevel
Definition: rewrite_options.h:569
Definition: rewrite_options.h:591
const GoogleString & signature() const
Returns the computed signature.
Definition: rewrite_options.h:2626
int size() const
Returns the number of properties.
Definition: rewrite_options.h:808
void set_option_at(int index, OptionBase *option)
Definition: rewrite_options.h:2867
bool has_cache_invalidation_timestamp_ms() const
static const int64 kDefaultFinderPropertiesCacheRefreshTimeMs
Default cache refresh value for finder properties in pcache.
Definition: rewrite_options.h:677
virtual ExperimentSpec * Clone()
Return a ExperimentSpec with all the same information as this one.
static const int kHashBytes
Number of bytes used for signature hashing.
Definition: rewrite_options.h:465
static bool ParseFromString(StringPiece value_string, bool *value)
static const int kCachePurgeBytes
Number of bytes capacity in the URL invalidation set.
Definition: rewrite_options.h:468
virtual void Merge(const OptionBase *src)
Definition: rewrite_options.h:2735
Definition: rewrite_options.h:595
static const Filter kFirstFilter
Used for enumerating over all entries in the Filter enum.
Definition: rewrite_options.h:517
void ComputeSignature() LOCKS_EXCLUDED(cache_purge_mutex_.get())
int64 MaxImageInlineMaxBytes() const
The larger of ImageInlineMaxBytes and CssImageInlineMaxBytes.