19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_DRIVER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_DRIVER_H_
26 #include "base/logging.h"
29 #include "net/instaweb/http/public/request_context.h"
31 #include "net/instaweb/rewriter/cached_result.pb.h"
37 #include "net/instaweb/rewriter/public/inline_resource_slot.h"
57 #include "pagespeed/kernel/base/thread_annotations.h"
68 #include "pagespeed/kernel/http/user_agent_matcher.h"
76 namespace net_instaweb {
78 class AbstractLogRecord;
82 class DependencyTracker;
84 class DomainRewriteFilter;
85 class FallbackPropertyPage;
88 class HtmlWriterFilter;
90 class RequestProperties;
92 class RewriteDriverPool;
95 class UrlLeftTrimFilter;
138 kInlineUnauthorizedResources,
139 kInlineOnlyAuthorizedResources
144 kIntendedForInlining,
199 static void Terminate();
211 bool MayCacheExtendImages()
const;
212 bool MayCacheExtendPdfs()
const;
213 bool MayCacheExtendScripts()
const;
215 const GoogleString& user_agent()
const {
return user_agent_; }
218 return request_properties_.get();
224 bool write_property_cache_dom_cohort()
const {
225 return write_property_cache_dom_cohort_;
227 void set_write_property_cache_dom_cohort(
bool x) {
228 write_property_cache_dom_cohort_ = x;
234 const PropertyCache* pcache,
const RewriteOptions*
options,
235 const ServerContext* server_context);
241 RequestContextPtr request_context() {
return request_context_; }
242 void set_request_context(
const RequestContextPtr& x);
251 void TraceLiteral(
const char* literal);
257 return flush_occurred_ ? NULL : response_headers_;
267 return response_headers_;
274 response_headers_ = headers;
288 return request_headers_.get();
291 UserAgentMatcher* user_agent_matcher()
const {
292 DCHECK(server_context() != NULL);
293 return server_context()->user_agent_matcher();
352 Writer* writer()
const {
return writer_; }
402 AsyncFetch* async_fetch);
411 RewriteFilter* filter,
412 AsyncFetch* async_fetch);
421 RewriteFilter** filter)
const;
429 const RewriteOptions* options_to_use,
430 const UrlNamer* url_namer,
431 ResourceNamer* name_out,
433 RewriteFilter** filter_out)
const;
449 RewriteContext::CacheLookupResultCallback* callback);
453 StringVector* decoded_urls)
const;
459 const UrlNamer* url_namer,
460 StringVector* decoded_urls)
const;
462 FileSystem* file_system() {
return file_system_; }
463 UrlAsyncFetcher* async_fetcher() {
return url_async_fetcher_; }
477 ServerContext* server_context()
const {
return server_context_; }
478 Statistics* statistics()
const;
488 controlling_pool_ = pool;
489 options_.reset(options);
501 virtual bool StartParseId(
const StringPiece&
url,
const StringPiece&
id,
526 const ResourceContext* data,
544 const
char* filter_id,
546 const ResourceContext* data,
568 const StringPiece& mapped_path, const StringPiece& unmapped_path,
569 const StringPiece&
base_url, const StringPiece& filter_id,
576 const StringPiece& filter_id,
577 const StringPiece& name,
584 const
GoogleUrl& unmapped_gurl, const StringPiece& filter_id,
591 const StringPiece& mapped_path, const StringPiece& unmapped_path,
592 const StringPiece& filter_id, const StringPiece& name,
596 filter_id, name, kind, failure_reason);
602 const StringPiece& path,
const StringPiece& filter_id,
606 kind, failure_reason);
631 bool* is_authorized);
653 bool* is_authorized);
659 const StringPiece& absolute_url);
681 bool* is_authorized_domain)
const;
695 StringPiece decoded_base()
const {
return decoded_base_url_.
Spec(); }
703 RewriteFilter*
FindFilter(
const StringPiece&
id)
const;
707 bool other_base_problem()
const {
return other_base_problem_; }
723 void set_containing_charset(
const StringPiece charset) {
724 charset.CopyToString(&containing_charset_);
731 HtmlResourceSlotPtr
GetSlot(
const ResourcePtr& resource,
733 HtmlElement::Attribute* attr);
739 InlineResourceSlotPtr
GetInlineSlot(
const ResourcePtr& resource,
740 HtmlCharactersNode* char_node);
747 const ResourcePtr& resource, HtmlElement* element,
748 HtmlElement::Attribute* attribute);
760 CommonFilter* filter, HtmlElement* element, HtmlElement::Attribute* attr);
767 LOCKS_EXCLUDED(rewrite_mutex());
768 void InitiateFetch(RewriteContext* rewrite_context);
780 void RewriteComplete(RewriteContext* rewrite_context, RenderOp permit_render);
801 LOCKS_EXCLUDED(rewrite_mutex());
802 GoogleString ToStringLockHeld(
bool show_detached_contexts)
const
803 EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
823 LOCKS_EXCLUDED(rewrite_mutex());
833 fully_rewrite_on_flush_ = x;
838 return fully_rewrite_on_flush_;
845 fast_blocking_rewrite_ = x;
848 bool fast_blocking_rewrite()
const {
849 return fast_blocking_rewrite_;
885 int rewrite_deadline_ms() {
return options()->rewrite_deadline_ms(); }
892 max_page_processing_delay_ms_ = x;
894 int max_page_processing_delay_ms() {
return max_page_processing_delay_ms_; }
906 RewriteContext* candidate);
913 const GoogleString& partition_key, RewriteContext* candidate);
918 bool flush_requested()
const {
return flush_requested_; }
946 virtual void Flush();
960 QueuedWorkerPool::Sequence* html_worker() {
return html_worker_; }
961 Sequence* rewrite_worker();
962 Scheduler::Sequence* scheduler_sequence() {
963 return scheduler_sequence_.get();
966 QueuedWorkerPool::Sequence* low_priority_rewrite_worker() {
967 return low_priority_rewrite_worker_;
982 Scheduler* scheduler() {
return scheduler_; }
997 const StringPiece& output_css_base,
998 const StringPiece& contents,
1000 MessageHandler* handler);
1010 const GoogleUrl& output_base,
1011 bool* proxy_mode)
const;
1021 AbstractPropertyPage* page,
1022 StringPiece property_name,
1023 StringPiece property_value);
1034 return fallback_property_page_;
1058 return critical_images_info_.get();
1066 return critical_selector_info_.get();
1073 critical_selector_info_.reset(info);
1081 critical_images_info_.reset(critical_images_info);
1087 return (
options()->Enabled(RewriteOptions::kFlattenCssImports) ||
1088 (!
options()->Forbidden(RewriteOptions::kFlattenCssImports) &&
1089 (
options()->Enabled(RewriteOptions::kPrioritizeCriticalCss) ||
1090 options()->Enabled(RewriteOptions::kComputeCriticalCss))));
1120 void set_is_lazyload_script_flushed(
bool x) {
1121 is_lazyload_script_flushed_ = x;
1123 bool is_lazyload_script_flushed()
const {
1124 return is_lazyload_script_flushed_; }
1132 return dependency_tracker_.get();
1145 void InsertDebugComments(
1146 const protobuf::RepeatedPtrField<GoogleString>& unescaped_messages,
1148 void InsertUnauthorizedDomainDebugComment(StringPiece
url,
1161 return dom_stats_filter_;
1183 bool Write(
const ResourceVector& inputs,
1184 const StringPiece& contents,
1186 StringPiece charset,
1189 void set_defer_instrumentation_script(
bool x) {
1190 defer_instrumentation_script_ = x;
1192 bool defer_instrumentation_script()
const {
1193 return defer_instrumentation_script_;
1200 num_initiated_rewrites_ = x;
1202 int64 num_initiated_rewrites()
const {
1204 return num_initiated_rewrites_;
1209 num_detached_rewrites_ = x;
1211 int64 num_detached_rewrites()
const {
1213 return num_detached_rewrites_;
1216 void set_pagespeed_query_params(StringPiece x) {
1217 x.CopyToString(&pagespeed_query_params_);
1219 StringPiece pagespeed_query_params()
const {
1220 return pagespeed_query_params_;
1223 void set_pagespeed_option_cookies(StringPiece x) {
1224 x.CopyToString(&pagespeed_option_cookies_);
1226 StringPiece pagespeed_option_cookies()
const {
1227 return pagespeed_option_cookies_;
1245 bool Decode(StringPiece leaf, ResourceNamer* resource_namer)
const;
1247 bool filters_added()
const {
return filters_added_; }
1248 bool has_html_writer_filter()
const {
1249 return html_writer_filter_.get() !=
nullptr;
1256 bool is_amp_document()
const {
return is_amp_; }
1258 const CspContext& content_security_policy()
const {
return csp_context_; }
1259 CspContext* mutable_content_security_policy() {
return &csp_context_; }
1260 bool IsLoadPermittedByCsp(
const GoogleUrl&
url,
InputRole role);
1267 friend class RewriteContext;
1268 friend class RewriteDriverTest;
1269 friend class RewriteTestBase;
1270 friend class ServerContextTest;
1272 typedef std::map<GoogleString, RewriteFilter*> StringFilterMap;
1278 void CheckForCompletionAsync(
WaitMode wait_mode, int64 timeout_ms,
1280 EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1285 void TryCheckForCompletion(
WaitMode wait_mode, int64 end_time_ms,
1287 EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1290 bool IsDone(
WaitMode wait_mode,
bool deadline_reached)
1291 EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1295 bool WaitForPendingAsyncEvents(
WaitMode wait_mode) {
1297 (fully_rewrite_on_flush_ && !fast_blocking_rewrite_);
1303 void FlushAsyncDone(
int num_rewrites, Function* callback);
1309 int64 ComputeCurrentFlushWindowRewriteDelayMs();
1312 void QueueFlushAsyncDone(
int num_rewrites, Function* callback);
1316 void QueueFinishParseAfterFlush(Function* user_callback);
1317 void FinishParseAfterFlush(Function* user_callback);
1319 bool RewritesComplete() const EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1323 void SetBaseUrlIfUnset(const StringPiece& new_base);
1327 void SetBaseUrlForFetch(const StringPiece&
url);
1331 void SetDecodedUrlFromBase();
1334 AbstractMutex* rewrite_mutex() const LOCK_RETURNED(scheduler_->mutex()) {
1335 return scheduler_->mutex();
1339 virtual void ParseTextInternal(
const char* content,
int size);
1342 bool ShouldSkipParsing();
1345 int SignatureLength()
const;
1347 friend class ScanFilter;
1352 void RegisterRewriteFilter(RewriteFilter* filter);
1358 void EnableRewriteFilter(
const char*
id);
1365 ResourcePtr CreateInputResourceUnchecked(
const GoogleUrl& gurl,
1366 bool is_authorized_domain);
1368 void AddPreRenderFilters();
1369 void AddPostRenderFilters();
1372 bool DecodeOutputResourceNameHelper(
const GoogleUrl& url,
1373 const RewriteOptions* options_to_use,
1374 const UrlNamer* url_namer,
1375 ResourceNamer* name_out,
1377 RewriteFilter** filter_out,
1379 StringVector* urls)
const;
1390 void WriteDomCohortIntoPropertyCache();
1393 CacheUrlAsyncFetcher* CreateCustomCacheFetcher(UrlAsyncFetcher* base_fetcher);
1401 void PossiblyPurgeCachedResponseAndReleaseDriver();
1421 bool PrepareShouldSignal() EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1422 void SignalIfRequired(
bool result_of_prepare_should_signal)
1423 EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex());
1427 void CleanupRequestThread();
1446 bool refs_before_base_;
1449 bool other_base_problem_;
1456 void PopulateRequestContext();
1458 bool filters_added_;
1459 bool externally_managed_;
1476 kRefPendingRewrites,
1481 kRefDetachedRewrites,
1490 kRefDeletingRewrites,
1493 kRefFetchUserFacing,
1496 kRefFetchBackground,
1506 kRefRenderBlockingAsyncEvents,
1511 friend class CategorizedRefcount<RewriteDriver, RefCategory>;
1514 CategorizedRefcount<RewriteDriver, RefCategory> ref_counts_;
1517 void LastRefRemoved();
1518 StringPiece RefCategoryName(RefCategory cat);
1522 void DropReference(RefCategory cat);
1526 bool release_driver_;
1531 WaitMode waiting_ GUARDED_BY(rewrite_mutex());
1534 bool waiting_deadline_reached_ GUARDED_BY(rewrite_mutex());
1540 bool fully_rewrite_on_flush_;
1544 bool fast_blocking_rewrite_;
1546 bool flush_requested_;
1547 bool flush_occurred_;
1551 bool is_lazyload_script_flushed_;
1556 bool write_property_cache_dom_cohort_;
1560 GoogleUrl base_url_;
1565 GoogleUrl decoded_base_url_;
1575 StringFilterMap resource_filter_map_;
1577 ResponseHeaders* response_headers_;
1581 scoped_ptr<const RequestHeaders> request_headers_;
1587 typedef std::vector<RewriteContext*> RewriteContextVector;
1588 RewriteContextVector rewrites_;
1592 int max_page_processing_delay_ms_;
1594 typedef std::set<RewriteContext*> RewriteContextSet;
1600 RewriteContextSet initiated_rewrites_ GUARDED_BY(rewrite_mutex());
1603 int64 num_initiated_rewrites_ GUARDED_BY(rewrite_mutex());
1612 int64 num_detached_rewrites_ GUARDED_BY(rewrite_mutex());
1621 RewriteContextSet detached_rewrites_ GUARDED_BY(rewrite_mutex());
1624 int possibly_quick_rewrites_ GUARDED_BY(rewrite_mutex());
1628 RewriteContextVector fetch_rewrites_;
1632 FileSystem* file_system_;
1633 ServerContext* server_context_;
1634 Scheduler* scheduler_;
1635 UrlAsyncFetcher* default_url_async_fetcher_;
1640 UrlAsyncFetcher* url_async_fetcher_;
1644 std::vector<UrlAsyncFetcher*> owned_url_async_fetchers_;
1646 DomStatsFilter* dom_stats_filter_;
1647 scoped_ptr<HtmlWriterFilter> html_writer_filter_;
1649 ScanFilter scan_filter_;
1650 scoped_ptr<DomainRewriteFilter> domain_rewriter_;
1651 scoped_ptr<UrlLeftTrimFilter> url_trim_filter_;
1655 typedef std::map<GoogleString, RewriteContext*> PrimaryRewriteContextMap;
1656 PrimaryRewriteContextMap primary_rewrite_context_map_;
1658 HtmlResourceSlotSet slots_;
1659 InlineResourceSlotSet inline_slots_;
1660 InlineAttributeSlotSet inline_attribute_slots_;
1661 SrcSetSlotCollectionSet srcset_collections_;
1663 scoped_ptr<RewriteOptions> options_;
1665 RewriteDriverPool* controlling_pool_;
1668 scoped_ptr<CacheUrlAsyncFetcher::AsyncOpHooks>
1669 cache_url_async_fetcher_async_op_hooks_;
1672 UrlSegmentEncoder default_encoder_;
1675 FilterList early_pre_render_filters_;
1677 FilterList pre_render_filters_;
1680 std::vector<ResourceUrlClaimant*> resource_claimants_;
1685 FilterVector filters_to_delete_;
1687 QueuedWorkerPool::Sequence* html_worker_;
1688 QueuedWorkerPool::Sequence* rewrite_worker_;
1689 QueuedWorkerPool::Sequence* low_priority_rewrite_worker_;
1690 scoped_ptr<Scheduler::Sequence> scheduler_sequence_;
1696 FallbackPropertyPage* fallback_property_page_;
1699 bool owns_property_page_;
1702 scoped_ptr<PropertyPage> origin_property_page_;
1709 scoped_ptr<CriticalImagesInfo> critical_images_info_;
1710 scoped_ptr<CriticalSelectorInfo> critical_selector_info_;
1713 bool xhtml_mimetype_computed_;
1718 int num_inline_preview_images_;
1723 DebugFilter* debug_filter_;
1725 scoped_ptr<FlushEarlyInfo> flush_early_info_;
1726 scoped_ptr<DependencyTracker> dependency_tracker_;
1728 bool can_rewrite_resources_;
1733 RequestContextPtr request_context_;
1736 int64 start_time_ms_;
1738 scoped_ptr<RequestProperties> request_properties_;
1743 static int initialized_count_;
1747 bool defer_instrumentation_script_;
1753 AtomicBool executing_rewrite_tasks_;
1756 DownstreamCachePurger downstream_cache_purger_;
1765 CspContext csp_context_;
virtual ResponseHeaders::VaryOption RespectVaryOnResources() const
class GoogleUrl
Definition: google_url.h:58
OutputResourcePtr DecodeOutputResource(const GoogleUrl &url, RewriteFilter **filter) const
Definition: rewrite_driver.h:115
static const char kDomCohort[]
Definition: rewrite_driver.h:151
void EnableBlockingRewrite(RequestHeaders *request_headers)
void RunTasksOnRequestThread()
void set_max_page_processing_delay_ms(int x)
Definition: rewrite_driver.h:891
InlineResourceSlotPtr GetInlineSlot(const ResourcePtr &resource, HtmlCharactersNode *char_node)
void PopulateResourceNamer(const StringPiece &filter_id, const StringPiece &name, ResourceNamer *full_name)
const ResponseHeaders * response_headers()
Definition: rewrite_driver.h:266
OutputResourcePtr CreateOutputResourceWithPath(const StringPiece &mapped_path, const StringPiece &unmapped_path, const StringPiece &base_url, const StringPiece &filter_id, const StringPiece &name, OutputResourceKind kind, GoogleString *failure_reason)
DomainRewriteFilter * domain_rewriter()
Definition: rewrite_driver.h:986
void ExecuteFlushIfRequested()
void PropertyCacheSetupDone()
Definition: critical_selector_finder.h:43
bool Write(const ResourceVector &inputs, const StringPiece &contents, const ContentType *type, StringPiece charset, OutputResource *output)
const GoogleUrl & google_url() const
Gets a parsed GoogleUrl& corresponding to url().
Definition: html_parse.h:385
bool DecodeUrlGivenOptions(const GoogleUrl &url, const RewriteOptions *options, const UrlNamer *url_namer, StringVector *decoded_urls) const
bool is_critical_images_beacon_enabled()
GoogleString GenerateUnauthorizedDomainDebugComment(const GoogleUrl &gurl, InputRole role)
Generates an unauthorized domain debug comment. Public for unit tests.
void AppendRewriteFilter(RewriteFilter *filter)
bool MayCacheExtendCss() const
void ClearRequestProperties()
Reinitializes request_properties_, clearing any cached values.
const GoogleUrl & base_url() const
Definition: rewrite_driver.h:686
void SwitchToQueuedWorkerPool() EXCLUSIVE_LOCKS_REQUIRED(rewrite_mutex())
bool FetchOutputResource(const OutputResourcePtr &output_resource, RewriteFilter *filter, AsyncFetch *async_fetch)
virtual bool IsCacheValid(const GoogleString &key, const ResponseHeaders &headers)
void AddOwnedPostRenderFilter(HtmlFilter *filter)
Adds a filter to the end of the post-render chain, taking ownership.
void set_options_for_pool(RewriteDriverPool *pool, RewriteOptions *options)
Definition: rewrite_driver.h:487
RewriteFilter * FindFilter(const StringPiece &id) const
Finds a filter with the given ID, or returns NULL if none found.
static const char kSubresourcesPropertyName[]
Flush Subresources Info associted with the HTML page.
Definition: rewrite_driver.h:165
void set_response_headers_ptr(ResponseHeaders *headers)
Definition: rewrite_driver.h:273
InlineAttributeSlotPtr GetInlineAttributeSlot(const ResourcePtr &resource, HtmlElement *element, HtmlElement::Attribute *attribute)
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
void InfoAt(const RewriteContext *context, const char *msg,...) INSTAWEB_PRINTF_FORMAT(3
DependencyTracker * dependency_tracker() const
Definition: rewrite_driver.h:1131
static PropertyCache::CohortVector GetCohortList(const PropertyCache *pcache, const RewriteOptions *options, const ServerContext *server_context)
CssResolutionStatus
Status return-code for ResolveCssUrls.
Definition: rewrite_driver.h:103
CriticalSelectorInfo * critical_selector_info()
Definition: rewrite_driver.h:1065
FallbackPropertyPage * fallback_property_page() const
Definition: rewrite_driver.h:1033
StringPiece containing_charset()
Definition: rewrite_driver.h:722
PropertyPage * origin_property_page() const
ResourcePtr CreateInputResourceAbsoluteUncheckedForTestsOnly(const StringPiece &absolute_url)
FlushEarlyInfo * flush_early_info()
This method is not thread-safe. Call it only from the html parser thread.
void AddRewriteTask(Function *task)
Queues up a task to run on the (high-priority) rewrite thread.
static void InitStats(Statistics *statistics)
Initialize statistics for all filters that need it.
void RewriteComplete(RewriteContext *rewrite_context, RenderOp permit_render)
void SetSessionFetcher(UrlAsyncFetcher *f)
void IncrementAsyncEventsCount()
bool DebugMode() const
Definition: rewrite_driver.h:1137
Definition: url_left_trim_filter.h:47
ResourcePtr CreateInputResource(const GoogleUrl &input_url, InputRole role, bool *is_authorized)
bool FetchResource(const StringPiece &url, AsyncFetch *fetch)
void set_fully_rewrite_on_flush(bool x)
Definition: rewrite_driver.h:832
Definition: html_parse.h:88
bool is_nested() const
Determine whether this driver is nested inside another.
Definition: rewrite_driver.h:1169
void increment_num_inline_preview_images()
We expect to this method to be called on the HTML parser thread.
bool LookupMetadataForOutputResource(StringPiece url, GoogleString *error_out, RewriteContext::CacheLookupResultCallback *callback)
void set_critical_images_info(CriticalImagesInfo *critical_images_info)
Definition: rewrite_driver.h:1080
Definition: html_element.h:42
void set_origin_property_page(PropertyPage *page)
Takes ownership of page.
void FlushAsync(Function *done)
Definition: log_record.h:59
void FinishParseAsync(Function *callback)
void DecrementAsyncEventsCount()
Decrements a reference count bumped up by IncrementAsyncEventsCount()
void AddOwnedEarlyPreRenderFilter(HtmlFilter *filter)
static void Initialize()
Initialize statics. Initialize/Terminate calls must be paired.
bool IsResourceUrlClaimed(const GoogleUrl &url) const
RequestTrace * trace_context()
void set_custom_options(RewriteOptions *options)
Takes ownership of 'options'.
Definition: rewrite_driver.h:481
CspDirective
Definition: csp_directive.h:37
virtual void DetermineFiltersBehaviorImpl()
Definition: property_cache.h:323
void PrintStateToErrorLog(bool show_detached_contexts)
For logs.
XhtmlStatus MimeTypeXhtmlStatus()
const char * url() const
Definition: html_parse.h:383
InputRole
Definition: rewrite_driver.h:611
void DetachedFetchComplete()
WaitMode
Mode for BoundedWaitForCompletion.
Definition: rewrite_driver.h:110
void SetIsAmpDocument(bool is_amp)
bool MatchesBaseUrl(const GoogleUrl &input_url) const
bool FlattenCssImportsEnabled() const
Definition: rewrite_driver.h:1086
Callback2< const GoogleUrl &, bool * > ResourceUrlClaimant
Definition: resource.h:357
Definition: rewrite_driver_pool.h:34
Definition: function.h:47
StringPiece Spec() const
It is illegal to call this for invalid urls (check IsWebValid() first).
void SetRequestHeaders(const RequestHeaders &headers)
static GoogleString DeadlineExceededMessage(StringPiece filter_name)
Formats a "deadline exceeded" message for a given filter.
bool DecodeOutputResourceName(const GoogleUrl &url, const RewriteOptions *options_to_use, const UrlNamer *url_namer, ResourceNamer *name_out, OutputResourceKind *kind_out, RewriteFilter **filter_out) const
void FetchInPlaceResource(const GoogleUrl &gurl, bool proxy_mode, AsyncFetch *async_fetch)
static const char kStatusCodePropertyName[]
Status codes of previous responses.
Definition: rewrite_driver.h:167
void set_num_detached_rewrites(int64 x)
Sets the num_detached_rewrites_. This should only be called from test code.
Definition: rewrite_driver.h:1207
void DeleteRewriteContext(RewriteContext *rewrite_context)
OutputResourcePtr CreateOutputResourceWithMappedPath(const StringPiece &mapped_path, const StringPiece &unmapped_path, const StringPiece &filter_id, const StringPiece &name, OutputResourceKind kind, GoogleString *failure_reason)
Definition: rewrite_driver.h:590
void set_fast_blocking_rewrite(bool x)
Definition: rewrite_driver.h:844
void set_unowned_fallback_property_page(FallbackPropertyPage *page)
Does not take the ownership of the page.
ResponseHeaders * mutable_response_headers()
Definition: rewrite_driver.h:256
void set_other_base_problem()
Sets if we had other difficulty handling <base> tag.
Definition: rewrite_driver.h:716
CssResolutionStatus ResolveCssUrls(const GoogleUrl &input_css_base, const StringPiece &output_css_base, const StringPiece &contents, Writer *writer, MessageHandler *handler)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
XhtmlStatus
Definition: rewrite_driver.h:130
void set_fallback_property_page(FallbackPropertyPage *page)
Takes ownership of page.
void set_critical_selector_info(CriticalSelectorInfo *info)
Definition: rewrite_driver.h:1072
Definition: rewrite_driver.h:113
bool fully_rewrite_on_flush() const
Returns if this response has a blocking rewrite or not.
Definition: rewrite_driver.h:837
CacheUrlAsyncFetcher * CreateCacheOnlyFetcher()
Returns a cache fetcher that does not fall back to an actual fetcher.
void DeregisterForPartitionKey(const GoogleString &partition_key, RewriteContext *candidate)
static const char kLastRequestTimestamp[]
Definition: rewrite_driver.h:161
void AppendOwnedPreRenderFilter(HtmlFilter *filter)
Adds a filter to the end of the pre-render chain, taking ownership.
void DecrementRenderBlockingAsyncEventsCount()
Helper class for lexically scoped mutexing.
Definition: abstract_mutex.h:46
PropertyPage * property_page() const
bool MayRewriteUrl(const GoogleUrl &domain_url, const GoogleUrl &input_url, InlineAuthorizationPolicy inline_authorization_policy, IntendedFor intended_for, bool *is_authorized_domain) const
bool can_rewrite_resources() const
Definition: rewrite_driver.h:1166
bool refs_before_base() const
Returns refs_before_base.
Definition: rewrite_driver.h:706
LazyBool
Lazily-initialized boolean value.
Definition: basictypes.h:68
StringPiece fetch_url() const
The URL that was requested if FetchResource was called.
Definition: rewrite_driver.h:689
OutputResourcePtr CreateOutputResourceFromResource(const char *filter_id, const UrlSegmentEncoder *encoder, const ResourceContext *data, const ResourcePtr &input_resource, OutputResourceKind kind, GoogleString *failure_reason)
Definition: file_system.h:76
void BoundedWaitFor(WaitMode mode, int64 timeout_ms) LOCKS_EXCLUDED(rewrite_mutex())
void AddUnownedPostRenderFilter(HtmlFilter *filter)
Same, without taking ownership.
bool IsHttps() const
Quick way to tell if the document url is https (ie was fetched via https).
Definition: rewrite_driver.h:698
Definition: html_node.h:43
GoogleString ToString(bool show_detached_contexts) const LOCKS_EXCLUDED(rewrite_mutex())
Debugging routines to print out data about the driver.
void ReportSlowRewrites(int num)
void PrependRewriteFilter(RewriteFilter *filter)
HtmlResourceSlotPtr GetSlot(const ResourcePtr &resource, HtmlElement *elt, HtmlElement::Attribute *attr)
Definition: rewrite_driver.h:100
const GoogleUrl & decoded_base_url() const
Definition: rewrite_driver.h:694
bool SetOrClearPageSpeedOptionCookies(const GoogleUrl &gurl, ResponseHeaders *response_headers)
void set_num_initiated_rewrites(int64 x)
Definition: rewrite_driver.h:1198
void set_property_page(PropertyPage *page)
Takes ownership of page.
void PrependOwnedPreRenderFilter(HtmlFilter *filter)
Adds a filter to the beginning of the pre-render chain, taking ownership.
Definition: server_context.h:99
virtual bool StartParseId(const StringPiece &url, const StringPiece &id, const ContentType &content_type)
Definition: content_type.h:31
RewriteDriverPool * controlling_pool()
Pool in which this driver can be recycled. May be NULL.
Definition: rewrite_driver.h:493
Definition: rewrite_context.h:155
void set_externally_managed(bool x)
Definition: rewrite_driver.h:862
OutputResourcePtr CreateOutputResourceWithUnmappedUrl(const GoogleUrl &unmapped_gurl, const StringPiece &filter_id, const StringPiece &name, OutputResourceKind kind, GoogleString *failure_reason)
StringPiece AllExceptLeaf() const
virtual void FinishParse()
void AppendUnownedPreRenderFilter(HtmlFilter *filter)
Same, without taking ownership.
bool InitiateRewrite(RewriteContext *rewrite_context) LOCKS_EXCLUDED(rewrite_mutex())
void PrintState(bool show_detached_contexts)
For debugging.
int num_inline_preview_images() const
Definition: rewrite_driver.h:1096
void SetWriter(Writer *writer)
bool ShouldAbsolutifyUrl(const GoogleUrl &input_base, const GoogleUrl &output_base, bool *proxy_mode) const
void AddResourceUrlClaimant(ResourceUrlClaimant *claimant)
void bool GenerateOutputResourceNameAndUrl(const UrlSegmentEncoder *encoder, const ResourceContext *data, const ResourcePtr &input_resource, GoogleString *name, GoogleUrl *mapped_gurl, GoogleString *failure_reason)
Constructs name and URL for the specified input resource and encoder.
void AddLowPriorityRewriteTask(Function *task)
OptionsAwareHTTPCacheCallback(const RewriteOptions *rewrite_options, const RequestContextPtr &request_ctx)
void TracePrintf(const char *fmt,...)
InlineAuthorizationPolicy
See CreateInputResource.
Definition: rewrite_driver.h:137
Definition: url_segment_encoder.h:33
SrcSetSlotCollectionPtr GetSrcSetSlotCollection(CommonFilter *filter, HtmlElement *element, HtmlElement::Attribute *attr)
const GoogleString & CacheFragment() const
wait for everything to complete (up to deadline)
Definition: rewrite_driver.h:112
static const char kBeaconCohort[]
The cohort for properties that are written by the beacon handler.
Definition: rewrite_driver.h:153
Definition: message_handler.h:39
bool Decode(StringPiece leaf, ResourceNamer *resource_namer) const
Definition: http_cache.h:132
virtual int64 OverrideCacheTtlMs(const GoogleString &key)
DeviceType
Definition: user_agent_matcher.h:49
OutputResourcePtr CreateOutputResourceWithPath(const StringPiece &path, const StringPiece &filter_id, const StringPiece &name, OutputResourceKind kind, GoogleString *failure_reason)
Definition: rewrite_driver.h:601
Definition: output_resource.h:44
CacheUrlAsyncFetcher * CreateCacheFetcher()
void set_refs_before_base()
Definition: rewrite_driver.h:713
RewriteContext * RegisterForPartitionKey(const GoogleString &partition_key, RewriteContext *candidate)
Used internally. Do not pass in.
Definition: rewrite_driver.h:111
Definition: dependency_tracker.h:41
void ExecuteFlushIfRequestedAsync(Function *callback)
AbstractLogRecord * log_record()
Definition: domain_rewrite_filter.h:50
void SetServerContext(ServerContext *server_context)
static const char kDependenciesCohort[]
Definition: rewrite_driver.h:157
const RewriteOptions * options() const
Return the options used for this RewriteDriver.
Definition: rewrite_driver.h:496
void UpdatePropertyValueInDomCohort(AbstractPropertyPage *page, StringPiece property_name, StringPiece property_value)
Definition: rewrite_options.h:84
void set_device_type(UserAgentMatcher::DeviceType x)
Sets the device type chosen for the current property_page.
Definition: rewrite_driver.h:897
Definition: rewrite_driver.h:1772
Counts some basic statistics observed as HTML is parsed.
Definition: dom_stats_filter.h:34
static const char kParseSizeLimitExceeded[]
Tracks if we exceeded the maximum size limit of html which we should parse.
Definition: rewrite_driver.h:163
bool DecodeUrl(const GoogleUrl &url, StringVector *decoded_urls) const
Decodes the incoming pagespeed url to original url(s).
Definition: request_properties.h:37
void InsertDebugComment(StringPiece unescaped_message, HtmlNode *node)
CriticalImagesInfo * critical_images_info() const
Used by ImageRewriteFilter for identifying critical images.
Definition: rewrite_driver.h:1057
IntendedFor
See CreateInputResource.
Definition: rewrite_driver.h:143
Definition: url_async_fetcher.h:33
void IncrementRenderBlockingAsyncEventsCount()
Definition: resource_namer.h:32
Definition: critical_images_finder.h:52
void RequestFlush()
Definition: rewrite_driver.h:917
OutputResourceKind
Definition: output_resource_kind.h:26
Definition: fallback_property_page.h:38