Page Speed Optimization Libraries
1.2.24.1
|
#include "image_url_encoder.h"
Public Member Functions | |
virtual void | Encode (const StringVector &urls, const ResourceContext *dim, GoogleString *rewritten_url) const |
virtual bool | Decode (const StringPiece &url_segment, StringVector *urls, ResourceContext *dim, MessageHandler *handler) const |
Static Public Member Functions | |
static bool | HasDimensions (const ResourceContext &data) |
static bool | HasValidDimensions (const ImageDim &dims) |
static bool | HasDimension (const ResourceContext &data) |
static bool | HasValidDimension (const ImageDim &dims) |
This class implements the encoding of image urls with optional additional dimension metadata. It basically prepends characters indicating image dimensions on the page, webp eligibility, and mobile user agent eligibility (this information is conveyed in the ResourceContext). http://...path.../50x75xurl... No webp, image is 50x75 on page http://...path.../50x75wurl... Webp requested, image is 50x75 on page http://...path.../50x75mxurl... No webp, for mobile user agent, image is 50x75 on page http://...path.../50x75mwurl... Webp requested, for mobile user agent, image is 50x75 on page http://...path.../50xNxurl.. No webp, image is 50 wide, no height given http://...path.../50xNwurl... Webp, image is 50 wide, no height given http://...path.../Nx75xurl... No webp, image is 75 high, no width given http://...path.../Nx75wurl... Webp, image is 75 high, no width given. http://...path.../50xNmxurl.. No webp, image is 50 wide, mobile http://...path.../50xNmwurl... Webp, image is 50 wide, mobile http://...path.../Nx75mxurl... No webp, image is 75 high, mobile http://...path.../Nx75mwurl... Webp, image is 75 high, mobile http://...path.../xurl... Page does not specify both dimensions. No webp. http://...path.../wurl... Webp requested, page missing dimensions. http://...path.../xurl... Page does not specify any dimension. No webp. http://...path.../wurl... Webp requested, page missing either dimension. http://...path.../mxurl... No webp, for mobile user agent, page does not specify dimensions. http://...path.../mwurl... Webp requested, for mobile user agent, page missing dimensions.
virtual bool net_instaweb::ImageUrlEncoder::Decode | ( | const StringPiece & | url_segment, |
StringVector * | urls, | ||
ResourceContext * | out_data, | ||
MessageHandler * | handler | ||
) | const [virtual] |
Decode URLs from "url_segment". Note that there may be other meta-data encoded in url_segment, which this function will write into out_data, if present.
Reimplemented from net_instaweb::UrlSegmentEncoder.
virtual void net_instaweb::ImageUrlEncoder::Encode | ( | const StringVector & | urls, |
const ResourceContext * | data, | ||
GoogleString * | url_segment | ||
) | const [virtual] |
Encodes arbitrary text so it can be used in a url segment. A url segment must contain only characters that are legal in URLs, and exclude "/" and "." which are used for a higher level encoding scheme into which this must fit.
'data' is optional -- it can be NULL and it is up to the encoder to decide what to do.
Reimplemented from net_instaweb::UrlSegmentEncoder.