Page Speed Optimization Libraries
1.8.31.3
|
#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 | 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 |
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).
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.
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.