Page Speed Optimization Libraries  1.8.31.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Static Public Attributes
net_instaweb::ImageUrlEncoder Class Reference

#include "image_url_encoder.h"

List of all members.

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 void SetLibWebpLevel (const RewriteOptions &options, const RequestProperties &request_properties, ResourceContext *resource_context)
static void SetWebpAndMobileUserAgent (const RewriteDriver &driver, ResourceContext *context)
static bool IsWebpRewrittenUrl (const GoogleUrl &gurl)
 Determines whether the given URL is a pagespeed-rewritten webp URL.
static void SetSmallScreen (const RewriteDriver &driver, ResourceContext *context)
static void SetUserAgentScreenResolution (RewriteDriver *driver, ResourceContext *context)
 Set context for screen resolution.
static GoogleString CacheKeyFromResourceContext (const ResourceContext &resource_context)
 Helper function to generate Metadata cache key from ResourceContext.
static bool HasDimensions (const ResourceContext &data)
static bool HasValidDimensions (const ImageDim &dims)
static bool HasDimension (const ResourceContext &data)
static bool HasValidDimension (const ImageDim &dims)

Static Public Attributes

static const int kSmallScreenSizeThresholdArea

Detailed Description

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.


Member Function Documentation

static void net_instaweb::ImageUrlEncoder::SetLibWebpLevel ( const RewriteOptions options,
const RequestProperties request_properties,
ResourceContext *  resource_context 
) [static]

Set LibWebp level according to the user agent.

Todo:
TODO(poojatandon): Pass a user agent object with its webp-cabaple bits pre-analyzed (not just the string from the request headers), since checking webp level related code doesn't belong here.
static void net_instaweb::ImageUrlEncoder::SetSmallScreen ( const RewriteDriver driver,
ResourceContext *  context 
) [static]

Flag whether this device has a small screen, which determines what Jpeg/WebP quality to use.

static void net_instaweb::ImageUrlEncoder::SetWebpAndMobileUserAgent ( const RewriteDriver driver,
ResourceContext *  context 
) [static]

Sets webp and mobile capability in resource context.

The parameters to this method are urls, rewrite options & resource context. Since rewrite options are not changed, we have passed const reference and resource context is modified and can be NULL, hence we pass as a pointer.


Member Data Documentation

Area threshold that determines whether we use Image*RecompressionQualityForSmallScreens to set WebP/Jpeg quality. The intent is for phones and small tablets (e.g., Nexus 7) to be in.


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