Page Speed Optimization Libraries  1.8.31.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Friends
net_instaweb::ProxyFetchPropertyCallbackCollector Class Reference

#include "proxy_fetch.h"

List of all members.

Public Member Functions

 ProxyFetchPropertyCallbackCollector (ServerContext *server_context, const StringPiece &url, const RequestContextPtr &req_ctx, const RewriteOptions *options, UserAgentMatcher::DeviceType device_type)
void AddCallback (ProxyFetchPropertyCallback *callback)
void ConnectProxyFetch (ProxyFetch *proxy_fetch)
void Detach (HttpStatus::Code status_code)
PropertyPageproperty_page ()
 Returns the actual property page.
FallbackPropertyPagefallback_property_page ()
 Returns the fallback property page.
PropertyPageReleasePropertyPage (ProxyFetchPropertyCallback::PageType page_type)
FallbackPropertyPageReleaseFallbackPropertyPage ()
 Releases the ownership of fallback property page.
void AddPostLookupTask (Function *func)
bool IsCacheValid (int64 write_timestamp_ms) const
void Done (ProxyFetchPropertyCallback *callback)
 Called by a ProxyFetchPropertyCallback when the former is complete.
const RequestContextPtr & request_context ()
UserAgentMatcher::DeviceType device_type ()
 Returns DeviceType from device property page.

Friends

class ProxyFetchPropertyCallbackCollectorTest

Detailed Description

Tracks a collection of property-cache lookups occuring in parallel. Sequence is used to execute various functions in an orderly fashion to avoid any kind of race between Done(), ConnectProxyFetch(), Detach() and AddPostLookupTask(). When any function is called, it is added to the sequence and added function will be executed immediately if sequence is free, otherwise it will wait for its turn.

Order of events: InitiatePropertyCacheLookup-->AddPostLookupTask-->Initiate Html Fetch | (Added to Sequence) | | Fetch Done Lookup Done() | (Added to Sequence) ------------------- is html | !html | ConnectProxyFetch() Detach() (Added to Sequence)


Member Function Documentation

Add a callback to be handled by this collector. Transfers ownership of the callback to the collector.

In our flow, property-page will be available via RewriteDriver only after ProxyFetch is set. But there may be instances where the result may be required even before proxy-fetch is created. Any task that depends on the PropertyCache result will be executed as soon as PropertyCache lookup is done. func is guaranteed to execute after PropertyCache lookup has completed, as long as ProxyFetch is not set before PropertyCache lookup is done. One should use PropertyCache result via RewriteDriver if some other thread can initiate SetProxyFetch().

In our flow, we initiate the property-cache lookup prior to creating a proxy-fetch, so that RewriteOptions lookup can proceed in parallel. If/when we determine that ProxyFetch is associated with HTML content, we connect it to this callback. Note that if the property cache lookups have completed, this will result in a direct call into proxy_fetch->PropertyCacheComplete.

void net_instaweb::ProxyFetchPropertyCallbackCollector::Detach ( HttpStatus::Code  status_code)

If for any reason we decide *not* to initiate a ProxyFetch for a request, then we need to 'detach' this request so that we can delete it once it completes, rather than waiting for a ProxyFetch to be inserted. The status code of the response is passed from ProxyFetch to the Collector. In case the status code is unknown then pass RewriteDriver::kStatusCodeUnknown.

bool net_instaweb::ProxyFetchPropertyCallbackCollector::IsCacheValid ( int64  write_timestamp_ms) const

If options_ is NULL returns true. Else, returns true if (url_, write_timestamp_ms) is valid as per URL cache invalidation entries is options_.

Returns the collected PropertyPage with the corresponding page_type. Ownership of the object is transferred to the caller.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines