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

#include "device_properties.h"

List of all members.

Public Types

enum  ImageQualityPreference { kImageQualityDefault, kImageQualityLow, kImageQualityMedium, kImageQualityHigh }

Public Member Functions

 DeviceProperties (UserAgentMatcher *matcher)
void SetUserAgent (const StringPiece &user_agent_string)
void ParseRequestHeaders (const RequestHeaders &request_headers)
bool SupportsImageInlining () const
bool SupportsLazyloadImages () const
bool SupportsCriticalCss () const
bool SupportsCriticalImagesBeacon () const
bool SupportsJsDefer (bool enable_mobile) const
bool SupportsWebpInPlace () const
bool SupportsWebpRewrittenUrls () const
bool SupportsWebpLosslessAlpha () const
bool IsBot () const
bool SupportsSplitHtml (bool enable_mobile) const
bool CanPreloadResources () const
bool GetScreenResolution (int *width, int *height) const
UserAgentMatcher::DeviceType GetDeviceType () const
bool IsMobile () const
void SetPreferredImageQualities (const std::vector< int > *webp, const std::vector< int > *jpeg)
bool GetPreferredImageQualities (ImageQualityPreference preference, int *webp, int *jpeg) const
 Returns true iff WebP and Jpeg image quality are set for the preference.

Static Public Member Functions

static int GetPreferredImageQualityCount ()

Static Public Attributes

static const int kMediumScreenWidthThreshold = 720
static const int kLargeScreenWidthThreshold = 1500

Friends

class ImageRewriteTest
class RequestProperties

Detailed Description

This class keeps track of the device properties of the client, which are for the most part learned from the UserAgent string.


Member Enumeration Documentation

Enumerator:
kImageQualityDefault 

Server uses its own default image quality.

kImageQualityLow 

The request asks for low image quality.

kImageQualityMedium 

The request asks for medium image quality.

kImageQualityHigh 

The request asks for high image quality.


Member Function Documentation

void net_instaweb::DeviceProperties::ParseRequestHeaders ( const RequestHeaders &  request_headers)

Set device-based properties that are capture in the request headers (eg. the Accept: header).

void net_instaweb::DeviceProperties::SetPreferredImageQualities ( const std::vector< int > *  webp,
const std::vector< int > *  jpeg 
)

Does not own the vectors. Callers must ensure the lifetime of vectors exceeds that of the DeviceProperties.

SupportsWebpInPlace indicates we saw an Accept: image/webp header, and can rewrite the request in place (using Vary: accept in the result headers, etc.).

SupportsWebpRewrittenUrls indicates that the device can handle webp so long as the url changes - either we know this based on user agent, or we got an Accept header. We can't tell a proxy cache to distinguish this case using Vary: accept in the result headers, as we can't guarantee we'll see such a header, ever. So we need to Vary: user-agent or cache-control: private, and thus restrict it to rewritten urls.


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