Page Speed Optimization Libraries
1.13.35.1
|
#include "device_properties.h"
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 | SupportsWebpAnimated () const |
bool | IsBot () const |
bool | AcceptsGzip () const |
UserAgentMatcher::DeviceType | GetDeviceType () const |
bool | IsMobile () const |
bool | IsTablet () const |
bool | ForbidWebpInlining () const |
bool | RequestsSaveData () const |
bool | HasViaHeader () const |
Static Public Attributes | |
static const int | kMediumScreenWidthThreshold = 720 |
static const int | kLargeScreenWidthThreshold = 1500 |
Friends | |
class | ImageRewriteTest |
class | RequestProperties |
This class keeps track of the device properties of the client, which are for the most part learned from the UserAgent string.
void net_instaweb::DeviceProperties::ParseRequestHeaders | ( | const RequestHeaders & | request_headers | ) |
Set device-based properties that are capture in the request headers (eg. the Accept: header).
bool net_instaweb::DeviceProperties::SupportsWebpInPlace | ( | ) | const |
SupportsWebpInPlace indicates we saw an Accept: image/webp header, and can rewrite the request in place (using Vary: accept in the result headers, etc.).
bool net_instaweb::DeviceProperties::SupportsWebpRewrittenUrls | ( | ) | const |
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.