#include "async_fetch_with_lock.h"
|
static const int | kContentLengthUnknown = -1 |
|
AsyncFetch object which tries to acquire lock before fetching content. Start() will returns false, if it fails to acquire lock. Note that acquiring a lock will fail if same resource is fetching somewhere else. Caller will call the Start() which will try to acquire a lock and internally call StartFetch() which actually triggers a fetch. Sequence of the events: 1) Caller calls AsyncFetchWithLock::Start(). 2) Start() will try to acquire lock. If lock is acquired successfully, AsyncFetchWithLock::StartFetch() will be called, otherwise AsyncFetchWithLock::Finalize() is called with lock_failure as true and success as false and StartFetch() returns false and async_fetch_with_lock object will be deleted. Note: StartFetch() will be called in case of lock failure only if ShouldYieldToRedundantFetchInProgress() returns false. 3) Subclass defines StartFetch() function which actually triggers UrlAsyncFetcher::Fetch(). 4) Subclass can override HandleHeadersComplete(), HandleWrite(), HandleFlush() and HandleDone() for special handling during fetch. HandleDone() also releases the lock. Note: If any of these functions is overridden, then AsyncFetchWithLock::HandleXXX should also be called. 5) Lastly AsyncFetchWithLock::Finalize() is called just before async_fetch delete itself.
virtual void net_instaweb::AsyncFetchWithLock::Finalize |
( |
bool |
lock_failure, |
|
|
bool |
success |
|
) |
| |
|
protectedvirtual |
Finalize is called either when we fail to acquire acquire a lock or at the end of request after releasing the lock.
virtual void net_instaweb::AsyncFetchWithLock::HandleDone |
( |
bool |
success | ) |
|
|
protectedvirtual |
virtual void net_instaweb::AsyncFetchWithLock::HandleHeadersComplete |
( |
| ) |
|
|
protectedvirtual |
virtual bool net_instaweb::AsyncFetchWithLock::ShouldYieldToRedundantFetchInProgress |
( |
| ) |
|
|
protectedpure virtual |
If someone is already fetching this resource, should we yield to them and try again later? If so, return true. Otherwise, if we must fetch the resource regardless, return false.
This will first try to acquire lock and triggers fetch by calling StartFetch() if successful. calls Finalize(true, false), if it fails to acquire lock, and deletes this.
virtual void net_instaweb::AsyncFetchWithLock::StartFetch |
( |
UrlAsyncFetcher * |
fetcher, |
|
|
MessageHandler * |
handler |
|
) |
| |
|
protectedpure virtual |
The documentation for this class was generated from the following file: