26 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CACHEABLE_RESOURCE_BASE_H_
27 #define NET_INSTAWEB_REWRITER_PUBLIC_CACHEABLE_RESOURCE_BASE_H_
34 #include "pagespeed/kernel/base/string.h"
36 namespace net_instaweb {
43 class ResponseHeaders;
61 const RequestContextPtr& request_context,
62 AsyncCallback* callback);
64 virtual void Freshen(FreshenCallback* callback, MessageHandler* handler);
66 virtual GoogleString
url()
const {
return url_; }
67 virtual GoogleString
cache_key()
const {
return cache_key_; }
74 const ContentType* type,
78 static void InitStats(StringPiece stat_prefix, Statistics* statistics);
82 virtual void PrepareRequest(
const RequestContextPtr& request_context,
83 RequestHeaders* headers);
92 RewriteDriver* rewrite_driver()
const {
return rewrite_driver_; }
93 const RewriteOptions* rewrite_options()
const;
100 class FreshenHttpCacheCallback;
101 class LoadHttpCacheCallback;
102 class FetchCallbackBase;
103 class FreshenFetchCallback;
104 class LoadFetchCallback;
105 friend class CacheableResourceBaseTest;
110 bool UpdateInputInfoForFreshen(
const ResponseHeaders& headers,
111 const HTTPValue& value,
112 Resource::FreshenCallback* callback);
116 bool IsValidAndCacheableImpl(
const ResponseHeaders& headers)
const;
119 MessageHandler* message_handler()
const {
124 GoogleString cache_key_;
128 Variable* recent_fetch_failures_;
129 Variable* recent_uncacheables_miss_;
130 Variable* recent_uncacheables_failure_;
virtual void LoadAndCallback(NotCacheablePolicy not_cacheable_policy, const RequestContextPtr &request_context, AsyncCallback *callback)
This checks the cache, and fetches the resource if appropriate.
bool ShouldSkipBackgroundFetch() const
ServerContext * server_context() const
Common methods across all deriviations.
Definition: resource.h:85
virtual void PrepareRequest(const RequestContextPtr &request_context, RequestHeaders *headers)
virtual void RefreshIfImminentlyExpiring()
virtual void PrepareResponseHeaders(ResponseHeaders *headers)
Definition: resource.h:56
NotCacheablePolicy
Definition: resource.h:67
virtual void Freshen(FreshenCallback *callback, MessageHandler *handler)
Definition: rewrite_driver.h:98
CacheableResourceBase(StringPiece stat_prefix, StringPiece url, StringPiece cache_key, const ContentType *type, RewriteDriver *rewrite_driver)
Note: InitStats(stat_prefix) must have been called before.
friend class RewriteDriver
for ReadIfCachedWithStatus
Definition: resource.h:274
virtual bool IsValidAndCacheable() const
virtual bool UseHttpCache() const
All the public methods here implement the Resource API.
Definition: cacheable_resource_base.h:55
Definition: cacheable_resource_base.h:50
virtual GoogleString cache_key() const
Definition: cacheable_resource_base.h:67
virtual GoogleString url() const
Gets the absolute URL of the resource.
Definition: cacheable_resource_base.h:66
Definition: http_cache.h:46