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

Unified Diff: Source/core/fetch/ClientHintsPreferences.cpp

Issue 1287783003: Make ClientHintsPreferences class work like a class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fetch/ClientHintsPreferences.h ('k') | Source/core/fetch/ClientHintsPreferencesTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ClientHintsPreferences.cpp
diff --git a/Source/core/fetch/ClientHintsPreferences.cpp b/Source/core/fetch/ClientHintsPreferences.cpp
index 0a31a59a2607ab9399af9da40bc6ce313b73f79e..ac9f2bf009216ea4941d58244c8cd8f67153ef8b 100644
--- a/Source/core/fetch/ClientHintsPreferences.cpp
+++ b/Source/core/fetch/ClientHintsPreferences.cpp
@@ -11,28 +11,43 @@
namespace blink {
-void handleAcceptClientHintsHeader(const String& headerValue, ClientHintsPreferences& preferences, ResourceFetcher* fetcher)
+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 acceptCH;
- parseCommaDelimitedHeader(headerValue, acceptCH);
- if (acceptCH.contains("dpr")) {
+
+ CommaDelimitedHeaderSet acceptClientHintsHeader;
+ parseCommaDelimitedHeader(headerValue, acceptClientHintsHeader);
+ if (acceptClientHintsHeader.contains("dpr")) {
if (fetcher)
fetcher->context().countClientHintsDPR();
- preferences.setShouldSendDPR(true);
+ m_shouldSendDPR = true;
}
- if (acceptCH.contains("width")) {
+ if (acceptClientHintsHeader.contains("width")) {
if (fetcher)
fetcher->context().countClientHintsResourceWidth();
- preferences.setShouldSendResourceWidth(true);
+ m_shouldSendResourceWidth = true;
}
- if (acceptCH.contains("viewport-width")) {
+ if (acceptClientHintsHeader.contains("viewport-width")) {
if (fetcher)
fetcher->context().countClientHintsViewportWidth();
- preferences.setShouldSendViewportWidth(true);
+ m_shouldSendViewportWidth = true;
}
}
« no previous file with comments | « Source/core/fetch/ClientHintsPreferences.h ('k') | Source/core/fetch/ClientHintsPreferencesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698