Page Speed Optimization Libraries  1.9.32.2
 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 <bitset>
23 #include <cstddef>
24 #include <map>
25 #include <set>
26 #include <utility>
27 #include <vector>
28 
29 #include "base/logging.h"
34 #include "pagespeed/kernel/base/basictypes.h"
35 #include "pagespeed/kernel/base/dense_hash_map.h"
36 #include "pagespeed/kernel/base/enum_set.h"
37 #include "pagespeed/kernel/base/fast_wildcard_group.h"
38 #include "pagespeed/kernel/base/gtest_prod.h"
39 #include "pagespeed/kernel/base/hasher.h"
40 #include "pagespeed/kernel/base/md5_hasher.h"
41 #include "pagespeed/kernel/base/proto_util.h"
42 #include "pagespeed/kernel/base/rde_hash_map.h"
43 #include "pagespeed/kernel/base/scoped_ptr.h"
44 #include "pagespeed/kernel/base/sha1_signature.h"
45 #include "pagespeed/kernel/base/string.h"
46 #include "pagespeed/kernel/base/string_hash.h"
47 #include "pagespeed/kernel/base/string_util.h"
48 #include "pagespeed/kernel/base/thread_annotations.h"
49 #include "pagespeed/kernel/base/thread_system.h"
50 #include "pagespeed/kernel/base/wildcard.h"
51 #include "pagespeed/kernel/http/http_names.h"
52 #include "pagespeed/kernel/http/semantic_type.h"
53 #include "pagespeed/kernel/http/user_agent_matcher.h"
54 #include "pagespeed/kernel/util/copy_on_write.h"
55 
56 namespace net_instaweb {
57 
58 class HttpOptions;
59 class MessageHandler;
60 class PurgeSet;
61 class RequestHeaders;
62 
84  private:
89  class PropertyBase;
90  template<class ValueType> class Property;
91  template<class RewriteOptionsSubclass, class OptionClass> class PropertyLeaf;
92 
93  public:
106  enum Filter {
108  kAddHead,
109  kAddInstrumentation,
110  kComputeStatistics,
111  kCachePartialHtml,
112  kCanonicalizeJavascriptLibraries,
113  kCollapseWhitespace,
114  kCollectFlushEarlyContentFilter,
115  kCombineCss,
116  kCombineHeads,
117  kCombineJavascript,
118  kComputeCriticalCss,
119  kComputeVisibleText,
120  kConvertGifToPng,
121  kConvertJpegToProgressive,
122  kConvertJpegToWebp,
123  kConvertMetaTags,
124  kConvertPngToJpeg,
125  kConvertToWebpLossless,
126  kDebug,
127  kDecodeRewrittenUrls,
128  kDedupInlinedImages,
129  kDeferIframe,
130  kDeferJavascript,
131  kDelayImages,
132  kDeterministicJs,
133  kDisableJavascript,
134  kDivStructure,
135  kElideAttributes,
137  kExplicitCloseTags,
138  kExtendCacheCss,
139  kExtendCacheImages,
140  kExtendCachePdfs,
141  kExtendCacheScripts,
142  kFallbackRewriteCssUrls,
143  kFixReflows,
144  kFlattenCssImports,
145  kFlushSubresources,
146  kHandleNoscriptRedirect,
147  kHtmlWriterFilter,
148  kIncludeJsSourceMaps,
149  kInlineCss,
150  kInlineGoogleFontCss,
151  kInlineImages,
152  kInlineImportToLink,
153  kInlineJavascript,
154  kInPlaceOptimizeForBrowser,
155  kInsertDnsPrefetch,
156  kInsertGA,
157  kInsertImageDimensions,
158  kJpegSubsampling,
159  kLazyloadImages,
160  kLeftTrimUrls,
161  kLocalStorageCache,
162  kMakeGoogleAnalyticsAsync,
163  kMobilize,
164  kMoveCssAboveScripts,
165  kMoveCssToHead,
166  kOutlineCss,
167  kOutlineJavascript,
168  kPedantic,
169  kPrioritizeCriticalCss,
170  kRecompressJpeg,
171  kRecompressPng,
172  kRecompressWebp,
173  kRemoveComments,
174  kRemoveQuotes,
175  kResizeImages,
176  kResizeMobileImages,
177  kResizeToRenderedImageDimensions,
178  kRewriteCss,
179  kRewriteDomains,
180  kRewriteJavascriptExternal,
181  kRewriteJavascriptInline,
182  kRewriteStyleAttributes,
183  kRewriteStyleAttributesWithUrl,
184  kSplitHtml,
185  kSplitHtmlHelper,
186  kSpriteImages,
187  kSquashImagesForMobileScreen,
188  kStripImageColorProfile,
189  kStripImageMetaData,
190  kStripNonCacheable,
191  kStripScripts,
192  kEndOfFilters
193  };
194 
195  enum EnabledEnum {
204  };
205 
212  static const char kAcceptInvalidSignatures[];
213  static const char kAccessControlAllowOrigins[];
214  static const char kAddOptionsToUrls[];
215  static const char kAllowLoggingUrlsInLogRecord[];
216  static const char kAllowOptionsToBeSetByCookies[];
217  static const char kAlwaysRewriteCss[];
218  static const char kAnalyticsID[];
219  static const char kAvoidRenamingIntrospectiveJavascript[];
220  static const char kAwaitPcacheLookup[];
221  static const char kBeaconReinstrumentTimeSec[];
222  static const char kBeaconUrl[];
223  static const char kBlinkMaxHtmlSizeRewritable[];
224  static const char kCacheFragment[];
225  static const char kCacheSmallImagesUnrewritten[];
226  static const char kClientDomainRewrite[];
227  static const char kCombineAcrossPaths[];
228  static const char kCriticalImagesBeaconEnabled[];
229  static const char kCriticalLineConfig[];
230  static const char kCssFlattenMaxBytes[];
231  static const char kCssImageInlineMaxBytes[];
232  static const char kCssInlineMaxBytes[];
233  static const char kCssOutlineMinBytes[];
234  static const char kCssPreserveURLs[];
235  static const char kDefaultCacheHtml[];
236  static const char kDisableBackgroundFetchesForBots[];
237  static const char kDisableRewriteOnNoTransform[];
238  static const char kDistributeFetches[];
239  static const char kDistributedRewriteKey[];
240  static const char kDistributedRewriteServers[];
241  static const char kDistributedRewriteTimeoutMs[];
242  static const char kDomainRewriteHyperlinks[];
243  static const char kDomainShardCount[];
244  static const char kDownstreamCachePurgeMethod[];
245  static const char kDownstreamCacheRebeaconingKey[];
246  static const char kDownstreamCacheRewrittenPercentageThreshold[];
247  static const char kEnableAggressiveRewritersForMobile[];
248  static const char kEnableBlinkHtmlChangeDetection[];
249  static const char kEnableBlinkHtmlChangeDetectionLogging[];
250  static const char kEnableCachePurge[];
251  static const char kEnableDeferJsExperimental[];
252  static const char kEnableExtendedInstrumentation[];
253  static const char kEnableFlushEarlyCriticalCss[];
254  static const char kEnableLazyLoadHighResImages[];
255  static const char kEnablePrioritizingScripts[];
256  static const char kEnabled[];
257  static const char kEnrollExperiment[];
258  static const char kExperimentCookieDurationMs[];
259  static const char kExperimentSlot[];
260  static const char kFetcherTimeOutMs[];
261  static const char kFinderPropertiesCacheExpirationTimeMs[];
262  static const char kFinderPropertiesCacheRefreshTimeMs[];
263  static const char kFlushBufferLimitBytes[];
264  static const char kFlushHtml[];
265  static const char kFlushMoreResourcesEarlyIfTimePermits[];
266  static const char kForbidAllDisabledFilters[];
267  static const char kHideRefererUsingMeta[];
268  static const char kIdleFlushTimeMs[];
269  static const char kImageInlineMaxBytes[];
270  static const char kImageJpegNumProgressiveScans[];
271  static const char kImageJpegNumProgressiveScansForSmallScreens[];
272  static const char kImageJpegRecompressionQuality[];
273  static const char kImageJpegRecompressionQualityForSmallScreens[];
274  static const char kImageLimitOptimizedPercent[];
275  static const char kImageLimitRenderedAreaPercent[];
276  static const char kImageLimitResizeAreaPercent[];
277  static const char kImageMaxRewritesAtOnce[];
278  static const char kImagePreserveURLs[];
279  static const char kImageRecompressionQuality[];
280  static const char kImageResolutionLimitBytes[];
281  static const char kImageWebpRecompressionQuality[];
282  static const char kImageWebpRecompressionQualityForSmallScreens[];
283  static const char kImageWebpTimeoutMs[];
284  static const char kImplicitCacheTtlMs[];
285  static const char kIncreaseSpeedTracking[];
286  static const char kInlineOnlyCriticalImages[];
287  static const char kInPlacePreemptiveRewriteCss[];
288  static const char kInPlacePreemptiveRewriteCssImages[];
289  static const char kInPlacePreemptiveRewriteImages[];
290  static const char kInPlacePreemptiveRewriteJavascript[];
291  static const char kInPlaceResourceOptimization[];
292  static const char kInPlaceRewriteDeadlineMs[];
293  static const char kInPlaceWaitForOptimized[];
294  static const char kJsInlineMaxBytes[];
295  static const char kJsOutlineMinBytes[];
296  static const char kJsPreserveURLs[];
297  static const char kLazyloadImagesAfterOnload[];
298  static const char kLazyloadImagesBlankUrl[];
299  static const char kLoadFromFileCacheTtlMs[];
300  static const char kLogBackgroundRewrite[];
301  static const char kLogRewriteTiming[];
302  static const char kLogUrlIndices[];
303  static const char kLowercaseHtmlNames[];
304  static const char kMaxCacheableResponseContentLength[];
305  static const char kMaxCombinedCssBytes[];
306  static const char kMaxCombinedJsBytes[];
307  static const char kMaxHtmlCacheTimeMs[];
308  static const char kMaxHtmlParseBytes[];
309  static const char kMaxImageBytesForWebpInCss[];
310  static const char kMaxImageSizeLowResolutionBytes[];
311  static const char kMaxInlinedPreviewImagesIndex[];
312  static const char kMaxLowResImageSizeBytes[];
313  static const char kMaxLowResToHighResImageSizePercentage[];
314  static const char kMaxPrefetchJsElements[];
315  static const char kMaxRewriteInfoLogSize[];
316  static const char kMaxUrlSegmentSize[];
317  static const char kMaxUrlSize[];
318  static const char kMetadataCacheStalenessThresholdMs[];
319  static const char kMinCacheTtlMs[];
320  static const char kMinImageSizeLowResolutionBytes[];
321  static const char kMinResourceCacheTimeToRewriteMs[];
322  static const char kMobCxxLayout[];
323  static const char kMobLayout[];
324  static const char kMobLogo[];
325  static const char kMobNav[];
326  static const char kModifyCachingHeaders[];
327  static const char kNoTransformOptimizedImages[];
328  static const char kNonCacheablesForCachePartialHtml[];
329  static const char kObliviousPagespeedUrls[];
330  static const char kOptionCookiesDurationMs[];
331  static const char kOverrideCachingTtlMs[];
332  static const char kPersistBlinkBlacklist[];
333  static const char kPreserveUrlRelativity[];
334  static const char kPrivateNotVaryForIE[];
335  static const char kPubliclyCacheMismatchedHashesExperimental[];
336  static const char kProactivelyFreshenUserFacingRequest[];
337  static const char kProactiveResourceFreshening[];
338  static const char kProgressiveJpegMinBytes[];
339  static const char kRejectBlacklisted[];
340  static const char kRejectBlacklistedStatusCode[];
341  static const char kReportUnloadTime[];
342  static const char kRequestOptionOverride[];
343  static const char kRespectVary[];
344  static const char kRespectXForwardedProto[];
345  static const char kRewriteDeadlineMs[];
346  static const char kRewriteLevel[];
347  static const char kRewriteRandomDropPercentage[];
348  static const char kRewriteUncacheableResources[];
349  static const char kRunningExperiment[];
350  static const char kServeGhostClickBusterWithSplitHtml[];
351  static const char kServeSplitHtmlInTwoChunks[];
352  static const char kServeStaleIfFetchError[];
353  static const char kServeStaleWhileRevalidateThresholdSec[];
354  static const char kServeXhrAccessControlHeaders[];
355  static const char kStickyQueryParameters[];
356  static const char kSupportNoScriptEnabled[];
357  static const char kTestOnlyPrioritizeCriticalCssDontApplyOriginalCss[];
358  static const char kUrlSigningKey[];
359  static const char kUseBlankImageForInlinePreview[];
360  static const char kUseExperimentalJsMinifier[];
361  static const char kUseFallbackPropertyCacheValues[];
362  static const char kUseImageScanlineApi[];
363  static const char kUseSelectorsForCriticalCss[];
364  static const char kUseSmartDiffInBlink[];
365  static const char kXModPagespeedHeaderValue[];
366  static const char kXPsaBlockingRewrite[];
368  static const char kAllow[];
369  static const char kBlockingRewriteRefererUrls[];
370  static const char kDisableFilters[];
371  static const char kDisallow[];
372  static const char kDistributableFilters[];
373  static const char kDomain[];
374  static const char kDownstreamCachePurgeLocationPrefix[];
375  static const char kEnableFilters[];
376  static const char kExperimentVariable[];
377  static const char kExperimentSpec[];
378  static const char kForbidFilters[];
379  static const char kInlineResourcesWithoutExplicitAuthorization[];
380  static const char kRetainComment[];
382  static const char kCustomFetchHeader[];
383  static const char kLoadFromFile[];
384  static const char kLoadFromFileMatch[];
385  static const char kLoadFromFileRule[];
386  static const char kLoadFromFileRuleMatch[];
387  static const char kMapOriginDomain[];
388  static const char kMapProxyDomain[];
389  static const char kMapRewriteDomain[];
390  static const char kShardDomain[];
392  static const char kLibrary[];
393  static const char kUrlValuedAttribute[];
396  static const char kCacheFlushFilename[];
397  static const char kCacheFlushPollIntervalSec[];
398  static const char kCompressMetadataCache[];
399  static const char kFetcherProxy[];
400  static const char kFetchFromModSpdy[];
401  static const char kFetchHttps[];
402  static const char kFileCacheCleanInodeLimit[];
403  static const char kFileCacheCleanIntervalMs[];
404  static const char kFileCacheCleanSizeKb[];
405  static const char kFileCachePath[];
406  static const char kLogDir[];
407  static const char kLruCacheByteLimit[];
408  static const char kLruCacheKbPerProcess[];
409  static const char kMemcachedServers[];
410  static const char kMemcachedThreads[];
411  static const char kMemcachedTimeoutUs[];
412  static const char kProxySuffix[];
413  static const char kRateLimitBackgroundFetches[];
414  static const char kServeWebpToAnyAgent[];
415  static const char kSlurpDirectory[];
416  static const char kSlurpFlushLimit[];
417  static const char kSlurpReadOnly[];
418  static const char kSslCertDirectory[];
419  static const char kSslCertFile[];
420  static const char kStatisticsEnabled[];
421  static const char kStatisticsLoggingChartsCSS[];
422  static const char kStatisticsLoggingChartsJS[];
423  static const char kStatisticsLoggingEnabled[];
424  static const char kStatisticsLoggingIntervalMs[];
425  static const char kStatisticsLoggingMaxFileSizeKb[];
426  static const char kTestProxy[];
427  static const char kTestProxySlurp[];
428  static const char kUseSharedMemLocking[];
430  static const char kNullOption[];
431 
439  struct BeaconUrl {
440  GoogleString http;
441  GoogleString https;
442  GoogleString http_in;
443  GoogleString https_in;
444  };
445 
446  struct NameValue {
447  NameValue(const StringPiece& name_in, const StringPiece& value_in) {
448  name_in.CopyToString(&name);
449  value_in.CopyToString(&value);
450  }
451  GoogleString name;
452  GoogleString value;
453  };
454 
470  static const int kOptionsVersion = 13;
471 
473  static const int kHashBytes = 20;
474 
476  static const int kCachePurgeBytes = 25000;
477 
484  enum OptionScope {
491  };
492 
493  static const char kCacheExtenderId[];
494  static const char kCollectFlushEarlyContentFilterId[];
495  static const char kCssCombinerId[];
496  static const char kCssFilterId[];
497  static const char kCssImportFlattenerId[];
498  static const char kCssInlineId[];
499  static const char kGoogleFontCssInlineId[];
500  static const char kImageCombineId[];
501  static const char kImageCompressionId[];
502  static const char kInPlaceRewriteId[];
503  static const char kJavascriptCombinerId[];
504  static const char kJavascriptInlineId[];
505  static const char kJavascriptMinId[];
506  static const char kJavascriptMinSourceMapId[];
507  static const char kLocalStorageCacheId[];
508  static const char kPrioritizeCriticalCssId[];
509 
510  static const char kPanelCommentPrefix[];
511 
514  static const char* FilterName(Filter filter);
515 
518  static const char* FilterId(Filter filter);
519 
522  static int NumFilterIds();
523 
526 
527  typedef EnumSet<Filter, kEndOfFilters> FilterSet;
528  typedef std::vector<Filter> FilterVector;
529 
531  typedef std::set<GoogleString> FilterIdSet;
532 
538  static bool AddByNameToFilterSet(const StringPiece& option, FilterSet* set,
539  MessageHandler* handler);
540 
543  typedef std::pair<GoogleString, GoogleString> OptionStringPair;
544  typedef std::set<OptionStringPair> OptionSet;
545 
546  typedef std::vector<PropertyBase*> PropertyVector;
547 
550  class OptionBase {
551  public:
552  OptionBase() {}
553  virtual ~OptionBase();
554 
558  virtual bool SetFromString(StringPiece value_string,
559  GoogleString* error_detail) = 0;
560  virtual void Merge(const OptionBase* src) = 0;
561  virtual bool was_set() const = 0;
562  virtual GoogleString Signature(const Hasher* hasher) const = 0;
563  virtual GoogleString ToString() const = 0;
564  const char* id() const { return property()->id(); }
565  const char* help_text() const { return property()->help_text(); }
566  OptionScope scope() const { return property()->scope(); }
567  StringPiece option_name() const { return property()->option_name(); }
568  bool is_used_for_signature_computation() const {
569  return property()->is_used_for_signature_computation();
570  }
571  virtual const PropertyBase* property() const = 0;
572  };
573 
575  typedef std::vector<OptionBase*> OptionBaseVector;
576 
583 
588 
595 
600 
604  };
605 
608  kOptionOk,
609  kOptionNameUnknown,
610  kOptionValueInvalid
611  };
612 
613  static const int kDefaultBeaconReinstrumentTimeSec;
614  static const int64 kDefaultBlinkMaxHtmlSizeRewritable;
615  static const int64 kDefaultCssFlattenMaxBytes;
616  static const int64 kDefaultCssImageInlineMaxBytes;
617  static const int64 kDefaultCssInlineMaxBytes;
618  static const int64 kDefaultCssOutlineMinBytes;
619  static const int64 kDefaultImageInlineMaxBytes;
620  static const int64 kDefaultJsInlineMaxBytes;
621  static const int64 kDefaultJsOutlineMinBytes;
622  static const int64 kDefaultProgressiveJpegMinBytes;
623  static const int64 kDefaultMaxCacheableResponseContentLength;
624  static const int64 kDefaultMaxHtmlCacheTimeMs;
625  static const int64 kDefaultMaxHtmlParseBytes;
626  static const int64 kDefaultMaxImageBytesForWebpInCss;
627  static const int64 kDefaultMaxLowResImageSizeBytes;
628  static const int kDefaultMaxLowResToFullResImageSizePercentage;
629  static const int64 kDefaultMetadataInputErrorsCacheTtlMs;
630  static const int64 kDefaultMinResourceCacheTimeToRewriteMs;
631  static const char kDefaultDownstreamCachePurgeMethod[];
632  static const int64 kDefaultDownstreamCacheRewrittenPercentageThreshold;
633  static const int64 kDefaultIdleFlushTimeMs;
634  static const int64 kDefaultFlushBufferLimitBytes;
635  static const int64 kDefaultImplicitCacheTtlMs;
636  static const int64 kDefaultMinCacheTtlMs;
637  static const int64 kDefaultPrioritizeVisibleContentCacheTimeMs;
638  static const char kDefaultBeaconUrl[];
639  static const int64 kDefaultImageRecompressQuality;
640  static const int64 kDefaultImageJpegRecompressQuality;
641  static const int64 kDefaultImageJpegRecompressQualityForSmallScreens;
642  static const int kDefaultImageLimitOptimizedPercent;
643  static const int kDefaultImageLimitRenderedAreaPercent;
644  static const int kDefaultImageLimitResizeAreaPercent;
645  static const int64 kDefaultImageResolutionLimitBytes;
646  static const int64 kDefaultImageJpegNumProgressiveScans;
647  static const int64 kDefaultImageWebpRecompressQuality;
648  static const int64 kDefaultImageWebpRecompressQualityForSmallScreens;
649  static const int64 kDefaultImageWebpTimeoutMs;
650  static const int kDefaultDomainShardCount;
651  static const int64 kDefaultBlinkHtmlChangeDetectionTimeMs;
652  static const int kDefaultMaxPrefetchJsElements;
653  static const int64 kDefaultOptionCookiesDurationMs;
654  static const int64 kDefaultLoadFromFileCacheTtlMs;
655 
658  static const int kDefaultMaxUrlSize;
659 
660  static const int kDefaultImageMaxRewritesAtOnce;
661 
666  static const int kDefaultMaxUrlSegmentSize;
667 
669  static const int kDefaultRewriteDeadlineMs;
670 
672  static const int64 kDefaultDistributedTimeoutMs;
673 
687 
691 
695 
697  static const int64 kDefaultMaxCombinedCssBytes;
698 
700  static const int64 kDefaultMaxCombinedJsBytes;
701 
702  static const int kDefaultExperimentTrafficPercent;
704  static const int kDefaultExperimentSlot;
705 
706  static const char kDefaultBlockingRewriteKey[];
707 
708  static const char kRejectedRequestUrlKeyName[];
709 
710  static const int kDefaultPropertyCacheHttpStatusStabilityThreshold;
711 
712  static const int kDefaultMaxRewriteInfoLogSize;
713 
721  public:
726  ExperimentSpec(const StringPiece& spec, const RewriteOptions* options,
727  MessageHandler* handler);
728 
732  explicit ExperimentSpec(int id);
733 
734  virtual ~ExperimentSpec();
735 
737  virtual ExperimentSpec* Clone();
738 
739  bool is_valid() const { return id_ >= 0; }
740 
742  int id() const { return id_; }
743  int percent() const { return percent_; }
744  GoogleString ga_id() const { return ga_id_; }
745  int slot() const { return ga_variable_slot_; }
746  RewriteLevel rewrite_level() const { return rewrite_level_; }
747  FilterSet enabled_filters() const { return enabled_filters_; }
748  FilterSet disabled_filters() const { return disabled_filters_; }
749  OptionSet filter_options() const { return filter_options_; }
750  bool matches_device_type(UserAgentMatcher::DeviceType type) const;
751  bool use_default() const { return use_default_; }
752  GoogleString ToString() const;
753 
754  protected:
759  void Merge(const ExperimentSpec& spec);
760 
761  typedef std::bitset<net_instaweb::UserAgentMatcher::kEndOfDeviceType>
762  DeviceTypeBitSet;
763 
764  static bool ParseDeviceTypeBitSet(const StringPiece& in,
765  DeviceTypeBitSet* out,
766  MessageHandler* handler);
767 
768  private:
769  FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
770  FRIEND_TEST(RewriteOptionsTest, DeviceTypeMergeTest);
771 
774  void Initialize(const StringPiece& spec, MessageHandler* handler);
775 
780  int id_;
781  GoogleString ga_id_;
782  int ga_variable_slot_;
783  int percent_;
784  RewriteLevel rewrite_level_;
785  FilterSet enabled_filters_;
786  FilterSet disabled_filters_;
787  OptionSet filter_options_;
791  scoped_ptr<DeviceTypeBitSet> matches_device_types_;
794  bool use_default_;
795  DISALLOW_COPY_AND_ASSIGN(ExperimentSpec);
796  };
797 
800  GoogleString element;
801  GoogleString attribute;
802  semantic_type::Category category;
803  };
804 
811  class Properties {
812  public:
821  static bool Initialize(Properties** properties);
822 
831  static bool Terminate(Properties** properties_handle);
832 
834  int size() const { return property_vector_.size(); }
835 
836  const PropertyBase* property(int index) const {
837  return property_vector_[index];
838  }
839  PropertyBase* property(int index) { return property_vector_[index]; }
840 
846  void Merge(Properties* properties);
847 
848  void push_back(PropertyBase* p) { property_vector_.push_back(p); }
849 
850  private:
853  Properties();
854  ~Properties();
855 
859  int initialization_count_;
860 
865  bool owns_properties_;
866  PropertyVector property_vector_;
867  };
868 
871  RewriteOptions::Filter filter_enum;
872  const char* filter_id;
873  const char* filter_name;
874  };
875 
876  static bool ParseRewriteLevel(const StringPiece& in, RewriteLevel* out);
877 
878  typedef std::set<semantic_type::Category> ResourceCategorySet;
879 
880  static bool ParseInlineUnauthorizedResourceType(
881  const StringPiece& in,
882  ResourceCategorySet* resource_types);
883 
887  static bool ParseBeaconUrl(const StringPiece& in, BeaconUrl* out);
888 
892  bool ImageOptimizationEnabled() const;
893 
894  explicit RewriteOptions(ThreadSystem* thread_system);
895  virtual ~RewriteOptions();
896 
900  static bool Initialize();
901  static bool Terminate();
902 
903 #ifndef NDEBUG
904  bool ModificationOK() const;
911 
918  bool MergeOK() const;
919 #endif
920 
925  void InitializeOptions(const Properties* properties);
926 
927  bool modified() const { return modified_; }
928 
936  level_.set_default(level);
937  }
938  void SetRewriteLevel(RewriteLevel level) {
939  set_option(level, &level_);
940  }
941 
943  void AddCustomFetchHeader(const StringPiece& name, const StringPiece& value);
944 
945  const NameValue* custom_fetch_header(int i) const {
946  return custom_fetch_headers_[i];
947  }
948 
949  int num_custom_fetch_headers() const {
950  return custom_fetch_headers_.size();
951  }
952 
955  ExperimentSpec* GetExperimentSpec(int id) const;
956 
960  bool AvailableExperimentId(int id);
961 
964  virtual ExperimentSpec* AddExperimentSpec(const StringPiece& spec,
965  MessageHandler* handler);
966 
974  virtual bool SetExperimentState(int id);
975 
979  void SetExperimentStateStr(const StringPiece& experiment_index);
980 
981  int experiment_id() const { return experiment_id_; }
982 
983  int experiment_spec_id(int i) const {
984  return experiment_specs_[i]->id();
985  }
986 
991  GoogleString GetExperimentStateStr() const;
992 
993  ExperimentSpec* experiment_spec(int i) const {
994  return experiment_specs_[i];
995  }
996 
997  int num_experiments() const { return experiment_specs_.size(); }
998 
999  bool enroll_experiment() const {
1000  return enroll_experiment_id() != experiment::kForceNoExperiment;
1001  }
1002 
1014  void AddUrlValuedAttribute(const StringPiece& element,
1015  const StringPiece& attribute,
1016  semantic_type::Category category);
1017 
1020  void UrlValuedAttribute(int index,
1021  StringPiece* element,
1022  StringPiece* attribute,
1023  semantic_type::Category* category) const;
1024 
1025  int num_url_valued_attributes() const {
1026  if (url_valued_attributes_ == NULL) {
1027  return 0;
1028  } else {
1029  return url_valued_attributes_->size();
1030  }
1031  }
1032 
1033  void AddInlineUnauthorizedResourceType(semantic_type::Category category);
1034  bool HasInlineUnauthorizedResourceType(
1035  semantic_type::Category category) const;
1036  void ClearInlineUnauthorizedResourceTypes();
1037  void set_inline_unauthorized_resource_types(ResourceCategorySet x);
1038 
1041  uint64 bytes, StringPiece md5_hash, StringPiece canonical_url) {
1042  return WriteableJavascriptLibraryIdentification()->RegisterLibrary(
1043  bytes, md5_hash, canonical_url);
1044  }
1045 
1049  const {
1050  if (Enabled(kCanonicalizeJavascriptLibraries)) {
1051  return javascript_library_identification_.get();
1052  } else {
1053  return NULL;
1054  }
1055  }
1056 
1057  RewriteLevel level() const { return level_.value(); }
1058 
1063  bool AdjustFiltersByCommaSeparatedList(const StringPiece& filters,
1064  MessageHandler* handler);
1065 
1069  bool EnableFiltersByCommaSeparatedList(const StringPiece& filters,
1070  MessageHandler* handler);
1071 
1075  bool DisableFiltersByCommaSeparatedList(const StringPiece& filters,
1076  MessageHandler* handler);
1077 
1081  bool ForbidFiltersByCommaSeparatedList(const StringPiece& filters,
1082  MessageHandler* handler);
1083 
1085  void DisableAllFilters();
1086 
1095 
1098  void DistributeFiltersByCommaSeparatedList(const StringPiece& filter_ids,
1099  MessageHandler* handler);
1102  void DistributeFilter(const StringPiece& filter_id);
1103 
1106  bool Distributable(const StringPiece& filter_id) const;
1107 
1111  void EnableFilter(Filter filter);
1114  void ForceEnableFilter(Filter filter);
1115  void DisableFilter(Filter filter);
1116  void DisableIfNotExplictlyEnabled(Filter filter);
1117  void ForbidFilter(Filter filter);
1118  void EnableFilters(const FilterSet& filter_set);
1119  void DisableFilters(const FilterSet& filter_set);
1120  void ForbidFilters(const FilterSet& filter_set);
1123  void ClearFilters();
1124 
1142  void SoftEnableFilterForTesting(Filter filter);
1143 
1146  void EnableExtendCacheFilters();
1147 
1148  bool Enabled(Filter filter) const;
1149  bool Forbidden(Filter filter) const;
1150  bool Forbidden(StringPiece filter_id) const;
1151 
1153  void GetEnabledFiltersRequiringScriptExecution(FilterVector* filters) const;
1154 
1157 
1163  const StringPiece& options, OptionSet* set, MessageHandler* handler);
1164 
1170  StringPiece name, StringPiece value, GoogleString* msg);
1171 
1174  StringPiece name, StringPiece value);
1175 
1179  OptionSettingResult SetOptionFromQuery(StringPiece name, StringPiece value);
1180 
1186  StringPiece name, StringPiece arg,
1187  GoogleString* msg, MessageHandler* handler);
1188 
1189  virtual OptionSettingResult ParseAndSetOptionFromName2(
1190  StringPiece name, StringPiece arg1, StringPiece arg2,
1191  GoogleString* msg, MessageHandler* handler);
1192 
1193  virtual OptionSettingResult ParseAndSetOptionFromName3(
1194  StringPiece name, StringPiece arg1, StringPiece arg2, StringPiece arg3,
1195  GoogleString* msg, MessageHandler* handler);
1196 
1202  bool OptionValue(StringPiece option_name, const char** id,
1203  bool* was_set, GoogleString* value) const;
1204 
1207  bool SetOptionsFromName(const OptionSet& option_set, MessageHandler* handler);
1208 
1211  bool SetOptionFromNameAndLog(StringPiece name,
1212  StringPiece value,
1213  MessageHandler* handler);
1214 
1217  static bool ParseFromString(StringPiece value_string, bool* value);
1218  static bool ParseFromString(StringPiece value_string, EnabledEnum* value);
1219  static bool ParseFromString(StringPiece value_string, int* value) {
1220  return StringToInt(value_string, value);
1221  }
1222  static bool ParseFromString(StringPiece value_string, int64* value) {
1223  return StringToInt64(value_string, value);
1224  }
1225  static bool ParseFromString(StringPiece value_string, GoogleString* value) {
1226  value_string.CopyToString(value);
1227  return true;
1228  }
1229  static bool ParseFromString(StringPiece value_string, RewriteLevel* value) {
1230  return ParseRewriteLevel(value_string, value);
1231  }
1232  static bool ParseFromString(StringPiece value_string,
1233  ResourceCategorySet* value) {
1234  return ParseInlineUnauthorizedResourceType(value_string, value);
1235  }
1236  static bool ParseFromString(StringPiece value_string, BeaconUrl* value) {
1237  return ParseBeaconUrl(value_string, value);
1238  }
1239  static bool ParseFromString(StringPiece value_string,
1240  protobuf::MessageLite* proto);
1241 
1244  int64 css_outline_min_bytes() const { return css_outline_min_bytes_.value(); }
1245  void set_css_outline_min_bytes(int64 x) {
1246  set_option(x, &css_outline_min_bytes_);
1247  }
1248 
1249  GoogleString ga_id() const { return ga_id_.value(); }
1250  void set_ga_id(GoogleString id) {
1251  set_option(id, &ga_id_);
1252  }
1253 
1254  bool increase_speed_tracking() const {
1255  return increase_speed_tracking_.value();
1256  }
1257  void set_increase_speed_tracking(bool x) {
1258  set_option(x, &increase_speed_tracking_);
1259  }
1260 
1261  int64 js_outline_min_bytes() const { return js_outline_min_bytes_.value(); }
1262  void set_js_outline_min_bytes(int64 x) {
1263  set_option(x, &js_outline_min_bytes_);
1264  }
1265 
1266  int64 progressive_jpeg_min_bytes() const {
1267  return progressive_jpeg_min_bytes_.value();
1268  }
1269  void set_progressive_jpeg_min_bytes(int64 x) {
1270  set_option(x, &progressive_jpeg_min_bytes_);
1271  }
1272 
1273  int64 css_flatten_max_bytes() const { return css_flatten_max_bytes_.value(); }
1274  void set_css_flatten_max_bytes(int64 x) {
1275  set_option(x, &css_flatten_max_bytes_);
1276  }
1277  bool cache_small_images_unrewritten() const {
1278  return cache_small_images_unrewritten_.value();
1279  }
1280  void set_cache_small_images_unrewritten(bool x) {
1281  set_option(x, &cache_small_images_unrewritten_);
1282  }
1283  int64 image_resolution_limit_bytes() const {
1284  return image_resolution_limit_bytes_.value();
1285  }
1286  void set_image_resolution_limit_bytes(int64 x) {
1287  set_option(x, &image_resolution_limit_bytes_);
1288  }
1289 
1291  int64 ImageInlineMaxBytes() const;
1292  void set_image_inline_max_bytes(int64 x);
1294  int64 CssImageInlineMaxBytes() const;
1295  void set_css_image_inline_max_bytes(int64 x) {
1296  set_option(x, &css_image_inline_max_bytes_);
1297  }
1299  int64 MaxImageInlineMaxBytes() const;
1300  int64 css_inline_max_bytes() const { return css_inline_max_bytes_.value(); }
1301  void set_css_inline_max_bytes(int64 x) {
1302  set_option(x, &css_inline_max_bytes_);
1303  }
1304  int64 js_inline_max_bytes() const { return js_inline_max_bytes_.value(); }
1305  void set_js_inline_max_bytes(int64 x) {
1306  set_option(x, &js_inline_max_bytes_);
1307  }
1308  int64 max_html_cache_time_ms() const {
1309  return max_html_cache_time_ms_.value();
1310  }
1311  void set_max_html_cache_time_ms(int64 x) {
1312  set_option(x, &max_html_cache_time_ms_);
1313  }
1314  int64 max_html_parse_bytes() const {
1315  return max_html_parse_bytes_.value();
1316  }
1317  void set_max_html_parse_bytes(int64 x) {
1318  set_option(x, &max_html_parse_bytes_);
1319  }
1320  int64 max_image_bytes_for_webp_in_css() const {
1321  return max_image_bytes_for_webp_in_css_.value();
1322  }
1323  void set_max_image_bytes_for_webp_in_css(int64 x) {
1324  set_option(x, &max_image_bytes_for_webp_in_css_);
1325  }
1326  int64 max_cacheable_response_content_length() const {
1327  return max_cacheable_response_content_length_.value();
1328  }
1329  void set_max_cacheable_response_content_length(int64 x) {
1330  set_option(x, &max_cacheable_response_content_length_);
1331  }
1332  int64 min_resource_cache_time_to_rewrite_ms() const {
1333  return min_resource_cache_time_to_rewrite_ms_.value();
1334  }
1335  void set_min_resource_cache_time_to_rewrite_ms(int64 x) {
1336  set_option(x, &min_resource_cache_time_to_rewrite_ms_);
1337  }
1338  bool need_to_store_experiment_data() const {
1339  return need_to_store_experiment_data_;
1340  }
1341  void set_need_to_store_experiment_data(bool x) {
1342  need_to_store_experiment_data_ = x;
1343  }
1344 
1345  int64 blocking_fetch_timeout_ms() const {
1346  return blocking_fetch_timeout_ms_.value();
1347  }
1348  void set_blocking_fetch_timeout_ms(int64 x) {
1349  set_option(x, &blocking_fetch_timeout_ms_);
1350  }
1351  bool override_ie_document_mode() const {
1352  return override_ie_document_mode_.value();
1353  }
1354  void set_override_ie_document_mode(bool x) {
1355  set_option(x, &override_ie_document_mode_);
1356  }
1357 
1358  int64 blink_blacklist_end_timestamp_ms() const {
1359  return blink_blacklist_end_timestamp_ms_.value();
1360  }
1361  void set_blink_blacklist_end_timestamp_ms(int64 x) {
1362  set_option(x, &blink_blacklist_end_timestamp_ms_);
1363  }
1364 
1365  bool persist_blink_blacklist() const {
1366  return persist_blink_blacklist_.value();
1367  }
1368  void set_persist_blink_blacklist(bool x) {
1369  set_option(x, &persist_blink_blacklist_);
1370  }
1371 
1372  bool preserve_url_relativity() const {
1373  return preserve_url_relativity_.value();
1374  }
1375  void set_preserve_url_relativity(bool x) {
1376  set_option(x, &preserve_url_relativity_);
1377  }
1378 
1395  bool IsUrlCacheValid(StringPiece url, int64 time_ms,
1396  bool search_wildcards) const;
1397 
1414  void AddUrlCacheInvalidationEntry(StringPiece url_pattern,
1415  int64 timestamp_ms,
1416  bool ignores_metadata_and_pcache);
1417 
1419  void PurgeUrl(StringPiece url, int64 timestamp_ms);
1420 
1424 
1427  void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock* lock) {
1428  cache_purge_mutex_.reset(lock);
1429  }
1430 
1435  int64 cache_invalidation_timestamp() const;
1436 
1441 
1450  bool UpdateCacheInvalidationTimestampMs(int64 timestamp_ms)
1451  LOCKS_EXCLUDED(cache_purge_mutex_.get());
1452 
1456  bool UpdateCachePurgeSet(const CopyOnWrite<PurgeSet>& purge_set)
1457  LOCKS_EXCLUDED(cache_purge_mutex_.get());
1458 
1461  GoogleString PurgeSetString() const;
1462 
1465  int64 idle_flush_time_ms() const {
1466  return idle_flush_time_ms_.value();
1467  }
1468  void set_idle_flush_time_ms(int64 x) {
1469  set_option(x, &idle_flush_time_ms_);
1470  }
1471 
1474  return flush_buffer_limit_bytes_.value();
1475  }
1476 
1477  void set_flush_buffer_limit_bytes(int64 x) {
1478  set_option(x, &flush_buffer_limit_bytes_);
1479  }
1480 
1483  int max_url_segment_size() const { return max_url_segment_size_.value(); }
1484  void set_max_url_segment_size(int x) {
1485  set_option(x, &max_url_segment_size_);
1486  }
1487 
1488  int image_max_rewrites_at_once() const {
1489  return image_max_rewrites_at_once_.value();
1490  }
1491  void set_image_max_rewrites_at_once(int x) {
1492  set_option(x, &image_max_rewrites_at_once_);
1493  }
1494 
1496  int max_url_size() const { return max_url_size_.value(); }
1497  void set_max_url_size(int x) {
1498  set_option(x, &max_url_size_);
1499  }
1500 
1501  int rewrite_deadline_ms() const { return rewrite_deadline_ms_.value(); }
1502  void set_rewrite_deadline_ms(int x) {
1503  set_option(x, &rewrite_deadline_ms_);
1504  }
1505 
1506  bool test_instant_fetch_rewrite_deadline() const {
1507  return test_instant_fetch_rewrite_deadline_.value();
1508  }
1509  void set_test_instant_fetch_rewrite_deadline(bool x) {
1510  set_option(x, &test_instant_fetch_rewrite_deadline_);
1511  }
1512 
1513  void set_test_only_prioritize_critical_css_dont_apply_original_css(bool x) {
1514  set_option(x, &test_only_prioritize_critical_css_dont_apply_original_css_);
1515  }
1516  bool test_only_prioritize_critical_css_dont_apply_original_css() const {
1517  return test_only_prioritize_critical_css_dont_apply_original_css_.value();
1518  }
1519 
1520  int domain_shard_count() const { return domain_shard_count_.value(); }
1523  void set_domain_shard_count(int64 x) {
1524  int value = x;
1525  set_option(value, &domain_shard_count_);
1526  }
1527 
1528  void set_enabled(EnabledEnum x) {
1529  set_option(x, &enabled_);
1530  }
1531  bool enabled() const {
1532  return enabled_.value() == kEnabledOn;
1533  }
1534  bool unplugged() const {
1535  return enabled_.value() == kEnabledUnplugged;
1536  }
1537 
1538  void set_add_options_to_urls(bool x) {
1539  set_option(x, &add_options_to_urls_);
1540  }
1541 
1542  bool add_options_to_urls() const {
1543  return add_options_to_urls_.value();
1544  }
1545 
1546  void set_publicly_cache_mismatched_hashes_experimental(bool x) {
1547  set_option(x, &publicly_cache_mismatched_hashes_experimental_);
1548  }
1549 
1550  bool publicly_cache_mismatched_hashes_experimental() const {
1551  return publicly_cache_mismatched_hashes_experimental_.value();
1552  }
1553 
1554  void set_oblivious_pagespeed_urls(bool x) {
1555  set_option(x, &oblivious_pagespeed_urls_);
1556  }
1557 
1558  bool oblivious_pagespeed_urls() const {
1559  return oblivious_pagespeed_urls_.value();
1560  }
1561 
1562  void set_in_place_rewriting_enabled(bool x) {
1563  set_option(x, &in_place_rewriting_enabled_);
1564  }
1565 
1566  bool in_place_rewriting_enabled() const {
1567  return CheckBandwidthOption(in_place_rewriting_enabled_);
1568  }
1569 
1570  void set_in_place_wait_for_optimized(bool x) {
1571  set_option(x, &in_place_wait_for_optimized_);
1572  }
1573 
1574  bool in_place_wait_for_optimized() const {
1575  return (in_place_wait_for_optimized_.value() ||
1576  (in_place_rewrite_deadline_ms() < 0));
1577  }
1578 
1579  void set_in_place_rewrite_deadline_ms(int x) {
1580  set_option(x, &in_place_rewrite_deadline_ms_);
1581  }
1582 
1583  int in_place_rewrite_deadline_ms() const {
1584  return in_place_rewrite_deadline_ms_.value();
1585  }
1586 
1587  void set_in_place_preemptive_rewrite_css(bool x) {
1588  set_option(x, &in_place_preemptive_rewrite_css_);
1589  }
1590  bool in_place_preemptive_rewrite_css() const {
1591  return CheckBandwidthOption(in_place_preemptive_rewrite_css_);
1592  }
1593 
1594  void set_in_place_preemptive_rewrite_css_images(bool x) {
1595  set_option(x, &in_place_preemptive_rewrite_css_images_);
1596  }
1597  bool in_place_preemptive_rewrite_css_images() const {
1598  return CheckBandwidthOption(in_place_preemptive_rewrite_css_images_);
1599  }
1600 
1601  void set_in_place_preemptive_rewrite_images(bool x) {
1602  set_option(x, &in_place_preemptive_rewrite_images_);
1603  }
1604  bool in_place_preemptive_rewrite_images() const {
1605  return CheckBandwidthOption(in_place_preemptive_rewrite_images_);
1606  }
1607 
1608  void set_in_place_preemptive_rewrite_javascript(bool x) {
1609  set_option(x, &in_place_preemptive_rewrite_javascript_);
1610  }
1611  bool in_place_preemptive_rewrite_javascript() const {
1612  return CheckBandwidthOption(in_place_preemptive_rewrite_javascript_);
1613  }
1614 
1615  void set_private_not_vary_for_ie(bool x) {
1616  set_option(x, &private_not_vary_for_ie_);
1617  }
1618  bool private_not_vary_for_ie() const {
1619  return private_not_vary_for_ie_.value();
1620  }
1621 
1622  void set_combine_across_paths(bool x) {
1623  set_option(x, &combine_across_paths_);
1624  }
1625  bool combine_across_paths() const { return combine_across_paths_.value(); }
1626 
1627  void set_log_background_rewrites(bool x) {
1628  set_option(x, &log_background_rewrites_);
1629  }
1630  bool log_background_rewrites() const {
1631  return log_background_rewrites_.value();
1632  }
1633 
1634  void set_log_rewrite_timing(bool x) {
1635  set_option(x, &log_rewrite_timing_);
1636  }
1637  bool log_rewrite_timing() const { return log_rewrite_timing_.value(); }
1638 
1639  void set_log_url_indices(bool x) {
1640  set_option(x, &log_url_indices_);
1641  }
1642  bool log_url_indices() const { return log_url_indices_.value(); }
1643 
1644  void set_lowercase_html_names(bool x) {
1645  set_option(x, &lowercase_html_names_);
1646  }
1647  bool lowercase_html_names() const { return lowercase_html_names_.value(); }
1648 
1649  void set_always_rewrite_css(bool x) {
1650  set_option(x, &always_rewrite_css_);
1651  }
1652  bool always_rewrite_css() const { return always_rewrite_css_.value(); }
1653 
1654  void set_respect_vary(bool x) {
1655  set_option(x, &respect_vary_);
1656  }
1657  bool respect_vary() const { return respect_vary_.value(); }
1658 
1659  void set_respect_x_forwarded_proto(bool x) {
1660  set_option(x, &respect_x_forwarded_proto_);
1661  }
1662  bool respect_x_forwarded_proto() const {
1663  return respect_x_forwarded_proto_.value();
1664  }
1665 
1666  void set_flush_html(bool x) { set_option(x, &flush_html_); }
1667  bool flush_html() const { return flush_html_.value(); }
1668 
1669  void set_serve_split_html_in_two_chunks(bool x) {
1670  set_option(x, &serve_split_html_in_two_chunks_);
1671  }
1672  bool serve_split_html_in_two_chunks() const {
1673  return serve_split_html_in_two_chunks_.value();
1674  }
1675 
1676  void set_serve_stale_if_fetch_error(bool x) {
1677  set_option(x, &serve_stale_if_fetch_error_);
1678  }
1679  bool serve_stale_if_fetch_error() const {
1680  return serve_stale_if_fetch_error_.value();
1681  }
1682 
1683  void set_serve_ghost_click_buster_with_split_html(bool x) {
1684  set_option(x, &serve_ghost_click_buster_with_split_html_);
1685  }
1686  bool serve_ghost_click_buster_with_split_html() const {
1687  return serve_ghost_click_buster_with_split_html_.value();
1688  }
1689 
1690  void set_serve_xhr_access_control_headers(bool x) {
1691  set_option(x, &serve_xhr_access_control_headers_);
1692  }
1693  bool serve_xhr_access_control_headers() const {
1694  return serve_xhr_access_control_headers_.value();
1695  }
1696 
1697  void set_proactively_freshen_user_facing_request(bool x) {
1698  set_option(x, &proactively_freshen_user_facing_request_);
1699  }
1700  bool proactively_freshen_user_facing_request() const {
1701  return proactively_freshen_user_facing_request_.value();
1702  }
1703 
1704  void set_serve_stale_while_revalidate_threshold_sec(int64 x) {
1705  set_option(x, &serve_stale_while_revalidate_threshold_sec_);
1706  }
1707  int64 serve_stale_while_revalidate_threshold_sec() const {
1708  return serve_stale_while_revalidate_threshold_sec_.value();
1709  }
1710 
1711  void set_enable_flush_early_critical_css(bool x) {
1712  set_option(x, &enable_flush_early_critical_css_);
1713  }
1714  bool enable_flush_early_critical_css() const {
1715  return enable_flush_early_critical_css_.value();
1716  }
1717 
1718  void set_use_selectors_for_critical_css(bool x) {
1719  set_option(x, &use_selectors_for_critical_css_);
1720  }
1721  bool use_selectors_for_critical_css() const {
1722  return use_selectors_for_critical_css_.value();
1723  }
1724 
1725  void set_default_cache_html(bool x) { set_option(x, &default_cache_html_); }
1726  bool default_cache_html() const { return default_cache_html_.value(); }
1727 
1728  void set_modify_caching_headers(bool x) {
1729  set_option(x, &modify_caching_headers_);
1730  }
1731  bool modify_caching_headers() const {
1732  return modify_caching_headers_.value();
1733  }
1734 
1735  void set_inline_only_critical_images(bool x) {
1736  set_option(x, &inline_only_critical_images_);
1737  }
1738  bool inline_only_critical_images() const {
1739  return inline_only_critical_images_.value();
1740  }
1741 
1742  void set_critical_images_beacon_enabled(bool x) {
1743  set_option(x, &critical_images_beacon_enabled_);
1744  }
1745  bool critical_images_beacon_enabled() const {
1746  return critical_images_beacon_enabled_.value();
1747  }
1748 
1749  void set_beacon_reinstrument_time_sec(int x) {
1750  set_option(x, &beacon_reinstrument_time_sec_);
1751  }
1752  int beacon_reinstrument_time_sec() const {
1753  return beacon_reinstrument_time_sec_.value();
1754  }
1755 
1756  void set_accept_invalid_signatures(bool x) {
1757  set_option(x, &accept_invalid_signatures_);
1758  }
1759  bool accept_invalid_signatures() const {
1760  return accept_invalid_signatures_.value();
1761  }
1762 
1763  void set_request_option_override(StringPiece p) {
1764  set_option(GoogleString(p.data(), p.size()), &request_option_override_);
1765  }
1766  const GoogleString& request_option_override() const {
1767  return request_option_override_.value();
1768  }
1769 
1770  void set_url_signing_key(StringPiece p) {
1771  set_option(GoogleString(p.data(), p.size()), &url_signing_key_);
1772  }
1773  const GoogleString& url_signing_key() const {
1774  return url_signing_key_.value();
1775  }
1776 
1777  void set_lazyload_images_after_onload(bool x) {
1778  set_option(x, &lazyload_images_after_onload_);
1779  }
1780  bool lazyload_images_after_onload() const {
1781  return lazyload_images_after_onload_.value();
1782  }
1783 
1784  void set_lazyload_images_blank_url(const StringPiece& p) {
1785  set_option(GoogleString(p.data(), p.size()), &lazyload_images_blank_url_);
1786  }
1787  const GoogleString& lazyload_images_blank_url() const {
1788  return lazyload_images_blank_url_.value();
1789  }
1790 
1791  void set_max_inlined_preview_images_index(int x) {
1792  set_option(x, &max_inlined_preview_images_index_);
1793  }
1794  int max_inlined_preview_images_index() const {
1795  return max_inlined_preview_images_index_.value();
1796  }
1797 
1798  void set_use_blank_image_for_inline_preview(bool x) {
1799  set_option(x, &use_blank_image_for_inline_preview_);
1800  }
1801  bool use_blank_image_for_inline_preview() const {
1802  return use_blank_image_for_inline_preview_.value();
1803  }
1804 
1805  void set_min_image_size_low_resolution_bytes(int64 x) {
1806  set_option(x, &min_image_size_low_resolution_bytes_);
1807  }
1808  int64 min_image_size_low_resolution_bytes() const {
1809  return min_image_size_low_resolution_bytes_.value();
1810  }
1811 
1812  void set_max_image_size_low_resolution_bytes(int64 x) {
1813  set_option(x, &max_image_size_low_resolution_bytes_);
1814  }
1815  int64 max_image_size_low_resolution_bytes() const {
1816  return max_image_size_low_resolution_bytes_.value();
1817  }
1818 
1819  void set_experiment_cookie_duration_ms(int64 x) {
1820  set_option(x, &experiment_cookie_duration_ms_);
1821  }
1822  int64 experiment_cookie_duration_ms() const {
1823  return experiment_cookie_duration_ms_.value();
1824  }
1825 
1826  void set_finder_properties_cache_expiration_time_ms(int64 x) {
1827  set_option(x, &finder_properties_cache_expiration_time_ms_);
1828  }
1829  int64 finder_properties_cache_expiration_time_ms() const {
1830  return finder_properties_cache_expiration_time_ms_.value();
1831  }
1832 
1833  void set_finder_properties_cache_refresh_time_ms(int64 x) {
1834  set_option(x, &finder_properties_cache_refresh_time_ms_);
1835  }
1836  int64 finder_properties_cache_refresh_time_ms() const {
1837  return finder_properties_cache_refresh_time_ms_.value();
1838  }
1839 
1840  void set_rewrite_random_drop_percentage(int x) {
1841  set_option(x, &rewrite_random_drop_percentage_);
1842  }
1843  int rewrite_random_drop_percentage() const {
1844  return rewrite_random_drop_percentage_.value();
1845  }
1846 
1847  bool css_preserve_urls() const {
1848  return CheckBandwidthOption(css_preserve_urls_);
1849  }
1850  void set_css_preserve_urls(bool x) {
1851  set_option(x, &css_preserve_urls_);
1852  }
1853 
1854  bool image_preserve_urls() const {
1855  return CheckBandwidthOption(image_preserve_urls_);
1856  }
1857  void set_image_preserve_urls(bool x) {
1858  set_option(x, &image_preserve_urls_);
1859  }
1860 
1861  bool js_preserve_urls() const {
1862  return CheckBandwidthOption(js_preserve_urls_);
1863  }
1864  void set_js_preserve_urls(bool x) {
1865  set_option(x, &js_preserve_urls_);
1866  }
1867 
1868  void set_metadata_cache_staleness_threshold_ms(int64 x) {
1869  set_option(x, &metadata_cache_staleness_threshold_ms_);
1870  }
1871  int64 metadata_cache_staleness_threshold_ms() const {
1872  return metadata_cache_staleness_threshold_ms_.value();
1873  }
1874 
1875  void set_metadata_input_errors_cache_ttl_ms(int64 x) {
1876  set_option(x, &metadata_input_errors_cache_ttl_ms_);
1877  }
1878  int64 metadata_input_errors_cache_ttl_ms() const {
1879  return metadata_input_errors_cache_ttl_ms_.value();
1880  }
1881 
1882  const GoogleString& downstream_cache_purge_method() const {
1883  return downstream_cache_purge_method_.value();
1884  }
1885  void set_downstream_cache_purge_method(const StringPiece& p) {
1886  set_option(p.as_string(), &downstream_cache_purge_method_);
1887  }
1888 
1889  const GoogleString& downstream_cache_purge_location_prefix() const {
1890  return downstream_cache_purge_location_prefix_.value();
1891  }
1895  while (p.ends_with("/")) {
1896  p.remove_suffix(1);
1897  }
1898  set_option(p.as_string(), &downstream_cache_purge_location_prefix_);
1899  }
1900  bool IsDownstreamCacheIntegrationEnabled() const {
1901  return !downstream_cache_purge_location_prefix().empty();
1902  }
1903 
1904  void set_downstream_cache_rebeaconing_key(const StringPiece& p) {
1905  set_option(p.as_string(), &downstream_cache_rebeaconing_key_);
1906  }
1907  const GoogleString& downstream_cache_rebeaconing_key() const {
1908  return downstream_cache_rebeaconing_key_.value();
1909  }
1910  bool IsDownstreamCacheRebeaconingKeyConfigured() const {
1911  return !downstream_cache_rebeaconing_key().empty();
1912  }
1915  bool MatchesDownstreamCacheRebeaconingKey(StringPiece key) const {
1916  if (!IsDownstreamCacheRebeaconingKeyConfigured()) {
1917  return false;
1918  }
1919  return StringCaseEqual(key, downstream_cache_rebeaconing_key());
1920  }
1921 
1922  void set_downstream_cache_rewritten_percentage_threshold(int64 x) {
1923  set_option(x, &downstream_cache_rewritten_percentage_threshold_);
1924  }
1925  int64 downstream_cache_rewritten_percentage_threshold() const {
1926  return downstream_cache_rewritten_percentage_threshold_.value();
1927  }
1928 
1929  const BeaconUrl& beacon_url() const { return beacon_url_.value(); }
1930  void set_beacon_url(const GoogleString& beacon_url) {
1931  GoogleString ignored_error_detail;
1932  beacon_url_.SetFromString(beacon_url, &ignored_error_detail);
1933  }
1934 
1936  virtual bool trim_urls_in_css() const { return true; }
1937 
1938  int64 image_jpeg_recompress_quality() const {
1939  return image_jpeg_recompress_quality_.value();
1940  }
1941  void set_image_jpeg_recompress_quality(int64 x) {
1942  set_option(x, &image_jpeg_recompress_quality_);
1943  }
1944 
1945  int64 image_jpeg_recompress_quality_for_small_screens() const {
1946  return image_jpeg_recompress_quality_for_small_screens_.value();
1947  }
1948  void set_image_jpeg_recompress_quality_for_small_screens(int64 x) {
1949  set_option(x, &image_jpeg_recompress_quality_for_small_screens_);
1950  }
1951 
1952  int64 image_recompress_quality() const {
1953  return image_recompress_quality_.value();
1954  }
1955  void set_image_recompress_quality(int64 x) {
1956  set_option(x, &image_recompress_quality_);
1957  }
1958 
1959  int image_limit_optimized_percent() const {
1960  return image_limit_optimized_percent_.value();
1961  }
1962  void set_image_limit_optimized_percent(int x) {
1963  set_option(x, &image_limit_optimized_percent_);
1964  }
1965  int image_limit_resize_area_percent() const {
1966  return image_limit_resize_area_percent_.value();
1967  }
1968  void set_image_limit_resize_area_percent(int x) {
1969  set_option(x, &image_limit_resize_area_percent_);
1970  }
1971 
1972  int image_limit_rendered_area_percent() const {
1973  return image_limit_rendered_area_percent_.value();
1974  }
1975  void set_image_limit_rendered_area_percent(int x) {
1976  set_option(x, &image_limit_rendered_area_percent_);
1977  }
1978 
1979  int64 image_jpeg_num_progressive_scans() const {
1980  return image_jpeg_num_progressive_scans_.value();
1981  }
1982  void set_image_jpeg_num_progressive_scans(int64 x) {
1983  set_option(x, &image_jpeg_num_progressive_scans_);
1984  }
1985 
1986  int64 image_jpeg_num_progressive_scans_for_small_screens() const {
1987  return image_jpeg_num_progressive_scans_for_small_screens_.value();
1988  }
1989  void set_image_jpeg_num_progressive_scans_for_small_screens(int64 x) {
1990  set_option(x, &image_jpeg_num_progressive_scans_for_small_screens_);
1991  }
1992 
1993  int64 image_webp_recompress_quality() const {
1994  return image_webp_recompress_quality_.value();
1995  }
1996  void set_image_webp_recompress_quality(int64 x) {
1997  set_option(x, &image_webp_recompress_quality_);
1998  }
1999 
2000  int64 image_webp_recompress_quality_for_small_screens() const {
2001  return image_webp_recompress_quality_for_small_screens_.value();
2002  }
2003  void set_image_webp_recompress_quality_for_small_screens(int64 x) {
2004  set_option(x, &image_webp_recompress_quality_for_small_screens_);
2005  }
2006  int64 image_webp_timeout_ms() const {
2007  return image_webp_timeout_ms_.value();
2008  }
2009  void set_image_webp_timeout_ms(int64 x) {
2010  set_option(x, &image_webp_timeout_ms_);
2011  }
2012 
2013  bool domain_rewrite_hyperlinks() const {
2014  return domain_rewrite_hyperlinks_.value();
2015  }
2016  void set_domain_rewrite_hyperlinks(bool x) {
2017  set_option(x, &domain_rewrite_hyperlinks_);
2018  }
2019 
2020  bool client_domain_rewrite() const {
2021  return client_domain_rewrite_.value();
2022  }
2023  void set_client_domain_rewrite(bool x) {
2024  set_option(x, &client_domain_rewrite_);
2025  }
2026 
2027  void set_flush_more_resources_early_if_time_permits(bool x) {
2028  set_option(x, &flush_more_resources_early_if_time_permits_);
2029  }
2030  bool flush_more_resources_early_if_time_permits() const {
2031  return flush_more_resources_early_if_time_permits_.value();
2032  }
2033 
2034  void set_flush_more_resources_in_ie_and_firefox(bool x) {
2035  set_option(x, &flush_more_resources_in_ie_and_firefox_);
2036  }
2037  bool flush_more_resources_in_ie_and_firefox() const {
2038  return flush_more_resources_in_ie_and_firefox_.value();
2039  }
2040 
2041  void set_max_prefetch_js_elements(int x) {
2042  set_option(x, &max_prefetch_js_elements_);
2043  }
2044  int max_prefetch_js_elements() const {
2045  return max_prefetch_js_elements_.value();
2046  }
2047 
2048  void set_enable_defer_js_experimental(bool x) {
2049  set_option(x, &enable_defer_js_experimental_);
2050  }
2051  bool enable_defer_js_experimental() const {
2052  return enable_defer_js_experimental_.value();
2053  }
2054 
2055  void set_disable_rewrite_on_no_transform(bool x) {
2056  set_option(x, &disable_rewrite_on_no_transform_);
2057  }
2058  bool disable_rewrite_on_no_transform() const {
2059  return disable_rewrite_on_no_transform_.value();
2060  }
2061 
2062  void set_disable_background_fetches_for_bots(bool x) {
2063  set_option(x, &disable_background_fetches_for_bots_);
2064  }
2065  bool disable_background_fetches_for_bots() const {
2066  return disable_background_fetches_for_bots_.value();
2067  }
2068 
2069  void set_enable_cache_purge(bool x) {
2070  set_option(x, &enable_cache_purge_);
2071  }
2072  bool enable_cache_purge() const {
2073  return enable_cache_purge_.value();
2074  }
2075 
2076  void set_proactive_resource_freshening(bool x) {
2077  set_option(x, &proactive_resource_freshening_);
2078  }
2079  bool proactive_resource_freshening() const {
2080  return proactive_resource_freshening_.value();
2081  }
2082 
2083  void set_lazyload_highres_images(bool x) {
2084  set_option(x, &lazyload_highres_images_);
2085  }
2086  bool lazyload_highres_images() const {
2087  return lazyload_highres_images_.value();
2088  }
2089 
2090  void set_enable_blink_debug_dashboard(bool x) {
2091  set_option(x, &enable_blink_debug_dashboard_);
2092  }
2093  bool enable_blink_debug_dashboard() const {
2094  return enable_blink_debug_dashboard_.value();
2095  }
2096 
2097  void set_enable_blink_html_change_detection(bool x) {
2098  set_option(x, &enable_blink_html_change_detection_);
2099  }
2100  bool enable_blink_html_change_detection() const {
2101  return enable_blink_html_change_detection_.value();
2102  }
2103 
2104  void set_enable_blink_html_change_detection_logging(bool x) {
2105  set_option(x, &enable_blink_html_change_detection_logging_);
2106  }
2107  bool enable_blink_html_change_detection_logging() const {
2108  return enable_blink_html_change_detection_logging_.value();
2109  }
2110 
2111  void set_use_smart_diff_in_blink(bool x) {
2112  set_option(x, &use_smart_diff_in_blink_);
2113  }
2114  bool use_smart_diff_in_blink() const {
2115  return use_smart_diff_in_blink_.value();
2116  }
2117 
2118  void set_use_fallback_property_cache_values(bool x) {
2119  set_option(x, &use_fallback_property_cache_values_);
2120  }
2121  bool use_fallback_property_cache_values() const {
2122  return use_fallback_property_cache_values_.value();
2123  }
2124 
2125  void set_await_pcache_lookup(bool x) {
2126  set_option(x, &await_pcache_lookup_);
2127  }
2128  bool await_pcache_lookup() const {
2129  return await_pcache_lookup_.value();
2130  }
2131 
2132  void set_enable_prioritizing_scripts(bool x) {
2133  set_option(x, &enable_prioritizing_scripts_);
2134  }
2135  bool enable_prioritizing_scripts() const {
2136  return enable_prioritizing_scripts_.value();
2137  }
2138 
2139  void set_blink_html_change_detection_time_ms(int64 x) {
2140  set_option(x, &blink_html_change_detection_time_ms_);
2141  }
2142  int64 blink_html_change_detection_time_ms() const {
2143  return blink_html_change_detection_time_ms_.value();
2144  }
2145 
2146  const GoogleString& blocking_rewrite_key() const {
2147  return blocking_rewrite_key_.value();
2148  }
2149  void set_blocking_rewrite_key(const StringPiece& p) {
2150  set_option(p.as_string(), &blocking_rewrite_key_);
2151  }
2152 
2153  void EnableBlockingRewriteForRefererUrlPattern(
2154  const StringPiece& url_pattern) {
2155  Modify();
2156  blocking_rewrite_referer_urls_.MakeWriteable()->Allow(url_pattern);
2157  }
2158 
2159  bool IsBlockingRewriteEnabledForReferer(const StringPiece& url) const {
2160  return blocking_rewrite_referer_urls_->Match(url, false);
2161  }
2162 
2163  bool IsBlockingRewriteRefererUrlPatternPresent() const {
2164  return blocking_rewrite_referer_urls_->num_wildcards() > 0;
2165  }
2166 
2167  bool rewrite_uncacheable_resources() const {
2168  return rewrite_uncacheable_resources_.value();
2169  }
2170 
2171  void set_rewrite_uncacheable_resources(bool x) {
2172  set_option(x, &rewrite_uncacheable_resources_);
2173  }
2174 
2175  void set_running_experiment(bool x) {
2176  set_option(x, &running_experiment_);
2177  }
2178  bool running_experiment() const {
2179  return running_experiment_.value();
2180  }
2181 
2184  set_option(x, &experiment_ga_slot_);
2185  }
2186  int experiment_ga_slot() const { return experiment_ga_slot_.value(); }
2187 
2188  void set_enroll_experiment_id(int x) {
2189  set_option(x, &enroll_experiment_id_);
2190  }
2191  int enroll_experiment_id() const { return enroll_experiment_id_.value(); }
2192 
2193  void set_report_unload_time(bool x) {
2194  set_option(x, &report_unload_time_);
2195  }
2196  bool report_unload_time() const {
2197  return report_unload_time_.value();
2198  }
2199 
2200  void set_implicit_cache_ttl_ms(int64 x) {
2201  set_option(x, &implicit_cache_ttl_ms_);
2202  }
2203  int64 implicit_cache_ttl_ms() const {
2204  return implicit_cache_ttl_ms_.value();
2205  }
2206 
2207  void set_load_from_file_cache_ttl_ms(int64 x) {
2208  set_option(x, &load_from_file_cache_ttl_ms_);
2209  }
2210  int64 load_from_file_cache_ttl_ms() const {
2211  return load_from_file_cache_ttl_ms_.value();
2212  }
2213  bool load_from_file_cache_ttl_ms_was_set() const {
2214  return load_from_file_cache_ttl_ms_.was_set();
2215  }
2216 
2217  void set_x_header_value(const StringPiece& p) {
2218  set_option(p.as_string(), &x_header_value_);
2219  }
2220  const GoogleString& x_header_value() const {
2221  return x_header_value_.value();
2222  }
2223 
2224  void set_distributed_rewrite_key(const StringPiece& p) {
2225  set_option(p.as_string(), &distributed_rewrite_key_);
2226  }
2227  const GoogleString& distributed_rewrite_key() const {
2228  return distributed_rewrite_key_.value();
2229  }
2230 
2231  void set_distribute_fetches(bool x) {
2232  set_option(x, &distribute_fetches_);
2233  }
2234  bool distribute_fetches() const {
2235  return distribute_fetches_.value();
2236  }
2237 
2238  void set_distributed_rewrite_servers(const StringPiece& p) {
2239  set_option(p.as_string(), &distributed_rewrite_servers_);
2240  }
2241  const GoogleString& distributed_rewrite_servers() const {
2242  return distributed_rewrite_servers_.value();
2243  }
2244 
2245  void set_distributed_rewrite_timeout_ms(const int64 x) {
2246  set_option(x, &distributed_rewrite_timeout_ms_);
2247  }
2248  int64 distributed_rewrite_timeout_ms() const {
2249  return distributed_rewrite_timeout_ms_.value();
2250  }
2251 
2252  void set_avoid_renaming_introspective_javascript(bool x) {
2253  set_option(x, &avoid_renaming_introspective_javascript_);
2254  }
2255  bool avoid_renaming_introspective_javascript() const {
2256  return avoid_renaming_introspective_javascript_.value();
2257  }
2258 
2259  int64 blink_max_html_size_rewritable() const {
2260  return blink_max_html_size_rewritable_.value();
2261  }
2262  void set_blink_max_html_size_rewritable(int64 x) {
2263  set_option(x, &blink_max_html_size_rewritable_);
2264  }
2265 
2266  void set_critical_line_config(const StringPiece& p) {
2267  set_option(GoogleString(p.data(), p.size()), &critical_line_config_);
2268  }
2269  const GoogleString& critical_line_config() const {
2270  return critical_line_config_.value();
2271  }
2272 
2273  void set_forbid_all_disabled_filters(bool x) {
2274  set_option(x, &forbid_all_disabled_filters_);
2275  }
2276  bool forbid_all_disabled_filters() const {
2277  return forbid_all_disabled_filters_.value();
2278  }
2279 
2280  bool reject_blacklisted() const { return reject_blacklisted_.value(); }
2281  void set_reject_blacklisted(bool x) {
2282  set_option(x, &reject_blacklisted_);
2283  }
2284 
2285  HttpStatus::Code reject_blacklisted_status_code() const {
2286  return static_cast<HttpStatus::Code>(
2287  reject_blacklisted_status_code_.value());
2288  }
2289  void set_reject_blacklisted_status_code(HttpStatus::Code x) {
2290  set_option(static_cast<int>(x), &reject_blacklisted_status_code_);
2291  }
2292 
2293  bool support_noscript_enabled() const {
2294  return support_noscript_enabled_.value();
2295  }
2296  void set_support_noscript_enabled(bool x) {
2297  set_option(x, &support_noscript_enabled_);
2298  }
2299 
2300  bool enable_extended_instrumentation() const {
2301  return enable_extended_instrumentation_.value();
2302  }
2303  void set_enable_extended_instrumentation(bool x) {
2304  set_option(x, &enable_extended_instrumentation_);
2305  }
2306 
2307  bool use_experimental_js_minifier() const {
2308  return use_experimental_js_minifier_.value();
2309  }
2310  void set_use_experimental_js_minifier(bool x) {
2311  set_option(x, &use_experimental_js_minifier_);
2312  }
2313 
2314  void set_max_combined_css_bytes(int64 x) {
2315  set_option(x, &max_combined_css_bytes_);
2316  }
2317  int64 max_combined_css_bytes() const {
2318  return max_combined_css_bytes_.value();
2319  }
2320 
2321  void set_max_combined_js_bytes(int64 x) {
2322  set_option(x, &max_combined_js_bytes_);
2323  }
2324  int64 max_combined_js_bytes() const {
2325  return max_combined_js_bytes_.value();
2326  }
2327 
2328  void set_pre_connect_url(const StringPiece& p) {
2329  set_option(GoogleString(p.data(), p.size()), &pre_connect_url_);
2330  }
2331  const GoogleString& pre_connect_url() const {
2332  return pre_connect_url_.value();
2333  }
2334  void set_property_cache_http_status_stability_threshold(int x) {
2335  set_option(x, &property_cache_http_status_stability_threshold_);
2336  }
2337  int property_cache_http_status_stability_threshold() const {
2338  return property_cache_http_status_stability_threshold_.value();
2339  }
2340 
2341  void set_max_rewrite_info_log_size(int x) {
2342  set_option(x, &max_rewrite_info_log_size_);
2343  }
2344  int max_rewrite_info_log_size() const {
2345  return max_rewrite_info_log_size_.value();
2346  }
2347 
2348  void set_enable_aggressive_rewriters_for_mobile(bool x) {
2349  set_option(x, &enable_aggressive_rewriters_for_mobile_);
2350  }
2351  bool enable_aggressive_rewriters_for_mobile() const {
2352  return enable_aggressive_rewriters_for_mobile_.value();
2353  }
2354 
2355  void set_allow_logging_urls_in_log_record(bool x) {
2356  set_option(x, &allow_logging_urls_in_log_record_);
2357  }
2358  bool allow_logging_urls_in_log_record() const {
2359  return allow_logging_urls_in_log_record_.value();
2360  }
2361 
2362  void set_allow_options_to_be_set_by_cookies(bool x) {
2363  set_option(x, &allow_options_to_be_set_by_cookies_);
2364  }
2365  bool allow_options_to_be_set_by_cookies() const {
2366  return allow_options_to_be_set_by_cookies_.value();
2367  }
2368 
2369  void set_non_cacheables_for_cache_partial_html(const StringPiece& p) {
2370  set_option(p.as_string(), &non_cacheables_for_cache_partial_html_);
2371  }
2372  const GoogleString& non_cacheables_for_cache_partial_html() const {
2373  return non_cacheables_for_cache_partial_html_.value();
2374  }
2375 
2376  void set_no_transform_optimized_images(bool x) {
2377  set_option(x, &no_transform_optimized_images_);
2378  }
2379  bool no_transform_optimized_images() const {
2380  return no_transform_optimized_images_.value();
2381  }
2382 
2383  void set_access_control_allow_origins(const StringPiece& p) {
2384  set_option(p.as_string(), &access_control_allow_origins_);
2385  }
2386  const GoogleString& access_control_allow_origins() const {
2387  return access_control_allow_origins_.value();
2388  }
2389 
2390  void set_hide_referer_using_meta(bool x) {
2391  set_option(x, &hide_referer_using_meta_);
2392  }
2393  bool hide_referer_using_meta() const {
2394  return hide_referer_using_meta_.value();
2395  }
2396 
2397  void set_max_low_res_image_size_bytes(int64 x) {
2398  set_option(x, &max_low_res_image_size_bytes_);
2399  }
2400  int64 max_low_res_image_size_bytes() const {
2401  return max_low_res_image_size_bytes_.value();
2402  }
2403 
2404  void set_max_low_res_to_full_res_image_size_percentage(int x) {
2405  set_option(x, &max_low_res_to_full_res_image_size_percentage_);
2406  }
2407  int max_low_res_to_full_res_image_size_percentage() const {
2408  return max_low_res_to_full_res_image_size_percentage_.value();
2409  }
2410 
2411  void set_serve_rewritten_webp_urls_to_any_agent(bool x) {
2412  set_option(x, &serve_rewritten_webp_urls_to_any_agent_);
2413  }
2414  bool serve_rewritten_webp_urls_to_any_agent() const {
2415  return serve_rewritten_webp_urls_to_any_agent_.value();
2416  }
2417 
2418  void set_cache_fragment(const StringPiece& p) {
2419  set_option(p.as_string(), &cache_fragment_);
2420  }
2421  const GoogleString& cache_fragment() const {
2422  return cache_fragment_.value();
2423  }
2424 
2425  void set_sticky_query_parameters(StringPiece p) {
2426  set_option(p.as_string(), &sticky_query_parameters_);
2427  }
2428  const GoogleString& sticky_query_parameters() const {
2429  return sticky_query_parameters_.value();
2430  }
2431 
2432  void set_option_cookies_duration_ms(int64 x) {
2433  set_option(x, &option_cookies_duration_ms_);
2434  }
2435  int64 option_cookies_duration_ms() const {
2436  return option_cookies_duration_ms_.value();
2437  }
2438 
2439  bool mob_layout() const { return mob_layout_.value(); }
2440  bool mob_cxx_layout() const { return mob_cxx_layout_.value(); }
2441  void set_mob_cxx_layout(bool x) { set_option(x, &mob_cxx_layout_); }
2442  bool mob_logo() const { return mob_logo_.value(); }
2443  bool mob_nav() const { return mob_nav_.value(); }
2444 
2445 
2461  virtual void Merge(const RewriteOptions& src);
2462 
2465  void Allow(const StringPiece& wildcard_pattern) {
2466  Modify();
2467  allow_resources_.MakeWriteable()->Allow(wildcard_pattern);
2468  }
2469 
2472  void Disallow(const StringPiece& wildcard_pattern) {
2473  Modify();
2474  allow_resources_.MakeWriteable()->Disallow(wildcard_pattern);
2475  }
2476 
2478  void AllowWhenInlining(const StringPiece& wildcard_pattern) {
2479  Modify();
2480  allow_when_inlining_resources_.MakeWriteable()->Allow(wildcard_pattern);
2481  }
2482 
2486  void AllowOnlyWhenInlining(const StringPiece& wildcard_pattern) {
2487  Disallow(wildcard_pattern);
2488  AllowWhenInlining(wildcard_pattern);
2489  }
2490 
2492  void DisallowWhenInlining(const StringPiece& wildcard_pattern) {
2493  Modify();
2494  allow_when_inlining_resources_.MakeWriteable()->Disallow(wildcard_pattern);
2495  }
2496 
2500  virtual void DisallowTroublesomeResources();
2501 
2506  virtual void DisallowResourcesForProxy();
2507 
2528  const DomainLawyer* domain_lawyer() const { return domain_lawyer_.get(); }
2529  DomainLawyer* WriteableDomainLawyer();
2530 
2531  FileLoadPolicy* file_load_policy() { return &file_load_policy_; }
2532  const FileLoadPolicy* file_load_policy() const { return &file_load_policy_; }
2533 
2536  bool IsAllowed(const StringPiece& url) const {
2537  return allow_resources_->Match(url, true );
2538  }
2539 
2547  bool IsAllowedWhenInlining(const StringPiece& url) const {
2548  return allow_when_inlining_resources_->Match(
2549  url, false );
2550  }
2551 
2553  void RetainComment(const StringPiece& comment) {
2554  Modify();
2555  retain_comments_.MakeWriteable()->Allow(comment);
2556  }
2557 
2561  bool IsRetainedComment(const StringPiece& comment) const {
2562  return retain_comments_->Match(comment, false);
2563  }
2564 
2566  void DisableLazyloadForClassName(const StringPiece& class_name) {
2567  Modify();
2568  lazyload_enabled_classes_.MakeWriteable()->Disallow(class_name);
2569  }
2570 
2572  bool IsLazyloadEnabledForClassName(const StringPiece& class_name) const {
2573  return lazyload_enabled_classes_->Match(class_name, true);
2574  }
2575 
2576  void set_override_caching_ttl_ms(int64 x) {
2577  set_option(x, &override_caching_ttl_ms_);
2578  }
2579  int64 override_caching_ttl_ms() const {
2580  return override_caching_ttl_ms_.value();
2581  }
2582 
2585  void AddOverrideCacheTtl(const StringPiece& wildcard) {
2586  Modify();
2587  override_caching_wildcard_.MakeWriteable()->Allow(wildcard);
2588  }
2589 
2591  bool IsCacheTtlOverridden(const StringPiece& url) const {
2592  return override_caching_wildcard_->Match(url, false);
2593  }
2594 
2595  void AddRejectedUrlWildcard(const GoogleString& wildcard) {
2596  AddRejectedHeaderWildcard(kRejectedRequestUrlKeyName, wildcard);
2597  }
2598 
2599  void AddRejectedHeaderWildcard(const StringPiece& header_name,
2600  const GoogleString& wildcard) {
2601  Modify();
2602  std::pair<FastWildcardGroupMap::iterator, bool> insert_result =
2603  rejected_request_map_.insert(std::make_pair(
2604  header_name, static_cast<FastWildcardGroup*>(NULL)));
2605 
2606  if (insert_result.second) {
2607  insert_result.first->second = new FastWildcardGroup;
2608  }
2609  insert_result.first->second->Allow(wildcard);
2610  }
2611 
2612  void set_min_cache_ttl_ms(int64 x) {
2613  set_option(x, &min_cache_ttl_ms_);
2614  }
2615  int64 min_cache_ttl_ms() const {
2616  return min_cache_ttl_ms_.value();
2617  }
2618 
2621  bool IsRequestDeclined(const GoogleString& url,
2622  const RequestHeaders* request_headers) const;
2623 
2627  virtual RewriteOptions* Clone() const;
2628 
2630  virtual RewriteOptions* NewOptions() const;
2631 
2637  void ComputeSignature() LOCKS_EXCLUDED(cache_purge_mutex_.get());
2638  void ComputeSignatureLockHeld() SHARED_LOCKS_REQUIRED(cache_purge_mutex_);
2639 
2644  void Freeze();
2645 
2656 
2657  bool frozen() const { return frozen_; }
2658 
2663  bool frozen = frozen_;
2665  return frozen;
2666  }
2667 
2669  const GoogleString& signature() const {
2677  ThreadSystem::ScopedReader lock(cache_purge_mutex_.get());
2678  DCHECK(frozen_);
2679  DCHECK(!signature_.empty());
2680  return signature_;
2681  }
2682 
2683  virtual GoogleString OptionsToString() const;
2684  GoogleString FilterSetToString(const FilterSet& filter_set) const;
2685  GoogleString EnabledFiltersToString() const;
2688  GoogleString SafeEnabledOptionsToString() const;
2689 
2692  virtual GoogleString ToExperimentString() const;
2693 
2697  virtual GoogleString ToExperimentDebugString() const;
2698 
2701  static Filter LookupFilterById(const StringPiece& filter_id);
2702 
2704  static Filter LookupFilter(const StringPiece& filter_name);
2705 
2708  static const PropertyBase* LookupOptionById(StringPiece option_id);
2709  static const PropertyBase* LookupOptionByName(StringPiece option_name);
2710 
2713  static const StringPiece LookupOptionNameById(StringPiece option_id);
2714 
2716  static bool IsValidOptionName(StringPiece name);
2717 
2721  return all_options_;
2722  }
2723 
2727  bool IsEqual(const RewriteOptions& that) const;
2728 
2730  const Hasher* hasher() const { return &hasher_; }
2731 
2732  const SHA1Signature* sha1signature() const { return &sha1signature_; }
2733 
2734  ThreadSystem* thread_system() const { return thread_system_; }
2735 
2739  HttpOptions ComputeHttpOptions() const;
2740 
2741  protected:
2751  template<class T> class OptionTemplateBase : public OptionBase {
2752  public:
2753  typedef T ValueType;
2754 
2755  OptionTemplateBase() : was_set_(false), property_(NULL) {}
2756 
2757  virtual bool was_set() const { return was_set_; }
2758 
2759  void set(const T& val) {
2760  was_set_ = true;
2761  value_ = val;
2762  }
2763 
2764  void set_default(const T& val) {
2765  if (!was_set_) {
2766  value_ = val;
2767  }
2768  }
2769 
2770  const T& value() const { return value_; }
2771  T& mutable_value() { was_set_ = true; return value_; }
2772 
2778  virtual void Merge(const OptionBase* src) {
2779  DCHECK(option_name() == src->option_name());
2780  MergeHelper(static_cast<const OptionTemplateBase*>(src));
2781  }
2782 
2783  void MergeHelper(const OptionTemplateBase* src) {
2786  if (src->was_set_ || !was_set_) {
2787  value_ = src->value_;
2788  was_set_ = src->was_set_;
2789  }
2790  }
2791 
2793  void set_property(const Property<T>* property) {
2794  property_ = property;
2795 
2800  value_ = property->default_value();
2801  }
2802  virtual const PropertyBase* property() const { return property_; }
2803 
2812  void set_global_default(const T& val) {
2813  Property<T>* property = const_cast<Property<T>*>(property_);
2814  property->set_default(val);
2815  }
2816 
2826  Property<T>* property = const_cast<Property<T>*>(property_);
2827  property->set_do_not_use_for_signature_computation(true);
2828  }
2829 
2830  private:
2831  bool was_set_;
2832  T value_;
2833  const Property<T>* property_;
2834 
2835  DISALLOW_COPY_AND_ASSIGN(OptionTemplateBase);
2836  };
2837 
2842  template<class T> class Option : public OptionTemplateBase<T> {
2843  public:
2844  Option() {}
2845 
2847  virtual bool SetFromString(StringPiece value_string,
2848  GoogleString* error_detail) {
2849  T value;
2850  bool success = RewriteOptions::ParseFromString(value_string, &value);
2851  if (success) {
2852  this->set(value);
2853  }
2854  return success;
2855  }
2856 
2857  virtual GoogleString Signature(const Hasher* hasher) const {
2858  return RewriteOptions::OptionSignature(this->value(), hasher);
2859  }
2860 
2861  virtual GoogleString ToString() const {
2862  return RewriteOptions::ToString(this->value());
2863  }
2864 
2865  private:
2866  DISALLOW_COPY_AND_ASSIGN(Option);
2867  };
2868 
2869  protected:
2871  template<class RewriteOptionsSubclass, class OptionClass>
2872  static void AddProperty(
2873  typename OptionClass::ValueType default_value,
2874  OptionClass RewriteOptionsSubclass::*offset,
2875  const char* id,
2876  StringPiece option_name,
2877  OptionScope scope,
2878  const char* help_text,
2879  bool safe_to_print,
2880  Properties* properties) {
2881  PropertyBase* property =
2882  new PropertyLeaf<RewriteOptionsSubclass, OptionClass>(
2883  default_value, offset, id, option_name);
2884  property->set_scope(scope);
2885  property->set_help_text(help_text);
2886  property->set_safe_to_print(safe_to_print);
2887  properties->push_back(property);
2888  }
2889 
2903  static void MergeSubclassProperties(Properties* properties);
2904 
2910  void set_option_at(int index, OptionBase* option) {
2911  all_options_[index] = option;
2912  }
2913 
2917  template<class T>
2918  void set_option(const T& new_value, OptionTemplateBase<T>* option) {
2919  option->set(new_value);
2920  Modify();
2921  }
2922 
2924  void Modify();
2925 
2933  void set_default_x_header_value(const StringPiece& x_header_value) {
2934  x_header_value_.set_global_default(x_header_value.as_string());
2935  }
2936 
2940  bool SetupExperimentRewriters();
2941 
2943  virtual void SetRequiredExperimentFilters();
2944 
2948  bool InsertExperimentSpecInVector(ExperimentSpec* spec);
2949 
2952 
2955 
2956  private:
2958  class CacheFragmentOption : public Option<GoogleString> {
2959  public:
2960  virtual bool SetFromString(StringPiece value_string,
2961  GoogleString* error_detail);
2962  };
2963 
2964  struct OptionIdCompare;
2965 
2970  enum MergeOverride { kNoAction, kDisablePreserve, kDisableFilter };
2971 
2974  class PropertyBase {
2975  public:
2976  PropertyBase(const char* id, StringPiece option_name)
2977  : id_(id),
2978  help_text_(NULL),
2979  option_name_(option_name),
2980  scope_(kDirectoryScope),
2981  do_not_use_for_signature_computation_(false),
2982  index_(-1) {
2983  }
2984  virtual ~PropertyBase();
2985 
2988  virtual void InitializeOption(RewriteOptions* options) const = 0;
2989 
2990  void set_do_not_use_for_signature_computation(bool x) {
2991  do_not_use_for_signature_computation_ = x;
2992  }
2993  bool is_used_for_signature_computation() const {
2994  return !do_not_use_for_signature_computation_;
2995  }
2996 
2997  void set_scope(OptionScope x) { scope_ = x; }
2998  OptionScope scope() const { return scope_; }
2999 
3000  void set_help_text(const char* x) { help_text_ = x; }
3001  const char* help_text() const { return help_text_; }
3002 
3003  void set_index(int index) { index_ = index; }
3004  const char* id() const { return id_; }
3005  StringPiece option_name() const { return option_name_; }
3006  int index() const { return index_; }
3007 
3008  bool safe_to_print() const { return safe_to_print_; }
3009  void set_safe_to_print(bool safe_to_print) {
3010  safe_to_print_ = safe_to_print;
3011  }
3012 
3013  private:
3014  const char* id_;
3015  const char* help_text_;
3016  StringPiece option_name_;
3017  OptionScope scope_;
3018  bool do_not_use_for_signature_computation_;
3019  bool safe_to_print_;
3020  int index_;
3021 
3022  DISALLOW_COPY_AND_ASSIGN(PropertyBase);
3023  };
3024 
3028  template<class ValueType>
3029  class Property : public PropertyBase {
3030  public:
3035  Property(ValueType default_value,
3036  const char* id,
3037  StringPiece option_name)
3038  : PropertyBase(id, option_name),
3039  default_value_(default_value) {
3040  }
3041 
3042  void set_default(ValueType value) { default_value_ = value; }
3043  const ValueType& default_value() const { return default_value_; }
3044 
3045  private:
3046  ValueType default_value_;
3047 
3048  DISALLOW_COPY_AND_ASSIGN(Property);
3049  };
3050 
3065  template<class RewriteOptionsSubclass, class OptionClass>
3066  class PropertyLeaf : public Property<typename OptionClass::ValueType> {
3067  public:
3071  typedef OptionClass RewriteOptionsSubclass::*OptionOffset;
3072  typedef typename OptionClass::ValueType ValueType;
3073 
3074  PropertyLeaf(ValueType default_value,
3075  OptionOffset offset,
3076  const char* id,
3077  StringPiece option_name)
3078  : Property<ValueType>(default_value, id, option_name),
3079  offset_(offset) {
3080  }
3081 
3082  virtual void InitializeOption(RewriteOptions* options) const {
3083  RewriteOptionsSubclass* options_subclass =
3084  static_cast<RewriteOptionsSubclass*>(options);
3085  OptionClass& option = options_subclass->*offset_;
3086  option.set_property(this);
3087  DCHECK_NE(-1, this->index()) << "Call Property::set_index first.";
3088  options->set_option_at(this->index(), &option);
3089  }
3090 
3091  private:
3092  OptionOffset offset_;
3093 
3094  DISALLOW_COPY_AND_ASSIGN(PropertyLeaf);
3095  };
3096 
3097  static Properties* properties_;
3098  static Properties* all_properties_;
3099 
3100  FRIEND_TEST(RewriteOptionsTest, ExperimentMergeTest);
3101  FRIEND_TEST(RewriteOptionsTest, LookupOptionByNameTest);
3102 
3104  bool HasRejectedHeader(const StringPiece& header_name,
3105  const RequestHeaders* request_headers) const;
3106 
3107  bool IsRejectedUrl(const GoogleString& url) const {
3108  return IsRejectedRequest(kRejectedRequestUrlKeyName, url);
3109  }
3110 
3111  bool IsRejectedRequest(const StringPiece& header_name,
3112  const StringPiece& value) const {
3113  FastWildcardGroupMap::const_iterator it = rejected_request_map_.find(
3114  header_name);
3115  if (it != rejected_request_map_.end()) {
3116  return it->second->Match(value, false);
3117  }
3118  return false;
3119  }
3120 
3123  JavascriptLibraryIdentification* WriteableJavascriptLibraryIdentification();
3124 
3131  struct PrioritizeVisibleContentFamily {
3132  PrioritizeVisibleContentFamily(StringPiece url_pattern_string,
3133  int64 cache_time_ms_in,
3134  StringPiece non_cacheable_elements_in)
3135  : url_pattern(url_pattern_string),
3136  cache_time_ms(cache_time_ms_in),
3137  non_cacheable_elements(non_cacheable_elements_in.data(),
3138  non_cacheable_elements_in.size()) {}
3139 
3140  PrioritizeVisibleContentFamily* Clone() const {
3141  return new PrioritizeVisibleContentFamily(
3142  url_pattern.spec(), cache_time_ms, non_cacheable_elements);
3143  }
3144 
3145  GoogleString ComputeSignature() const {
3146  return StrCat(url_pattern.spec(), ";", Integer64ToString(cache_time_ms),
3147  ";", non_cacheable_elements);
3148  }
3149 
3150  GoogleString ToString() const {
3151  return StrCat("URL pattern: ", url_pattern.spec(), ", Cache time (ms): ",
3152  Integer64ToString(cache_time_ms), ", Non-cacheable: ",
3153  non_cacheable_elements);
3154  }
3155 
3156  Wildcard url_pattern;
3157  int64 cache_time_ms;
3158  GoogleString non_cacheable_elements;
3159  };
3160 
3163  struct UrlCacheInvalidationEntry {
3164  UrlCacheInvalidationEntry(StringPiece url_pattern_in,
3165  int64 timestamp_ms_in,
3166  bool ignores_metadata_and_pcache_in)
3167  : url_pattern(url_pattern_in),
3168  timestamp_ms(timestamp_ms_in),
3169  ignores_metadata_and_pcache(ignores_metadata_and_pcache_in) {}
3170 
3171  UrlCacheInvalidationEntry* Clone() const {
3172  return new UrlCacheInvalidationEntry(
3173  url_pattern.spec(), timestamp_ms, ignores_metadata_and_pcache);
3174  }
3175 
3176  GoogleString ComputeSignature() const {
3177  if (ignores_metadata_and_pcache) {
3178  return "";
3179  }
3180  return StrCat(url_pattern.spec(), "@", Integer64ToString(timestamp_ms));
3181  }
3182 
3183  GoogleString ToString() const {
3184  return StrCat(
3185  url_pattern.spec(), ", ",
3186  (ignores_metadata_and_pcache ? "STRICT" : "REFERENCE"), " @ ",
3187  Integer64ToString(timestamp_ms));
3188  }
3189 
3190  Wildcard url_pattern;
3191  int64 timestamp_ms;
3192  bool ignores_metadata_and_pcache;
3193  };
3194 
3195  typedef std::vector<UrlCacheInvalidationEntry*>
3196  UrlCacheInvalidationEntryVector;
3197  typedef dense_hash_map<GoogleString, int64> UrlCacheInvalidationMap;
3198 
3202  typedef rde::hash_map<StringPiece, const PropertyBase*,
3203  CaseFoldStringPieceHash, 6,
3204  CaseFoldStringPieceEqual> PropertyNameMap;
3205 
3218  template<class OptionClass>
3219  static void AddRequestProperty(typename OptionClass::ValueType default_value,
3220  OptionClass RewriteOptions::*offset,
3221  const char* id, bool safe_to_print) {
3222  AddProperty(default_value, offset, id, kNullOption, kProcessScope,
3223  NULL, safe_to_print, properties_);
3224  }
3225 
3228  template<class OptionClass>
3229  static void AddBaseProperty(typename OptionClass::ValueType default_value,
3230  OptionClass RewriteOptions::*offset,
3231  const char* id,
3232  StringPiece option_name,
3233  OptionScope scope,
3234  const char* help,
3235  bool safe_to_print) {
3236  AddProperty(default_value, offset, id, option_name, scope, help,
3237  safe_to_print, properties_);
3238  }
3239 
3240  static void AddProperties();
3241  bool AddCommaSeparatedListToFilterSetState(
3242  const StringPiece& filters, FilterSet* set, MessageHandler* handler);
3243  static bool AddCommaSeparatedListToFilterSet(
3244  const StringPiece& filters, FilterSet* set, MessageHandler* handler);
3246  static void InitFilterIdToEnumArray();
3247  static void InitOptionIdToPropertyArray();
3248  static void InitOptionNameToPropertyArray();
3249 
3253  OptionSettingResult FormatSetOptionMessage(
3254  OptionSettingResult result, StringPiece name, StringPiece value,
3255  StringPiece error_detail, GoogleString* msg);
3256 
3259  OptionSettingResult SetOptionFromNameInternal(
3260  StringPiece name, StringPiece value, bool from_query,
3261  GoogleString* error_detail);
3262 
3265  static GoogleString OptionSignature(bool x, const Hasher* hasher) {
3266  return x ? "T" : "F";
3267  }
3268  static GoogleString OptionSignature(int x, const Hasher* hasher) {
3269  return IntegerToString(x);
3270  }
3271  static GoogleString OptionSignature(int64 x, const Hasher* hasher) {
3272  return Integer64ToString(x);
3273  }
3274  static GoogleString OptionSignature(const GoogleString& x,
3275  const Hasher* hasher);
3276  static GoogleString OptionSignature(RewriteLevel x,
3277  const Hasher* hasher);
3278  static GoogleString OptionSignature(ResourceCategorySet x,
3279  const Hasher* hasher);
3280  static GoogleString OptionSignature(const BeaconUrl& beacon_url,
3281  const Hasher* hasher);
3282  static GoogleString OptionSignature(
3283  const protobuf::MessageLite& proto,
3284  const Hasher* hasher);
3285 
3288  static GoogleString ToString(bool x) {
3289  return x ? "True" : "False";
3290  }
3291  static GoogleString ToString(int x) {
3292  return IntegerToString(x);
3293  }
3294  static GoogleString ToString(int64 x) {
3295  return Integer64ToString(x);
3296  }
3297  static GoogleString ToString(const GoogleString& x) {
3298  return x;
3299  }
3300  static GoogleString ToString(RewriteLevel x);
3301  static GoogleString ToString(const ResourceCategorySet &x);
3302  static GoogleString ToString(const BeaconUrl& beacon_url);
3303  static GoogleString ToString(const protobuf::MessageLite& proto);
3304 
3307  static bool PropertyLessThanByOptionName(PropertyBase* p1, PropertyBase* p2) {
3308  return StringCaseCompare(p1->option_name(), p2->option_name()) < 0;
3309  }
3310 
3312  static bool OptionNameLessThanArg(OptionBase* option, StringPiece arg) {
3313  return StringCaseCompare(option->option_name(), arg) < 0;
3314  }
3315 
3317  static bool CompareUrlCacheInvalidationEntry(UrlCacheInvalidationEntry* e1,
3318  UrlCacheInvalidationEntry* e2) {
3319  return e1->timestamp_ms < e2->timestamp_ms;
3320  }
3321 
3323  static bool FilterEnumToIdAndNameEntryLessThanById(
3324  const FilterEnumToIdAndNameEntry* e1,
3325  const FilterEnumToIdAndNameEntry* e2) {
3326  return strcmp(e1->filter_id, e2->filter_id) < 0;
3327  }
3328 
3331  static StringPiece GetEffectiveOptionName(StringPiece name);
3332 
3335  bool CheckBandwidthOption(const Option<bool>& option) const {
3336  if (option.was_set() || (level() != kOptimizeForBandwidth)) {
3337  return option.value();
3338  }
3339  return true;
3340  }
3341 
3348  MergeOverride ComputeMergeOverride(
3349  Filter filter,
3350  const Option<bool>& src_preserve_option,
3351  const Option<bool>& preserve_option,
3352  const RewriteOptions& src);
3353 
3355  void ApplyMergeOverride(
3356  MergeOverride merge_override,
3357  Filter filter,
3358  Option<bool>* preserve_option);
3359 
3360  bool modified_;
3361  bool frozen_;
3362  FilterSet enabled_filters_;
3363  FilterSet disabled_filters_;
3364  FilterSet forbidden_filters_;
3365 
3368  FilterIdSet distributable_filters_;
3369 
3375  Option<RewriteLevel> level_;
3376 
3379  UrlCacheInvalidationEntryVector url_cache_invalidation_entries_;
3380 
3387  CopyOnWrite<PurgeSet> purge_set_ GUARDED_BY(cache_purge_mutex_);
3388 
3389  scoped_ptr<ThreadSystem::RWLock> cache_purge_mutex_;
3390  Option<int64> css_flatten_max_bytes_;
3391  Option<bool> cache_small_images_unrewritten_;
3392  Option<bool> no_transform_optimized_images_;
3393 
3395  Option<int64> image_resolution_limit_bytes_;
3396  Option<int64> css_image_inline_max_bytes_;
3397  Option<int64> css_inline_max_bytes_;
3398  Option<int64> css_outline_min_bytes_;
3399 
3401  Option<bool> css_preserve_urls_;
3402  Option<bool> js_preserve_urls_;
3403  Option<bool> image_preserve_urls_;
3404 
3405  Option<int64> image_inline_max_bytes_;
3406  Option<int64> js_inline_max_bytes_;
3407  Option<int64> js_outline_min_bytes_;
3408  Option<int64> progressive_jpeg_min_bytes_;
3410  Option<int64> max_html_cache_time_ms_;
3413  Option<int64> max_html_parse_bytes_;
3415  Option<int64> max_image_bytes_for_webp_in_css_;
3417  Option<int64> min_resource_cache_time_to_rewrite_ms_;
3418  Option<int64> idle_flush_time_ms_;
3419  Option<int64> flush_buffer_limit_bytes_;
3420 
3424  Option<int64> blocking_fetch_timeout_ms_;
3425 
3428  Option<int64> image_recompress_quality_;
3429 
3431  Option<int64> image_jpeg_recompress_quality_;
3432  Option<int64> image_jpeg_recompress_quality_for_small_screens_;
3433  Option<int64> image_jpeg_num_progressive_scans_;
3434  Option<int64> image_jpeg_num_progressive_scans_for_small_screens_;
3435 
3437  Option<int> image_limit_optimized_percent_;
3438  Option<int> image_limit_resize_area_percent_;
3439  Option<int> image_limit_rendered_area_percent_;
3440 
3442  Option<int64> image_webp_recompress_quality_;
3443  Option<int64> image_webp_recompress_quality_for_small_screens_;
3444  Option<int64> image_webp_timeout_ms_;
3445 
3446  Option<int> image_max_rewrites_at_once_;
3447  Option<int> max_url_segment_size_;
3448  Option<int> max_url_size_;
3449  Option<int> rewrite_deadline_ms_;
3453  Option<int> domain_shard_count_;
3454 
3455  Option<EnabledEnum> enabled_;
3456 
3457  Option<bool> distributable_;
3458 
3461  Option<bool> add_options_to_urls_;
3462 
3468  Option<bool> publicly_cache_mismatched_hashes_experimental_;
3469 
3471  Option<bool> in_place_rewriting_enabled_;
3473  Option<bool> in_place_wait_for_optimized_;
3476  Option<int> in_place_rewrite_deadline_ms_;
3479  Option<bool> in_place_preemptive_rewrite_css_;
3481  Option<bool> in_place_preemptive_rewrite_css_images_;
3484  Option<bool> in_place_preemptive_rewrite_images_;
3487  Option<bool> in_place_preemptive_rewrite_javascript_;
3493  Option<bool> private_not_vary_for_ie_;
3494  Option<bool> combine_across_paths_;
3495  Option<bool> log_background_rewrites_;
3496  Option<bool> log_rewrite_timing_;
3497  Option<bool> log_url_indices_;
3498  Option<bool> lowercase_html_names_;
3499  Option<bool> always_rewrite_css_;
3500  Option<bool> respect_vary_;
3501  Option<bool> respect_x_forwarded_proto_;
3502  Option<bool> flush_html_;
3506  Option<bool> serve_split_html_in_two_chunks_;
3509  Option<bool> serve_stale_if_fetch_error_;
3511  Option<bool> serve_ghost_click_buster_with_split_html_;
3513  Option<bool> serve_xhr_access_control_headers_;
3516  Option<bool> proactively_freshen_user_facing_request_;
3519  Option<int64> serve_stale_while_revalidate_threshold_sec_;
3521  Option<bool> enable_flush_early_critical_css_;
3523  Option<bool> use_selectors_for_critical_css_;
3528  Option<bool> default_cache_html_;
3533  Option<bool> modify_caching_headers_;
3537  Option<bool> lazyload_images_after_onload_;
3540  Option<GoogleString> lazyload_images_blank_url_;
3543  Option<bool> use_blank_image_for_inline_preview_;
3547  Option<bool> inline_only_critical_images_;
3550  Option<bool> critical_images_beacon_enabled_;
3553  Option<bool> client_domain_rewrite_;
3556  Option<bool> domain_rewrite_hyperlinks_;
3559  Option<bool> running_experiment_;
3562  Option<int> experiment_ga_slot_;
3565  Option<int> enroll_experiment_id_;
3566 
3569  Option<bool> increase_speed_tracking_;
3570 
3574  Option<bool> report_unload_time_;
3575 
3576  Option<bool> serve_rewritten_webp_urls_to_any_agent_;
3577 
3579  Option<bool> flush_more_resources_early_if_time_permits_;
3580 
3582  Option<bool> flush_more_resources_in_ie_and_firefox_;
3583 
3586  Option<int> max_prefetch_js_elements_;
3587 
3589  Option<bool> enable_defer_js_experimental_;
3590 
3592  Option<bool> disable_rewrite_on_no_transform_;
3593 
3595  Option<bool> disable_background_fetches_for_bots_;
3596 
3606  Option<bool> enable_cache_purge_;
3607 
3611  Option<bool> proactive_resource_freshening_;
3612 
3614  Option<bool> lazyload_highres_images_;
3615 
3618  Option<bool> avoid_renaming_introspective_javascript_;
3619 
3621  Option<bool> override_ie_document_mode_;
3622 
3624  Option<bool> test_instant_fetch_rewrite_deadline_;
3625 
3629  Option<bool> test_only_prioritize_critical_css_dont_apply_original_css_;
3630 
3636  Option<GoogleString> blocking_rewrite_key_;
3637 
3641  Option<int> beacon_reinstrument_time_sec_;
3642 
3645  Option<int> max_inlined_preview_images_index_;
3647  Option<int64> min_image_size_low_resolution_bytes_;
3649  Option<int64> max_image_size_low_resolution_bytes_;
3652  Option<int> rewrite_random_drop_percentage_;
3653 
3656  Option<bool> oblivious_pagespeed_urls_;
3657 
3659  Option<int64> finder_properties_cache_expiration_time_ms_;
3660 
3664  Option<int64> finder_properties_cache_refresh_time_ms_;
3667  Option<int64> experiment_cookie_duration_ms_;
3668 
3671  Option<int64> metadata_cache_staleness_threshold_ms_;
3672 
3674  Option<int64> metadata_input_errors_cache_ttl_ms_;
3675 
3678  Option<GoogleString> downstream_cache_purge_method_;
3679 
3681  Option<GoogleString> downstream_cache_purge_location_prefix_;
3682 
3685  Option<GoogleString> downstream_cache_rebeaconing_key_;
3686 
3692  Option<int64> downstream_cache_rewritten_percentage_threshold_;
3693 
3697  Option<int64> implicit_cache_ttl_ms_;
3698 
3703  Option<int64> load_from_file_cache_ttl_ms_;
3704 
3706  Option<int64> max_cacheable_response_content_length_;
3707 
3709  Option<int64> blink_blacklist_end_timestamp_ms_;
3711  Option<bool> persist_blink_blacklist_;
3712 
3715  Option<bool> preserve_url_relativity_;
3716 
3717  Option<GoogleString> ga_id_;
3718 
3719  Option<int64> blink_max_html_size_rewritable_;
3722  Option<int64> blink_html_change_detection_time_ms_;
3724  Option<bool> enable_blink_debug_dashboard_;
3726  Option<bool> enable_blink_html_change_detection_;
3728  Option<bool> enable_blink_html_change_detection_logging_;
3730  Option<bool> use_smart_diff_in_blink_;
3732  Option<bool> use_fallback_property_cache_values_;
3734  Option<bool> await_pcache_lookup_;
3736  Option<bool> enable_prioritizing_scripts_;
3738  Option<bool> rewrite_uncacheable_resources_;
3740  Option<GoogleString> critical_line_config_;
3743  Option<GoogleString> distributed_rewrite_key_;
3745  Option<GoogleString> distributed_rewrite_servers_;
3750  Option<bool> distribute_fetches_;
3753  Option<int64> distributed_rewrite_timeout_ms_;
3759  Option<bool> forbid_all_disabled_filters_;
3761  Option<bool> enable_aggressive_rewriters_for_mobile_;
3762 
3768  Option<bool> reject_blacklisted_;
3769  Option<int> reject_blacklisted_status_code_;
3770 
3774  Option<bool> support_noscript_enabled_;
3775 
3778  Option<bool> enable_extended_instrumentation_;
3779 
3780  Option<bool> use_experimental_js_minifier_;
3781 
3784  Option<int64> max_combined_css_bytes_;
3785 
3788  Option<int64> max_combined_js_bytes_;
3789 
3791  Option<GoogleString> pre_connect_url_;
3794  Option<int> property_cache_http_status_stability_threshold_;
3796  Option<int> max_rewrite_info_log_size_;
3797 
3802  Option<int64> override_caching_ttl_ms_;
3803  CopyOnWrite<FastWildcardGroup> override_caching_wildcard_;
3804 
3808  Option<int64> min_cache_ttl_ms_;
3809 
3811  Option<bool> allow_logging_urls_in_log_record_;
3812 
3814  Option<bool> allow_options_to_be_set_by_cookies_;
3815 
3817  Option<GoogleString> non_cacheables_for_cache_partial_html_;
3818 
3822  Option<GoogleString> access_control_allow_origins_;
3823 
3825  Option<bool> hide_referer_using_meta_;
3826 
3831  Option<int64> max_low_res_image_size_bytes_;
3832  Option<int> max_low_res_to_full_res_image_size_percentage_;
3833 
3835  Option<GoogleString> request_option_override_;
3836 
3838  Option<GoogleString> url_signing_key_;
3839 
3841  Option<bool> accept_invalid_signatures_;
3842 
3847  Option<GoogleString> sticky_query_parameters_;
3848  Option<int64> option_cookies_duration_ms_;
3849 
3852  CacheFragmentOption cache_fragment_;
3853 
3856  OptionBaseVector all_options_;
3857  size_t initialized_options_;
3858 
3861  static const FilterEnumToIdAndNameEntry* filter_id_to_enum_array_[
3862  kEndOfFilters];
3863 
3865  static PropertyNameMap* option_name_to_property_map_;
3866 
3868  static const PropertyBase** option_id_to_property_array_;
3869 
3876  bool options_uniqueness_checked_;
3877 
3878  bool need_to_store_experiment_data_;
3879  int experiment_id_;
3880  int experiment_percent_;
3881  std::vector<ExperimentSpec*> experiment_specs_;
3882 
3884  std::vector<NameValue*> custom_fetch_headers_;
3885 
3888  scoped_ptr<std::vector<ElementAttributeCategory> > url_valued_attributes_;
3889 
3890  Option<ResourceCategorySet> inline_unauthorized_resource_types_;
3891 
3892  Option<bool> mob_layout_;
3893  Option<bool> mob_cxx_layout_;
3894  Option<bool> mob_logo_;
3895  Option<bool> mob_nav_;
3896 
3897  CopyOnWrite<JavascriptLibraryIdentification>
3898  javascript_library_identification_;
3899 
3900  CopyOnWrite<DomainLawyer> domain_lawyer_;
3901  FileLoadPolicy file_load_policy_;
3902 
3903  CopyOnWrite<FastWildcardGroup> allow_resources_;
3904  CopyOnWrite<FastWildcardGroup> allow_when_inlining_resources_;
3905  CopyOnWrite<FastWildcardGroup> retain_comments_;
3906  CopyOnWrite<FastWildcardGroup> lazyload_enabled_classes_;
3907 
3910  CopyOnWrite<FastWildcardGroup> blocking_rewrite_referer_urls_;
3911 
3914  typedef std::map<StringPiece, FastWildcardGroup*> FastWildcardGroupMap;
3915  FastWildcardGroupMap rejected_request_map_;
3916 
3917  GoogleString signature_;
3918  MD5Hasher hasher_;
3919  SHA1Signature sha1signature_;
3920 
3921  ThreadSystem* thread_system_;
3922 
3935  scoped_ptr<ThreadSystem::ThreadId> last_thread_id_;
3936 
3937  DISALLOW_COPY_AND_ASSIGN(RewriteOptions);
3938 };
3939 
3940 }
3941 
3942 #endif
void set_experiment_ga_slot(int x)
x should be between 1 and 5 inclusive.
Definition: rewrite_options.h:2183
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:195
void DisallowWhenInlining(const StringPiece &wildcard_pattern)
Like Disallow(). See IsAllowedWhenInlining().
Definition: rewrite_options.h:2492
bool AdjustFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
static const int64 kDefaultMaxCombinedCssBytes
Default maximum size of the combined CSS resource.
Definition: rewrite_options.h:697
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:2872
bool ClearSignatureForTesting()
Definition: rewrite_options.h:2662
int64 idle_flush_time_ms() const
Definition: rewrite_options.h:1465
void DisableLazyloadForClassName(const StringPiece &class_name)
Adds a new class name for which lazyload should be disabled.
Definition: rewrite_options.h:2566
static bool Initialize(Properties **properties)
bool MatchesDownstreamCacheRebeaconingKey(StringPiece key) const
Definition: rewrite_options.h:1915
customized at directory level (.htaccess, <Directory>)
Definition: rewrite_options.h:487
Definition: rewrite_options.h:485
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:658
static const int64 kDefaultExperimentCookieDurationMs
Definition: rewrite_options.h:690
void set_downstream_cache_purge_location_prefix(StringPiece p)
Definition: rewrite_options.h:1892
Definition: rewrite_options.h:446
Maps a filter's enum (kAddHead) to its id ("ah") and name ("Add Head").
Definition: rewrite_options.h:870
void Allow(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2465
Definition: rewrite_options.h:550
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:2572
Definition: rewrite_options.h:203
static bool Terminate(Properties **properties_handle)
void RetainComment(const StringPiece &comment)
Adds a new comment wildcard pattern to be retained.
Definition: rewrite_options.h:2553
bool IsAllowed(const StringPiece &url) const
Definition: rewrite_options.h:2536
int max_url_segment_size() const
Definition: rewrite_options.h:1483
bool InsertExperimentSpecInVector(ExperimentSpec *spec)
bool ImageOptimizationEnabled() const
std::pair< GoogleString, GoogleString > OptionStringPair
Definition: rewrite_options.h:543
Definition: rewrite_options.h:2842
Definition: rewrite_options.h:2751
virtual void DisallowTroublesomeResources()
static const char kAcceptInvalidSignatures[]
Definition: rewrite_options.h:212
static const char kCacheFlushFilename[]
Definition: rewrite_options.h:396
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:1936
Option< BeaconUrl > beacon_url_
Protected option values so that derived class can modify.
Definition: rewrite_options.h:2951
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:107
static const int kDefaultExperimentSlot
Default Custom Variable slot in which to put Experiment information.
Definition: rewrite_options.h:704
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:1473
static bool ParseBeaconUrl(const StringPiece &in, BeaconUrl *out)
int64 cache_invalidation_timestamp() const
const DomainLawyer * domain_lawyer() const
Definition: rewrite_options.h:2528
Definition: rewrite_options.h:439
void set_cache_invalidation_timestamp_mutex(ThreadSystem::RWLock *lock)
Definition: rewrite_options.h:1427
static void MergeSubclassProperties(Properties *properties)
void set_domain_shard_count(int64 x)
Definition: rewrite_options.h:1523
int64 css_outline_min_bytes() const
Definition: rewrite_options.h:1244
void DisableFiltersRequiringScriptExecution()
Disables all filters that depend on executing custom javascript.
void set_global_default(const T &val)
Definition: rewrite_options.h:2812
bool IsUrlCacheInvalidationEntriesSorted() const
static const int64 kDefaultMetadataCacheStalenessThresholdMs
Definition: rewrite_options.h:694
virtual GoogleString ToExperimentString() const
static const int kOptionsVersion
Definition: rewrite_options.h:470
void MergeHelper(const OptionTemplateBase *src)
Definition: rewrite_options.h:2783
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:575
OptionScope
Definition: rewrite_options.h:484
void Disallow(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2472
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:684
bool RegisterLibrary(SizeInBytes bytes, StringPiece md5_hash, StringPiece canonical_url)
Represents the content type of user-defined url-valued attributes.
Definition: rewrite_options.h:799
Option< GoogleString > x_header_value_
The value we put for the X-Mod-Pagespeed header. Default is our version.
Definition: rewrite_options.h:2954
void set_option(const T &new_value, OptionTemplateBase< T > *option)
Definition: rewrite_options.h:2918
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:1496
virtual OptionSettingResult ParseAndSetOptionFromName1(StringPiece name, StringPiece arg, GoogleString *msg, MessageHandler *handler)
Definition: rewrite_options.h:811
Definition: rewrite_options.h:720
void DoNotUseForSignatureComputation()
Definition: rewrite_options.h:2825
bool IsRetainedComment(const StringPiece &comment) const
Definition: rewrite_options.h:2561
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:676
static const char kAllow[]
Options that require special handling, e.g. non-scalar values.
Definition: rewrite_options.h:368
void set_property(const Property< T > *property)
The static properties of an Option are held in a Property<T>*.
Definition: rewrite_options.h:2793
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:1040
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:2730
static const int64 kDefaultMaxCombinedJsBytes
Default maximum size of the combined js resource generated by JsCombiner.
Definition: rewrite_options.h:700
std::set< GoogleString > FilterIdSet
Convenience name for a set of rewrite filter ids.
Definition: rewrite_options.h:531
customized at server level (e.g. VirtualHost)
Definition: rewrite_options.h:488
bool SetOptionFromNameAndLog(StringPiece name, StringPiece value, MessageHandler *handler)
customized at process level only (command-line flags)
Definition: rewrite_options.h:489
static const char kLibrary[]
3-argument ones:
Definition: rewrite_options.h:392
virtual void Merge(const RewriteOptions &src)
void SetDefaultRewriteLevel(RewriteLevel level)
Definition: rewrite_options.h:934
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:672
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:2720
Filter
Definition: rewrite_options.h:106
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:200
static const int kDefaultMaxUrlSegmentSize
Definition: rewrite_options.h:666
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:2478
static const int kDefaultRewriteDeadlineMs
Default time to wait for rewrite before returning original resource.
Definition: rewrite_options.h:669
void InitializeOptions(const Properties *properties)
void AddOverrideCacheTtl(const StringPiece &wildcard)
Definition: rewrite_options.h:2585
void set_default_x_header_value(const StringPiece &x_header_value)
Definition: rewrite_options.h:2933
static const int64 kDefaultMaxImageSizeLowResolutionBytes
Definition: rewrite_options.h:682
bool IsCacheTtlOverridden(const StringPiece &url) const
Is the cache TTL overridden for the given url?
Definition: rewrite_options.h:2591
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:382
virtual bool SetFromString(StringPiece value_string, GoogleString *error_detail)
Sets value_ from value_string.
Definition: rewrite_options.h:2847
OptionSettingResult
Used for return value of SetOptionFromName.
Definition: rewrite_options.h:607
static const char kDistributableFilters[]
For experimentation.
Definition: rewrite_options.h:372
Temporary and will be removed soon.
Definition: rewrite_options.h:136
void DistributeFilter(const StringPiece &filter_id)
static const int64 kDefaultMinImageSizeLowResolutionBytes
Definition: rewrite_options.h:679
as above, but fail startup if included in vhost
Definition: rewrite_options.h:490
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:430
Definition: rewrite_options.h:198
void AllowOnlyWhenInlining(const StringPiece &wildcard_pattern)
Definition: rewrite_options.h:2486
void ForceEnableFilter(Filter filter)
ExperimentSpec(const StringPiece &spec, const RewriteOptions *options, MessageHandler *handler)
bool IsAllowedWhenInlining(const StringPiece &url) const
Definition: rewrite_options.h:2547
bool SetOptionsFromName(const OptionSet &option_set, MessageHandler *handler)
Definition: rewrite_options.h:582
const JavascriptLibraryIdentification * javascript_library_identification() const
Definition: rewrite_options.h:1048
bool ForbidFiltersByCommaSeparatedList(const StringPiece &filters, MessageHandler *handler)
Definition: rewrite_options.h:594
void UrlValuedAttribute(int index, StringPiece *element, StringPiece *attribute, semantic_type::Category *category) const
int id() const
Accessors.
Definition: rewrite_options.h:742
void Merge(const ExperimentSpec &spec)
bool AvailableExperimentId(int id)
Definition: rewrite_options.h:83
bool IsRequestDeclined(const GoogleString &url, const RequestHeaders *request_headers) const
bool IsEqual(const RewriteOptions &that) const
RewriteLevel
Definition: rewrite_options.h:577
Definition: rewrite_options.h:599
const GoogleString & signature() const
Returns the computed signature.
Definition: rewrite_options.h:2669
int size() const
Returns the number of properties.
Definition: rewrite_options.h:834
void set_option_at(int index, OptionBase *option)
Definition: rewrite_options.h:2910
bool has_cache_invalidation_timestamp_ms() const
static const int64 kDefaultFinderPropertiesCacheRefreshTimeMs
Default cache refresh value for finder properties in pcache.
Definition: rewrite_options.h:686
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:473
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:476
virtual void Merge(const OptionBase *src)
Definition: rewrite_options.h:2778
Definition: rewrite_options.h:603
static const Filter kFirstFilter
Used for enumerating over all entries in the Filter enum.
Definition: rewrite_options.h:525
void ComputeSignature() LOCKS_EXCLUDED(cache_purge_mutex_.get())
int64 MaxImageInlineMaxBytes() const
The larger of ImageInlineMaxBytes and CssImageInlineMaxBytes.