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

#include "in_place_resource_recorder.h"

List of all members.

Classes

class  HTTPValueFetch

Public Types

enum  HeadersKind { kPreliminaryHeaders, kFullHeaders }

Public Member Functions

 InPlaceResourceRecorder (const RequestContextPtr &request_context, StringPiece url, StringPiece fragment, RequestHeaders::Properties request_properties, bool respect_vary, int max_response_bytes, int max_concurrent_recordings, int64 implicit_cache_ttl_ms, HTTPCache *cache, Statistics *statistics, MessageHandler *handler)
virtual ~InPlaceResourceRecorder ()
virtual bool Write (const StringPiece &contents, MessageHandler *handler)
virtual bool Flush (MessageHandler *handler)
void ConsiderResponseHeaders (HeadersKind headers_kind, ResponseHeaders *response_headers)
void Fail ()
void DoneAndSetHeaders (ResponseHeaders *response_headers)
const GoogleString & url () const
MessageHandler * handler ()
bool failed ()
bool limit_active_recordings ()
int64 implicit_cache_ttl_ms ()

Static Public Member Functions

static void InitStats (Statistics *statistics)

Detailed Description

Records a copy of a resource streamed through it and saves the result to the cache if it's cacheable. Used in the In-Place Resource Optimization (IPRO) flow to get resources into the cache.


Member Enumeration Documentation

Enumerator:
kPreliminaryHeaders 

Headers should only be used to determine if context was gzip'd by a reverse proxy.

kFullHeaders 

Headers are complete.


Constructor & Destructor Documentation

net_instaweb::InPlaceResourceRecorder::InPlaceResourceRecorder ( const RequestContextPtr &  request_context,
StringPiece  url,
StringPiece  fragment,
RequestHeaders::Properties  request_properties,
bool  respect_vary,
int  max_response_bytes,
int  max_concurrent_recordings,
int64  implicit_cache_ttl_ms,
HTTPCache cache,
Statistics *  statistics,
MessageHandler *  handler 
)

Does not take ownership of request_headers, cache nor handler. Like other callbacks, InPlaceResourceRecorder is self-owned and will delete itself when DoneAndSetHeaders() is called.

Normally you should use DoneAndSetHeaders rather than deleting this directly.


Member Function Documentation

void net_instaweb::InPlaceResourceRecorder::ConsiderResponseHeaders ( HeadersKind  headers_kind,
ResponseHeaders *  response_headers 
)

Sometimes the response headers prohibit IPRO: If it's not an IPRO content type. If it's not served as cacheable. If there's a content length, and it's over our max. In these cases, shift into the failed state and stop any resource recording.

At this time we might also realize that there are too many IPRO recordings going on and skip IPRO for that reason. In that case we don't mark the resource as not ipro-cacheable.

You must call ConsiderResponseHeaders() with whatever information is available before payload. If it's only enough to determine if content is gzip'ed, pass in kPreliminaryHeaders. If it's the complete final headers, pass in kFullHeaders.

Call DoneAndSetHeaders() after the entire payload and headers are available. Note that only Content-Encoding: from ConsiderResponseHeaders will be used to determine whether to gunzip content or not. This is done since in Apache we can only capture the full headers after mod_deflate has already run, while content is captured before.

Does not take ownership of response_headers.

void net_instaweb::InPlaceResourceRecorder::DoneAndSetHeaders ( ResponseHeaders *  response_headers)

Call when finished and the final response headers are known. Because of Apache's quirky filter order, we cannot get both the uncompressed final contents and the complete headers at the same time.

Does not take ownership of response_headers.

Deletes itself. Do not use object after calling DoneAndSetHeaders().

Call if something went wrong. The results will not be added to cache. You still need to call DoneAndSetHeaders().

virtual bool net_instaweb::InPlaceResourceRecorder::Flush ( MessageHandler *  handler) [inline, virtual]

Flush is a no-op because we have to buffer up the whole contents before writing to cache.

virtual bool net_instaweb::InPlaceResourceRecorder::Write ( const StringPiece &  contents,
MessageHandler *  handler 
) [virtual]

These take a handler for compatibility with the Writer API, but the handler is not used.


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