Page Speed Optimization Libraries  1.5.27.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions
net_instaweb::RequestContext Class Reference

#include "request_context.h"

Inheritance diagram for net_instaweb::RequestContext:
net_instaweb::ApacheRequestContext

List of all members.

Classes

class  TimingInfo

Public Member Functions

 RequestContext (AbstractMutex *logging_mutex, Timer *timer)
virtual AbstractLogRecordNewSubordinateLogRecord (AbstractMutex *logging_mutex)
RequestTraceroot_trace_context ()
void set_root_trace_context (RequestTrace *x)
 Takes ownership of the given context.
virtual RequestTraceCreateDependentTraceContext (const StringPiece &label)
virtual void ReleaseDependentTraceContext (RequestTrace *t)
virtual AbstractLogRecordlog_record ()
 The log record for the this request, created when the request context is.
bool using_spdy () const
 Determines whether this request is using the SPDY protocol.
void set_using_spdy (bool x)
void PrepareLogRecordForOutput ()
void WriteBackgroundRewriteLog ()
 Write the log for background rewriting into disk.
AbstractLogRecordGetBackgroundRewriteLog (ThreadSystem *thread_system, bool log_urls, bool log_url_indices, int max_rewrite_info_log_size)
const TimingInfotiming_info () const
TimingInfomutable_timing_info ()

Static Public Member Functions

static RequestContextPtr NewTestRequestContext (ThreadSystem *thread_system)

Protected Member Functions

 RequestContext ()
virtual ~RequestContext ()
 Destructors in refcounted classes should be protected.
 REFCOUNT_FRIEND_DECLARATION (RequestContext)

Detailed Description

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.


Constructor & Destructor Documentation

net_instaweb::RequestContext::RequestContext ( AbstractMutex logging_mutex,
Timer timer 
) [explicit]

|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 TimingInfo, which will *not* take ownership. Passing NULL for |timer| is allowed.

Todo:
TODO(gee): Fix this, it sucks. The default constructor will not create a LogRecord. Subclass constructors must do this explicitly.

Member Function Documentation

virtual RequestTrace* net_instaweb::RequestContext::CreateDependentTraceContext ( const StringPiece &  label) [inline, virtual]

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.

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.

static RequestContextPtr net_instaweb::RequestContext::NewTestRequestContext ( ThreadSystem thread_system) [static]
Todo:
TODO(marq): Move this test context factory to a test-specific file. Makes a request context for running tests.

Prepare the AbstractLogRecord for a subsequent call to WriteLog. This might include propagating information collected in the RequestContext, TimingInfo for example, to the underlying logging infrastructure.

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.

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.


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