| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/fetch/ClientHintsPreferences.h" | 6 #include "core/fetch/ClientHintsPreferences.h" |
| 7 | 7 |
| 8 #include "core/fetch/ResourceFetcher.h" |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/network/HTTPParsers.h" | 10 #include "platform/network/HTTPParsers.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 void handleAcceptClientHintsHeader(const String& headerValue, ClientHintsPrefere
nces& preferences) | 14 void handleAcceptClientHintsHeader(const String& headerValue, ClientHintsPrefere
nces& preferences, ResourceFetcher* fetcher) |
| 14 { | 15 { |
| 15 if (!RuntimeEnabledFeatures::clientHintsEnabled() || headerValue.isEmpty()) | 16 if (!RuntimeEnabledFeatures::clientHintsEnabled() || headerValue.isEmpty()) |
| 16 return; | 17 return; |
| 17 CommaDelimitedHeaderSet acceptCH; | 18 CommaDelimitedHeaderSet acceptCH; |
| 18 parseCommaDelimitedHeader(headerValue, acceptCH); | 19 parseCommaDelimitedHeader(headerValue, acceptCH); |
| 19 if (acceptCH.contains("dpr")) | 20 if (acceptCH.contains("dpr")) { |
| 21 if (fetcher) |
| 22 fetcher->context().countClientHintsDPR(); |
| 20 preferences.setShouldSendDPR(true); | 23 preferences.setShouldSendDPR(true); |
| 24 } |
| 21 | 25 |
| 22 if (acceptCH.contains("width")) | 26 if (acceptCH.contains("width")) { |
| 27 if (fetcher) |
| 28 fetcher->context().countClientHintsResourceWidth(); |
| 23 preferences.setShouldSendResourceWidth(true); | 29 preferences.setShouldSendResourceWidth(true); |
| 30 } |
| 24 | 31 |
| 25 if (acceptCH.contains("viewport-width")) | 32 if (acceptCH.contains("viewport-width")) { |
| 33 if (fetcher) |
| 34 fetcher->context().countClientHintsViewportWidth(); |
| 26 preferences.setShouldSendViewportWidth(true); | 35 preferences.setShouldSendViewportWidth(true); |
| 36 } |
| 27 } | 37 } |
| 28 | 38 |
| 29 } | 39 } |
| OLD | NEW |