Page Speed Optimization Libraries
1.7.30.1
|
#include "in_place_resource_recorder.h"
Public Member Functions | |
InPlaceResourceRecorder (StringPiece url, RequestHeaders *request_headers, bool respect_vary, int max_response_bytes, int max_concurrent_recordings, HTTPCache *cache, Statistics *statistics, MessageHandler *handler) | |
virtual bool | Write (const StringPiece &contents, MessageHandler *handler) |
virtual bool | Flush (MessageHandler *handler) |
void | ConsiderResponseHeaders (ResponseHeaders *response_headers) |
void | Fail () |
void | DoneAndSetHeaders (ResponseHeaders *response_headers) |
const GoogleString & | url () const |
MessageHandler * | handler () |
bool | failed () |
bool | limit_active_recordings () |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
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.
net_instaweb::InPlaceResourceRecorder::InPlaceResourceRecorder | ( | StringPiece | url, |
RequestHeaders * | request_headers, | ||
bool | respect_vary, | ||
int | max_response_bytes, | ||
int | max_concurrent_recordings, | ||
HTTPCache * | cache, | ||
Statistics * | statistics, | ||
MessageHandler * | handler | ||
) |
Takes ownership of request_headers, but not cache nor handler. Like other callbacks, InPlaceResourceRecorder is self-owned and will delete itself when DoneAndSetHeaders() is called.
void net_instaweb::InPlaceResourceRecorder::ConsiderResponseHeaders | ( | 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.
If you have the final headers before processing the content you should call ConsiderResponseHeaders() yourself. Otherwise DoneAndSetHeaders() will call it for you.
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().
void net_instaweb::InPlaceResourceRecorder::Fail | ( | ) | [inline] |
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.