Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ClientHintsPreferences.cpp

Issue 2584423002: Loading: move core/fetch to platform/loader/fetch (Closed)
Patch Set: another try Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/fetch/ClientHintsPreferences.h"
6
7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/network/HTTPParsers.h"
9
10 namespace blink {
11
12 ClientHintsPreferences::ClientHintsPreferences()
13 : m_shouldSendDPR(false),
14 m_shouldSendResourceWidth(false),
15 m_shouldSendViewportWidth(false) {}
16
17 void ClientHintsPreferences::updateFrom(
18 const ClientHintsPreferences& preferences) {
19 m_shouldSendDPR = preferences.m_shouldSendDPR;
20 m_shouldSendResourceWidth = preferences.m_shouldSendResourceWidth;
21 m_shouldSendViewportWidth = preferences.m_shouldSendViewportWidth;
22 }
23
24 void ClientHintsPreferences::updateFromAcceptClientHintsHeader(
25 const String& headerValue,
26 Context* context) {
27 if (!RuntimeEnabledFeatures::clientHintsEnabled() || headerValue.isEmpty())
28 return;
29
30 CommaDelimitedHeaderSet acceptClientHintsHeader;
31 parseCommaDelimitedHeader(headerValue, acceptClientHintsHeader);
32 if (acceptClientHintsHeader.contains("dpr")) {
33 if (context)
34 context->countClientHintsDPR();
35 m_shouldSendDPR = true;
36 }
37
38 if (acceptClientHintsHeader.contains("width")) {
39 if (context)
40 context->countClientHintsResourceWidth();
41 m_shouldSendResourceWidth = true;
42 }
43
44 if (acceptClientHintsHeader.contains("viewport-width")) {
45 if (context)
46 context->countClientHintsViewportWidth();
47 m_shouldSendViewportWidth = true;
48 }
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698