Page Speed Optimization Libraries
1.11.33.2
|
#include "render_blocking_html_computation.h"
Public Member Functions | |
RenderBlockingHtmlComputation (RewriteDriver *parent_driver) | |
void | Compute (const GoogleString &url) |
Protected Member Functions | |
virtual void | SetupFilters (RewriteDriver *child_driver)=0 |
virtual void | Done (bool success)=0 |
This class helps one perform a background computation based on an HTML webpage at a given URL, while blocking rendering on parent RewriteDriver until the computation succeeds. Basic usage is as follows: 1) Subclass this, overriding two methods: a) SetupFilters to add filters to child_driver. b) Done() to pass result on to the client. 2) In the parent, create a new object for the computation, call Compute(), and use result it passed from its Done in RenderDone(). The object will self-delete.
void net_instaweb::RenderBlockingHtmlComputation::Compute | ( | const GoogleString & | url | ) |
Tries to fetch a webpage on url. If fetching is successful, it will create a new RewriteDriver child_driver with same options as parent_driver but no filters, call SetupFilters on it, then pass the document through it, then call Done(true). If something fails before that, Done(false) will be called instead. this object will be deleted after the call completes.
Rendering on the rewrite driver will be disabled until Done() is invoked.
|
protectedpure virtual |
Override this to extract and save the computation result. The object will be deleted after this returns.
Warning: this method can run in a variety of threads, so make sure you properly lock access to data this updates.