Page Speed Optimization Libraries
1.13.35.1
|
#include "request_context.h"
Public Member Functions | |
RequestContext (const HttpOptions &options, AbstractMutex *logging_mutex, Timer *timer) | |
RequestContext (AbstractMutex *logging_mutex, Timer *timer) | |
If you use this constructor, you MUST set_options() later. | |
virtual AbstractLogRecord * | NewSubordinateLogRecord (AbstractMutex *logging_mutex) |
RequestTrace * | root_trace_context () |
void | set_root_trace_context (RequestTrace *x) |
Takes ownership of the given context. | |
virtual RequestTrace * | CreateDependentTraceContext (const StringPiece &label) |
virtual void | ReleaseDependentTraceContext (RequestTrace *t) |
virtual AbstractLogRecord * | log_record () |
The log record for the this request, created when the request context is. | |
bool | using_http2 () const |
Determines whether this request is using the HTTP2 protocol. | |
void | set_using_http2 (bool x) |
void | SetHttp2SupportFromViaHeader (StringPiece header) |
const GoogleString & | minimal_private_suffix () const |
void | set_minimal_private_suffix (StringPiece minimal_private_suffix) |
void | SetAcceptsWebp (bool x) |
bool | accepts_webp () const |
void | SetAcceptsGzip (bool x) |
bool | accepts_gzip () const |
int64 | request_id () const |
void | set_request_id (int64 x) |
const GoogleString & | sticky_query_parameters_token () const |
void | set_sticky_query_parameters_token (StringPiece x) |
void | AddSessionAuthorizedFetchOrigin (const GoogleString &origin) |
bool | IsSessionAuthorizedFetchOrigin (const GoogleString &origin) const |
void | PrepareLogRecordForOutput () |
void | WriteBackgroundRewriteLog () |
Write the log for background rewriting into disk. | |
AbstractLogRecord * | GetBackgroundRewriteLog (ThreadSystem *thread_system, bool log_urls, bool log_url_indices, int max_rewrite_info_log_size) |
const RequestTimingInfo & | timing_info () const |
RequestTimingInfo * | mutable_timing_info () |
void | set_options (const HttpOptions &options) |
void | ResetOptions (const HttpOptions &options) |
const HttpOptions & | options () const |
void | Freeze () |
bool | frozen () const |
Public Member Functions inherited from net_instaweb::RefCounted< RequestContext > | |
void | Release () |
void | AddRef () |
bool | HasOneRef () |
Static Public Member Functions | |
static RequestContextPtr | NewTestRequestContext (ThreadSystem *thread_system) |
static RequestContextPtr | NewTestRequestContextWithTimer (ThreadSystem *thread_system, Timer *timer) |
static RequestContextPtr | NewTestRequestContext (AbstractLogRecord *log_record) |
Protected Member Functions | |
RequestContext (const HttpOptions &options, AbstractMutex *mutex, Timer *timer, AbstractLogRecord *log_record) | |
virtual | ~RequestContext () |
Destructors in refcounted classes should be protected. | |
REFCOUNT_FRIEND_DECLARATION (RequestContext) | |
A class which wraps state associated with a request.
This object should be reference counted, wrapped in a RequestContextPtr. We use reference counting because, depending on the timing of asynchronous rewrites, RPC calls, and so on, a RequestContext may outlive the original HTTP request serving, or not. Reference counting avoids the complexity of explicit transfer of ownership in these cases.
net_instaweb::RequestContext::RequestContext | ( | const HttpOptions & | options, |
AbstractMutex * | logging_mutex, | ||
Timer * | timer | ||
) |
|logging_mutex| will be passed to the request context's AbstractLogRecord, which will take ownership of it. If you will be doing logging in a real (threaded) environment, pass in a real mutex. If not, a NullMutex is fine. |timer| will be passed to the RequestTimingInfo, which will not take ownership. Passing NULL for |timer| is allowed.
|
protected |
|
inlinevirtual |
Creates a new RequestTrace associated with a request depending on the root user request; e.g., a subresource fetch for an HTML page.
This implementation is a no-op. Subclasses should customize this based on their underlying tracing system. A few interface notes:
AbstractLogRecord* net_instaweb::RequestContext::GetBackgroundRewriteLog | ( | ThreadSystem * | thread_system, |
bool | log_urls, | ||
bool | log_url_indices, | ||
int | max_rewrite_info_log_size | ||
) |
Return the log record for background rewrites. If it doesn't exist, create a new one.
|
inline |
Returns true for exactly the origins that were authorized for this particular session by calls to AddSessionAuthorizedFetchOrigin()
|
inline |
The minimal private suffix for the hostname specified in this request. This should be calculated from the hostname by considering the list of public suffixes and including one additional component. So if a host is "a.b.c.d.e.f.g" and "e.f.g" is on the public suffix list then the minimal private suffix is "d.e.f.g".
There are two ways of specifying the host – with the Host header, or on the initial request line. The caller should make sure to look in both places.
If a system doesn't want to fragment the cache by minimal private suffix, it may set value to the empty string.
|
virtual |
Creates a new, unowned AbstractLogRecord, for use by some subordinate action. Also useful in case of background activity where logging is required after the response is written out, e.g., blink flow.
|
inlinestatic |
void net_instaweb::RequestContext::PrepareLogRecordForOutput | ( | ) |
Prepare the AbstractLogRecord for a subsequent call to WriteLog. This might include propagating information collected in the RequestContext, RequestTimingInfo for example, to the underlying logging infrastructure.
|
virtual |
Releases this object's reference to the given context and frees memory. Calls to CreateDependentTraceContext need not be matched by calls to this function. If a dependent trace span is not released when the request context reference count drops to zero, this object will clean all dependent traces.
Note that automatic cleanup of dependent traces is provided for safety. To provide meaningful performance statistics, cleanup should be coupled with the completion of the event being traced.
Subclasses should customize this based on their underlying tracing system.
|
inline |
This allows changing options already set.
|
inline |
The root trace context is associated with the user request which we are attempting to serve. If this is a request with constituent resources that we rewrite, there may be several dependent fetches synthesized by PSOL during rewrites. Those are traced separately.
void net_instaweb::RequestContext::SetAcceptsGzip | ( | bool | x | ) |
Indicates whether the request-headers tell us that a browser can extract gzip compressed data.
void net_instaweb::RequestContext::SetAcceptsWebp | ( | bool | x | ) |
Indicates whether the request-headers tell us that a browser can render webp images.
void net_instaweb::RequestContext::SetHttp2SupportFromViaHeader | ( | StringPiece | header | ) |
Checks to see if the passed in Via: header indicates this connection was terminated by an HTTP/2 proxy, and if so, sets the using_http2 bit. (If there are multiple proxies, this looks only at the one closest to the user)
This assumes that all the Via: headers are combined here, with the usual comma separation.