blob: d376f22952ddd8dfbf0e24d3de9c1d88e0e04b85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/fetch/ClientHintsPreferences.h"
#include "core/fetch/ResourceFetcher.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/network/HTTPParsers.h"
namespace blink {
ClientHintsPreferences::ClientHintsPreferences()
: m_shouldSendDPR(false)
, m_shouldSendResourceWidth(false)
, m_shouldSendViewportWidth(false)
{
}
void ClientHintsPreferences::updateFrom(const ClientHintsPreferences& preferences)
{
m_shouldSendDPR = preferences.m_shouldSendDPR;
m_shouldSendResourceWidth = preferences.m_shouldSendResourceWidth;
m_shouldSendViewportWidth = preferences.m_shouldSendViewportWidth;
}
void ClientHintsPreferences::updateFromAcceptClientHintsHeader(const String& headerValue, ResourceFetcher* fetcher)
{
if (!RuntimeEnabledFeatures::clientHintsEnabled() || headerValue.isEmpty())
return;
CommaDelimitedHeaderSet acceptClientHintsHeader;
parseCommaDelimitedHeader(headerValue, acceptClientHintsHeader);
if (acceptClientHintsHeader.contains("dpr")) {
if (fetcher)
fetcher->context().countClientHintsDPR();
m_shouldSendDPR = true;
}
if (acceptClientHintsHeader.contains("width")) {
if (fetcher)
fetcher->context().countClientHintsResourceWidth();
m_shouldSendResourceWidth = true;
}
if (acceptClientHintsHeader.contains("viewport-width")) {
if (fetcher)
fetcher->context().countClientHintsViewportWidth();
m_shouldSendViewportWidth = true;
}
}
} // namespace blink
|