Page Speed Optimization Libraries
1.3.25.1
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_DRIVER_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_DRIVER_H_ 00021 00022 #include <map> 00023 #include <set> 00024 #include <vector> 00025 00026 #include "base/logging.h" 00027 #include "net/instaweb/htmlparse/public/html_element.h" 00028 #include "net/instaweb/htmlparse/public/html_node.h" 00029 #include "net/instaweb/htmlparse/public/html_parse.h" 00030 #include "net/instaweb/http/public/content_type.h" 00031 #include "net/instaweb/http/public/http_cache.h" 00032 #include "net/instaweb/http/public/request_context.h" 00033 #include "net/instaweb/http/public/user_agent_matcher.h" 00034 #include "net/instaweb/rewriter/public/output_resource_kind.h" 00035 #include "net/instaweb/rewriter/public/resource.h" 00036 #include "net/instaweb/rewriter/public/server_context.h" 00037 #include "net/instaweb/rewriter/public/resource_slot.h" 00038 #include "net/instaweb/rewriter/public/rewrite_options.h" 00039 #include "net/instaweb/rewriter/public/scan_filter.h" 00040 #include "net/instaweb/util/public/abstract_client_state.h" 00041 #include "net/instaweb/util/public/basictypes.h" 00042 #include "net/instaweb/util/public/google_url.h" 00043 #include "net/instaweb/util/public/printf_format.h" 00044 #include "net/instaweb/util/public/scoped_ptr.h" 00045 #include "net/instaweb/util/public/queued_worker_pool.h" 00046 #include "net/instaweb/util/public/scheduler.h" 00047 #include "net/instaweb/util/public/string.h" 00048 #include "net/instaweb/util/public/string_util.h" 00049 #include "net/instaweb/util/public/thread_system.h" 00050 #include "net/instaweb/util/public/url_segment_encoder.h" 00051 00052 namespace net_instaweb { 00053 00054 class AbstractMutex; 00055 class AddInstrumentationFilter; 00056 class AsyncFetch; 00057 class CacheUrlAsyncFetcher; 00058 class CommonFilter; 00059 class CriticalLineInfo; 00060 class DebugFilter; 00061 class DeviceProperties; 00062 class DomainRewriteFilter; 00063 class FileSystem; 00064 class FlushEarlyInfo; 00065 class FlushEarlyRenderInfo; 00066 class Function; 00067 class HtmlEvent; 00068 class HtmlFilter; 00069 class HtmlWriterFilter; 00070 class LogRecord; 00071 class MessageHandler; 00072 class OutputResource; 00073 class PropertyPage; 00074 class RequestHeaders; 00075 class RequestTrace; 00076 class ResourceContext; 00077 class ResourceNamer; 00078 class ResponseHeaders; 00079 class RewriteContext; 00080 class RewriteDriverPool; 00081 class RewriteFilter; 00082 class ScopedMutex; 00083 class Statistics; 00084 class UrlAsyncFetcher; 00085 class UrlLeftTrimFilter; 00086 class Writer; 00087 00090 class RewriteDriver : public HtmlParse { 00091 public: 00093 enum CssResolutionStatus { 00094 kWriteFailed, 00095 kNoResolutionNeeded, 00096 kSuccess 00097 }; 00098 00100 enum WaitMode { 00101 kNoWait, 00102 kWaitForCompletion, 00103 kWaitForCachedRender, 00104 00105 kWaitForShutDown 00106 00107 }; 00108 00120 enum XhtmlStatus { 00121 kXhtmlUnknown, 00122 kIsXhtml, 00123 kIsNotXhtml 00124 }; 00125 00132 static const char* kPassThroughRequestAttributes[5]; 00133 00137 static const char kDomCohort[]; 00138 00141 static const char kLastRequestTimestamp[]; 00143 static const char kParseSizeLimitExceeded[]; 00145 static const char kSubresourcesPropertyName[]; 00147 static const char kStatusCodePropertyName[]; 00148 00149 RewriteDriver(MessageHandler* message_handler, 00150 FileSystem* file_system, 00151 UrlAsyncFetcher* url_async_fetcher); 00152 00155 virtual ~RewriteDriver(); 00156 00159 RewriteDriver* Clone(); 00160 00166 void Clear(); 00167 00169 static void InitStats(Statistics* statistics); 00170 00172 static void Initialize(); 00173 static void Terminate(); 00174 00177 void SetResourceManager(ServerContext* resource_manager); 00178 00181 bool MayCacheExtendCss() const; 00182 bool MayCacheExtendImages() const; 00183 bool MayCacheExtendPdfs() const; 00184 bool MayCacheExtendScripts() const; 00185 00186 void RememberResource(const StringPiece& url, const ResourcePtr& resource); 00187 const GoogleString& user_agent() const { return user_agent_; } 00188 00189 void SetUserAgent(const StringPiece& user_agent_string); 00190 00191 const DeviceProperties* device_properties() const { 00192 return device_properties_.get(); 00193 } 00194 00196 void ClearDeviceProperties(); 00197 00199 bool using_spdy() const { return request_context_->using_spdy(); } 00200 00201 bool write_property_cache_dom_cohort() const { 00202 return write_property_cache_dom_cohort_; 00203 } 00204 void set_write_property_cache_dom_cohort(bool x) { 00205 write_property_cache_dom_cohort_ = x; 00206 } 00207 00208 RequestContextPtr request_context() { return request_context_; } 00209 void set_request_context(const RequestContextPtr& x); 00210 00213 RequestTrace* trace_context(); 00214 00217 void TracePrintf(const char* fmt, ...); 00218 00221 ResponseHeaders* mutable_response_headers() { 00222 return flush_occurred_ ? NULL : response_headers_; 00223 } 00224 00231 const ResponseHeaders* response_headers() { 00232 return response_headers_; 00233 } 00234 00238 void set_response_headers_ptr(ResponseHeaders* headers) { 00239 response_headers_ = headers; 00240 } 00241 00242 void set_request_headers(const RequestHeaders* headers) { 00243 request_headers_ = headers; 00244 } 00245 00246 const RequestHeaders* request_headers() const { 00247 DCHECK(request_headers_ != NULL); 00248 return request_headers_; 00249 } 00250 00251 UserAgentMatcher* user_agent_matcher() const { 00252 DCHECK(server_context() != NULL); 00253 return server_context()->user_agent_matcher(); 00254 } 00255 00256 bool SupportsFlushEarly() const; 00257 00262 void AddFilters(); 00263 00267 void AddOwnedEarlyPreRenderFilter(HtmlFilter* filter); 00268 00270 void PrependOwnedPreRenderFilter(HtmlFilter* filter); 00272 void AppendOwnedPreRenderFilter(HtmlFilter* filter); 00273 00275 void AddOwnedPostRenderFilter(HtmlFilter* filter); 00277 void AddUnownedPostRenderFilter(HtmlFilter* filter); 00278 00290 void AppendRewriteFilter(RewriteFilter* filter); 00291 00294 void PrependRewriteFilter(RewriteFilter* filter); 00295 00301 void SetWriter(Writer* writer); 00302 00303 Writer* writer() const { return writer_; } 00304 00330 bool FetchResource(const StringPiece& url, AsyncFetch* fetch); 00331 00343 void FetchInPlaceResource(const GoogleUrl& gurl, bool perform_http_fetch, 00344 AsyncFetch* async_fetch); 00345 00352 bool FetchOutputResource(const OutputResourcePtr& output_resource, 00353 RewriteFilter* filter, 00354 AsyncFetch* async_fetch); 00355 00362 OutputResourcePtr DecodeOutputResource(const GoogleUrl& url, 00363 RewriteFilter** filter) const; 00364 00368 bool DecodeOutputResourceName(const GoogleUrl& url, 00369 ResourceNamer* name_out, 00370 OutputResourceKind* kind_out, 00371 RewriteFilter** filter_out) const; 00372 00374 bool DecodeUrl(const GoogleUrl& url, 00375 StringVector* decoded_urls) const; 00376 00377 FileSystem* file_system() { return file_system_; } 00378 UrlAsyncFetcher* async_fetcher() { return url_async_fetcher_; } 00379 00384 void SetSessionFetcher(UrlAsyncFetcher* f); 00385 00388 CacheUrlAsyncFetcher* CreateCacheFetcher(); 00390 CacheUrlAsyncFetcher* CreateCacheOnlyFetcher(); 00391 00392 ServerContext* server_context() const { return server_context_; } 00393 Statistics* statistics() const; 00394 00395 AddInstrumentationFilter* add_instrumentation_filter() { 00396 return add_instrumentation_filter_; 00397 } 00398 00400 void set_custom_options(RewriteOptions* options) { 00401 set_options_for_pool(NULL, options); 00402 } 00403 00406 void set_options_for_pool(RewriteDriverPool* pool, RewriteOptions* options) { 00407 controlling_pool_ = pool; 00408 options_.reset(options); 00409 } 00410 00412 RewriteDriverPool* controlling_pool() { return controlling_pool_; } 00413 00415 const RewriteOptions* options() const { return options_.get(); } 00416 00418 virtual bool StartParseId(const StringPiece& url, const StringPiece& id, 00419 const ContentType& content_type); 00420 00427 virtual void FinishParse(); 00428 00431 void FinishParseAsync(Function* callback); 00432 00437 void InhibitEndElement(const HtmlElement* element); 00438 00445 void UninhibitEndElement(const HtmlElement* element); 00446 00448 bool EndElementIsInhibited(const HtmlElement* element); 00449 00453 bool EndElementIsStoppingFlush(const HtmlElement* element); 00454 00458 void InfoAt(const RewriteContext* context, 00459 const char* msg, ...) INSTAWEB_PRINTF_FORMAT(3, 4); 00460 00465 00472 OutputResourcePtr CreateOutputResourceFromResource( 00473 const StringPiece& filter_id, 00474 const UrlSegmentEncoder* encoder, 00475 const ResourceContext* data, 00476 const ResourcePtr& input_resource, 00477 OutputResourceKind kind); 00478 00495 OutputResourcePtr CreateOutputResourceWithPath( 00496 const StringPiece& mapped_path, const StringPiece& unmapped_path, 00497 const StringPiece& base_url, const StringPiece& filter_id, 00498 const StringPiece& name, OutputResourceKind kind); 00499 00502 void PopulateResourceNamer( 00503 const StringPiece& filter_id, 00504 const StringPiece& name, 00505 ResourceNamer* full_name); 00506 00510 OutputResourcePtr CreateOutputResourceWithUnmappedUrl( 00511 const GoogleUrl& unmapped_gurl, const StringPiece& filter_id, 00512 const StringPiece& name, OutputResourceKind kind); 00513 00516 OutputResourcePtr CreateOutputResourceWithMappedPath( 00517 const StringPiece& mapped_path, const StringPiece& unmapped_path, 00518 const StringPiece& filter_id, const StringPiece& name, 00519 OutputResourceKind kind) { 00520 return CreateOutputResourceWithPath(mapped_path, unmapped_path, 00521 decoded_base_url_.AllExceptLeaf(), 00522 filter_id, name, kind); 00523 } 00524 00527 OutputResourcePtr CreateOutputResourceWithPath( 00528 const StringPiece& path, const StringPiece& filter_id, 00529 const StringPiece& name, OutputResourceKind kind) { 00530 return CreateOutputResourceWithPath(path, path, path, filter_id, name, 00531 kind); 00532 } 00533 00537 ResourcePtr CreateInputResource(const GoogleUrl& input_url); 00538 00542 ResourcePtr CreateInputResourceAbsoluteUnchecked( 00543 const StringPiece& absolute_url); 00544 00549 bool MatchesBaseUrl(const GoogleUrl& input_url) const; 00550 00554 bool MayRewriteUrl(const GoogleUrl& domain_url, 00555 const GoogleUrl& input_url) const; 00556 00561 void ReadAsync(Resource::AsyncCallback* callback, 00562 MessageHandler* message_handler); 00563 00567 const GoogleUrl& base_url() const { return base_url_; } 00568 00572 const GoogleUrl& decoded_base_url() const { return decoded_base_url_; } 00573 StringPiece decoded_base() const { return decoded_base_url_.Spec(); } 00574 00576 bool IsHttps() const { return google_url().SchemeIs("https"); } 00577 00578 const UrlSegmentEncoder* default_encoder() const { return &default_encoder_; } 00579 00581 RewriteFilter* FindFilter(const StringPiece& id) const; 00582 00584 bool refs_before_base() { return refs_before_base_; } 00585 00590 void set_refs_before_base() { refs_before_base_ = true; } 00591 00596 StringPiece containing_charset() { return containing_charset_; } 00597 void set_containing_charset(const StringPiece charset) { 00598 charset.CopyToString(&containing_charset_); 00599 } 00600 00602 HtmlResourceSlotPtr GetSlot(const ResourcePtr& resource, 00603 HtmlElement* elt, 00604 HtmlElement::Attribute* attr); 00605 00610 bool InitiateRewrite(RewriteContext* rewrite_context); 00611 void InitiateFetch(RewriteContext* rewrite_context); 00612 00623 void RewriteComplete(RewriteContext* rewrite_context, bool permit_render); 00624 00628 void ReportSlowRewrites(int num); 00629 00634 void Cleanup(); 00635 00637 GoogleString ToString(bool show_detached_contexts); 00638 void PrintState(bool show_detached_contexts); 00639 void PrintStateToErrorLog(bool show_detached_contexts); 00640 00643 void WaitForCompletion(); 00644 00651 void WaitForShutDown(); 00652 00656 void BoundedWaitFor(WaitMode mode, int64 timeout_ms); 00657 00665 void set_fully_rewrite_on_flush(bool x) { 00666 fully_rewrite_on_flush_ = x; 00667 } 00668 00671 void EnableBlockingRewrite(RequestHeaders* request_headers); 00672 00679 void set_externally_managed(bool x) { externally_managed_ = x; } 00680 00684 void DetachFetch(); 00685 00688 void DetachedFetchComplete(); 00689 00693 void FetchComplete(); 00694 00700 void DeleteRewriteContext(RewriteContext* rewrite_context); 00701 00707 void set_rewrite_deadline_ms(int x) { options_->set_rewrite_deadline_ms(x); } 00708 int rewrite_deadline_ms() { return options_->rewrite_deadline_ms(); } 00709 00714 void set_max_page_processing_delay_ms(int x) { 00715 max_page_processing_delay_ms_ = x; 00716 } 00717 int max_page_processing_delay_ms() { return max_page_processing_delay_ms_; } 00718 00720 void set_device_type(UserAgentMatcher::DeviceType x) { device_type_ = x; } 00721 UserAgentMatcher::DeviceType device_type() { return device_type_; } 00722 00728 RewriteContext* RegisterForPartitionKey(const GoogleString& partition_key, 00729 RewriteContext* candidate); 00730 00735 void DeregisterForPartitionKey( 00736 const GoogleString& partition_key, RewriteContext* candidate); 00737 00740 void RequestFlush() { flush_requested_ = true; } 00741 bool flush_requested() const { return flush_requested_; } 00742 00754 void ExecuteFlushIfRequested(); 00755 00759 void ExecuteFlushIfRequestedAsync(Function* callback); 00760 00769 virtual void Flush(); 00770 00776 void FlushAsync(Function* done); 00777 00779 void AddRewriteTask(Function* task); 00780 00783 void AddLowPriorityRewriteTask(Function* task); 00784 00785 QueuedWorkerPool::Sequence* html_worker() { return html_worker_; } 00786 QueuedWorkerPool::Sequence* rewrite_worker() { return rewrite_worker_; } 00787 QueuedWorkerPool::Sequence* low_priority_rewrite_worker() { 00788 return low_priority_rewrite_worker_; 00789 } 00790 00791 Scheduler* scheduler() { return scheduler_; } 00792 00795 DomainRewriteFilter* domain_rewriter() { return domain_rewriter_.get(); } 00796 UrlLeftTrimFilter* url_trim_filter() { return url_trim_filter_.get(); } 00797 00805 CssResolutionStatus ResolveCssUrls(const GoogleUrl& input_css_base, 00806 const StringPiece& output_css_base, 00807 const StringPiece& contents, 00808 Writer* writer, 00809 MessageHandler* handler); 00810 00818 bool ShouldAbsolutifyUrl(const GoogleUrl& input_base, 00819 const GoogleUrl& output_base, 00820 bool* proxy_mode) const; 00821 00829 void UpdatePropertyValueInDomCohort(StringPiece property_name, 00830 StringPiece property_value); 00831 00834 void set_client_state(AbstractClientState* client_state) { 00835 client_state_.reset(client_state); 00836 } 00837 00841 AbstractClientState* client_state() const { return client_state_.get(); } 00842 00843 void set_client_id(const StringPiece& id) { client_id_ = id.as_string(); } 00844 const GoogleString& client_id() const { return client_id_; } 00845 00846 PropertyPage* property_page() const { return property_page_; } 00847 void set_property_page(PropertyPage* page); 00848 00849 void set_unowned_property_page(PropertyPage* page); 00850 00852 const CriticalLineInfo* critical_line_info() const; 00853 00856 void set_critical_line_info(CriticalLineInfo* critical_line_info); 00857 00859 const StringSet* critical_images() const { 00860 return critical_images_.get(); 00861 } 00862 00865 void set_critical_images(StringSet* critical_images) { 00866 critical_images_.reset(critical_images); 00867 } 00868 00869 const StringSet* css_critical_images() const { 00870 return css_critical_images_.get(); 00871 } 00872 00875 void set_css_critical_images(StringSet* css_critical_images) { 00876 css_critical_images_.reset(css_critical_images); 00877 } 00878 00879 bool updated_critical_images() const { return updated_critical_images_; } 00880 void set_updated_critical_images(bool x) { updated_critical_images_ = x; } 00881 00885 int num_inline_preview_images() const { return num_inline_preview_images_; } 00886 00888 void increment_num_inline_preview_images(); 00889 00892 int num_flushed_early_pagespeed_resources() const { 00893 return num_flushed_early_pagespeed_resources_; 00894 } 00895 00898 void increment_num_flushed_early_pagespeed_resources() { 00899 ++num_flushed_early_pagespeed_resources_; 00900 } 00901 00905 void increment_async_events_count(); 00906 00908 void decrement_async_events_count(); 00909 00912 XhtmlStatus MimeTypeXhtmlStatus(); 00913 00914 void set_flushed_cached_html(bool x) { flushed_cached_html_ = x; } 00915 bool flushed_cached_html() { return flushed_cached_html_; } 00916 00917 void set_flushing_cached_html(bool x) { flushing_cached_html_ = x; } 00918 bool flushing_cached_html() { return flushing_cached_html_; } 00919 00920 void set_flushed_early(bool x) { flushed_early_ = x; } 00921 bool flushed_early() { return flushed_early_; } 00922 00923 void set_flushing_early(bool x) { flushing_early_ = x; } 00924 bool flushing_early() { return flushing_early_; } 00925 00926 void set_is_lazyload_script_flushed(bool x) { 00927 is_lazyload_script_flushed_ = x; 00928 } 00929 bool is_lazyload_script_flushed() { return is_lazyload_script_flushed_; } 00930 00932 FlushEarlyInfo* flush_early_info(); 00933 00934 FlushEarlyRenderInfo* flush_early_render_info() const; 00935 00938 void set_flush_early_render_info( 00939 FlushEarlyRenderInfo* flush_early_render_info); 00940 00941 void set_serve_blink_non_critical(bool x) { serve_blink_non_critical_ = x; } 00942 bool serve_blink_non_critical() const { return serve_blink_non_critical_; } 00943 00944 void set_is_blink_request(bool x) { is_blink_request_ = x; } 00945 bool is_blink_request() const { return is_blink_request_; } 00946 00949 bool DebugMode() const { return options()->Enabled(RewriteOptions::kDebug); } 00950 00953 void SaveOriginalHeaders(const ResponseHeaders& response_headers); 00954 00957 LogRecord* log_record(); 00958 00961 bool can_rewrite_resources() { return can_rewrite_resources_; } 00962 00964 void set_is_nested(bool n) { is_nested_ = n; } 00965 bool is_nested() const { return is_nested_; } 00966 00979 bool Write(const ResourceVector& inputs, 00980 const StringPiece& contents, 00981 const ContentType* type, 00982 StringPiece charset, 00983 OutputResource* output); 00984 00985 private: 00986 friend class RewriteContext; 00987 friend class RewriteDriverTest; 00988 friend class RewriteTestBase; 00989 friend class ServerContextTest; 00990 00991 typedef std::map<GoogleString, RewriteFilter*> StringFilterMap; 00992 00997 void FetchCompleteImpl(bool signal, ScopedMutex* lock); 00998 01003 void CheckForCompletionAsync(WaitMode wait_mode, int64 timeout_ms, 01004 Function* done); 01005 01009 void TryCheckForCompletion(WaitMode wait_mode, int64 end_time_ms, 01010 Function* done); 01011 01013 bool IsDone(WaitMode wait_mode, bool deadline_reached); 01014 01018 void FlushAsyncDone(int num_rewrites, Function* callback); 01019 01024 int64 ComputeCurrentFlushWindowRewriteDelayMs(); 01025 01027 void QueueFlushAsyncDone(int num_rewrites, Function* callback); 01028 01031 void QueueFinishParseAfterFlush(Function* user_callback); 01032 void FinishParseAfterFlush(Function* user_callback); 01033 01035 bool RewritesComplete() const; 01036 01041 bool HaveBackgroundFetchRewrite() const; 01042 01045 void SetBaseUrlIfUnset(const StringPiece& new_base); 01046 01049 void SetBaseUrlForFetch(const StringPiece& url); 01050 01053 void SetDecodedUrlFromBase(); 01054 01056 AbstractMutex* rewrite_mutex() { return scheduler_->mutex(); } 01057 01059 virtual void ParseTextInternal(const char* content, int size); 01060 01062 bool ShouldSkipParsing(); 01063 01064 friend class ScanFilter; 01065 01069 void AddCommonFilter(CommonFilter* filter); 01070 01074 void RegisterRewriteFilter(RewriteFilter* filter); 01075 01080 void EnableRewriteFilter(const char* id); 01081 01085 ResourcePtr CreateInputResourceUnchecked(const GoogleUrl& gurl); 01086 01087 void AddPreRenderFilters(); 01088 void AddPostRenderFilters(); 01089 01091 void UninhibitFlushDone(Function* user_callback); 01092 01094 void SplitQueueIfNecessary(); 01095 01097 bool DecodeOutputResourceNameHelper(const GoogleUrl& url, 01098 ResourceNamer* name_out, 01099 OutputResourceKind* kind_out, 01100 RewriteFilter** filter_out, 01101 GoogleString* url_base, 01102 StringVector* urls) const; 01103 01113 void WriteDomCohortIntoPropertyCache(); 01114 01117 void WriteClientStateIntoPropertyCache(); 01118 01119 void FinalizeFilterLogging(); 01120 01122 CacheUrlAsyncFetcher* CreateCustomCacheFetcher(UrlAsyncFetcher* base_fetcher); 01123 01135 bool base_was_set_; 01136 01141 bool refs_before_base_; 01142 01144 GoogleString containing_charset_; 01145 01146 bool filters_added_; 01147 bool externally_managed_; 01148 01152 bool fetch_queued_; 01153 01158 bool fetch_detached_; 01159 01166 bool detached_fetch_main_path_complete_; 01167 bool detached_fetch_detached_path_complete_; 01168 01171 bool parsing_; 01172 01176 WaitMode waiting_; 01177 01182 bool fully_rewrite_on_flush_; 01183 01186 bool cleanup_on_fetch_complete_; 01187 01188 bool flush_requested_; 01189 bool flush_occurred_; 01190 01192 bool flushed_cached_html_; 01193 01195 bool flushing_cached_html_; 01196 01199 bool flushed_early_; 01203 bool flushing_early_; 01204 01207 bool is_lazyload_script_flushed_; 01208 01210 bool release_driver_; 01211 01215 bool write_property_cache_dom_cohort_; 01216 01217 scoped_ptr<AbstractMutex> inhibits_mutex_; 01218 typedef std::set <const HtmlElement*> ConstHtmlElementSet; 01219 ConstHtmlElementSet end_elements_inhibited_; 01220 HtmlEventList deferred_queue_; 01221 Function* finish_parse_on_hold_; 01222 HtmlEvent* inhibiting_event_; 01223 bool flush_in_progress_; 01224 bool uninhibit_reflush_requested_; 01225 01233 int rewrites_to_delete_; 01234 01237 GoogleUrl base_url_; 01238 01242 GoogleUrl decoded_base_url_; 01243 01244 GoogleString user_agent_; 01245 01246 LazyBool should_skip_parsing_; 01247 mutable LazyBool supports_flush_early_; 01248 01249 StringFilterMap resource_filter_map_; 01250 01251 ResponseHeaders* response_headers_; 01252 const RequestHeaders* request_headers_; 01253 int status_code_; 01254 01257 typedef std::vector<RewriteContext*> RewriteContextVector; 01258 RewriteContextVector rewrites_; 01259 01262 int max_page_processing_delay_ms_; 01263 01264 typedef std::set<RewriteContext*> RewriteContextSet; 01265 01270 RewriteContextSet initiated_rewrites_; 01271 01279 RewriteContextSet detached_rewrites_; 01280 01285 int pending_rewrites_; 01286 01288 int possibly_quick_rewrites_; 01289 01294 int pending_async_events_; 01295 01298 FileSystem* file_system_; 01299 ServerContext* server_context_; 01300 Scheduler* scheduler_; 01301 UrlAsyncFetcher* default_url_async_fetcher_; 01302 01306 UrlAsyncFetcher* url_async_fetcher_; 01307 01310 std::vector<UrlAsyncFetcher*> owned_url_async_fetchers_; 01311 01312 AddInstrumentationFilter* add_instrumentation_filter_; 01313 scoped_ptr<HtmlWriterFilter> html_writer_filter_; 01314 01315 ScanFilter scan_filter_; 01316 scoped_ptr<DomainRewriteFilter> domain_rewriter_; 01317 scoped_ptr<UrlLeftTrimFilter> url_trim_filter_; 01318 01320 typedef std::map<GoogleString, ResourcePtr> ResourceMap; 01321 ResourceMap resource_map_; 01322 01325 typedef std::map<GoogleString, RewriteContext*> PrimaryRewriteContextMap; 01326 PrimaryRewriteContextMap primary_rewrite_context_map_; 01327 01328 HtmlResourceSlotSet slots_; 01329 01330 scoped_ptr<RewriteOptions> options_; 01331 RewriteDriverPool* controlling_pool_; 01332 01334 UrlSegmentEncoder default_encoder_; 01335 01337 FilterList early_pre_render_filters_; 01339 FilterList pre_render_filters_; 01340 01344 FilterVector filters_to_delete_; 01345 01346 QueuedWorkerPool::Sequence* html_worker_; 01347 QueuedWorkerPool::Sequence* rewrite_worker_; 01348 QueuedWorkerPool::Sequence* low_priority_rewrite_worker_; 01349 01350 Writer* writer_; 01351 01353 GoogleString client_id_; 01354 01356 scoped_ptr<AbstractClientState> client_state_; 01357 01359 PropertyPage* property_page_; 01360 01362 bool owns_property_page_; 01363 01365 UserAgentMatcher::DeviceType device_type_; 01366 01367 scoped_ptr<CriticalLineInfo> critical_line_info_; 01368 01370 scoped_ptr<StringSet> critical_images_; 01371 01373 scoped_ptr<StringSet> css_critical_images_; 01374 01376 bool updated_critical_images_; 01377 01379 bool xhtml_mimetype_computed_; 01380 XhtmlStatus xhtml_status_ : 8; 01381 01384 int num_inline_preview_images_; 01385 01387 int num_flushed_early_pagespeed_resources_; 01388 01390 int num_bytes_in_; 01391 01392 DebugFilter* debug_filter_; 01393 01394 scoped_ptr<FlushEarlyInfo> flush_early_info_; 01395 scoped_ptr<FlushEarlyRenderInfo> flush_early_render_info_; 01396 01400 bool serve_blink_non_critical_; 01402 bool is_blink_request_; 01403 bool can_rewrite_resources_; 01404 01407 RequestContextPtr request_context_; 01408 01410 int64 start_time_ms_; 01411 01416 bool is_nested_; 01417 01418 scoped_ptr<DeviceProperties> device_properties_; 01419 01423 static int initialized_count_; 01424 01425 DISALLOW_COPY_AND_ASSIGN(RewriteDriver); 01426 }; 01427 01430 class OptionsAwareHTTPCacheCallback : public HTTPCache::Callback { 01431 public: 01432 virtual ~OptionsAwareHTTPCacheCallback(); 01433 virtual bool IsCacheValid(const GoogleString& key, 01434 const ResponseHeaders& headers); 01435 virtual int64 OverrideCacheTtlMs(const GoogleString& key); 01436 protected: 01439 OptionsAwareHTTPCacheCallback( 01440 const RewriteOptions* rewrite_options, 01441 const RequestContextPtr& request_ctx); 01442 01443 private: 01444 const RewriteOptions* rewrite_options_; 01445 01446 DISALLOW_COPY_AND_ASSIGN(OptionsAwareHTTPCacheCallback); 01447 }; 01448 01449 } 01450 01451 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_DRIVER_H_