#include "async_fetch.h"
Public Member Functions | |
void | HeadersComplete () |
void | Done (bool success) |
virtual bool | Write (const StringPiece &sp, MessageHandler *handler) |
virtual bool | Flush (MessageHandler *handler) |
virtual bool | IsCachedResultValid (const ResponseHeaders &headers) |
RequestHeaders * | request_headers () |
void | set_request_headers (RequestHeaders *headers) |
const RequestHeaders * | request_headers () const |
ResponseHeaders * | response_headers () |
See doc for request_headers and set_request_headers. | |
void | set_response_headers (ResponseHeaders *headers) |
virtual bool | EnableThreaded () const |
virtual bool | IsBackgroundFetch () const |
virtual void | Reset () |
bool | headers_complete () const |
void | set_timing_info (TimingInfo *timing_info) |
virtual TimingInfo * | timing_info () |
GoogleString | TimingString () const |
Protected Member Functions | |
virtual bool | HandleWrite (const StringPiece &sp, MessageHandler *handler)=0 |
virtual bool | HandleFlush (MessageHandler *handler)=0 |
virtual void | HandleDone (bool success)=0 |
virtual void | HandleHeadersComplete ()=0 |
Abstract base class for encapsulating streaming, asynchronous HTTP fetches.
If you want to fetch a resources, implement this interface, create an instance and call UrlAsyncFetcher::Fetch() with it.
It combines the 3 callbacks we expect to get from fetchers (Write, Flush and Done) and adds a HeadersComplete indicator that is useful in any place where we want to deal with and send headers before Write or Done are called.
Note that it automatically invokes HeadersComplete before the first call to Write, Flush or Done.
void net_instaweb::AsyncFetch::Done | ( | bool | success | ) |
Fetch complete. This interface is intended for callers (e.g. Fetchers). Implementors must override HandleDone.
void net_instaweb::AsyncFetch::HeadersComplete | ( | ) |
Called when ResponseHeaders have been set, but before writing contents. Contract: Must be called (at most once) before Write, Flush or Done. Automatically invoked (if neccessary) before the first call to Write, Flush, or Done. This interface is intended for callers (e.g. Fetchers). Implementors of the AsyncFetch interface must override HandleHeadersComplete.
virtual bool net_instaweb::AsyncFetch::IsBackgroundFetch | ( | ) | const [inline, virtual] |
Indicates whether the request is a background fetch. These can be scheduled differently by the fetcher.
Reimplemented in net_instaweb::SharedAsyncFetch.
virtual bool net_instaweb::AsyncFetch::IsCachedResultValid | ( | const ResponseHeaders & | headers | ) | [inline, virtual] |
Is the cache entry corresponding to headers valid? Default is that it is valid. Sub-classes can provide specific implementations, e.g., based on cache invalidation timestamp in domain specific options. Used by CacheUrlAsyncFetcher.
Reimplemented in net_instaweb::ProxyFetch, and net_instaweb::SharedAsyncFetch.
const RequestHeaders* net_instaweb::AsyncFetch::request_headers | ( | ) | const |
Returns the request_headers as a const pointer: it is required that the RequestHeaders be pre-initialized via non-const request_headers() or via set_request_headers before calling this.
RequestHeaders* net_instaweb::AsyncFetch::request_headers | ( | ) |
Returns a pointer to the request-headers, lazily constructing them if needed. If they are constructed here (as opposed to being set with set_request_headers) then they will be owned by the class instance.
virtual void net_instaweb::AsyncFetch::Reset | ( | ) | [inline, virtual] |
Resets the 'headers_complete_' flag.
Reimplemented in net_instaweb::StringAsyncFetch, and net_instaweb::InflatingFetch.
void net_instaweb::AsyncFetch::set_request_headers | ( | RequestHeaders * | headers | ) |
Sets the request-headers to the specifid pointer. The caller must guarantee that the pointed-to headers remain valid as long as the AsyncFetch is running.
void net_instaweb::AsyncFetch::set_timing_info | ( | TimingInfo * | timing_info | ) |
Sets the TimingInfo to the specified pointer. The caller must guarantee that the pointed-to TimingInfo remains valid as long as the AsyncFetch is running.
virtual TimingInfo* net_instaweb::AsyncFetch::timing_info | ( | ) | [virtual] |
Returns a pointer to the timing info, lazily constructing them if needed. If they are constructed here (as opposed to being set with set_timing_info) then they will be owned by the class instance.
GoogleString net_instaweb::AsyncFetch::TimingString | ( | ) | const |
Returns a Timing information in a string eg. c1:0;c2:2;hf:45;. c1 is cache 1, c2 is cache 2, hf is headers fetch.
virtual bool net_instaweb::AsyncFetch::Write | ( | const StringPiece & | sp, | |
MessageHandler * | handler | |||
) | [virtual] |
Data available. This interface is intended for callers. Implementors must override HandlerWrite and HandleFlush.
Implements net_instaweb::Writer.