| 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 #ifndef ClientHintsPreferences_h | 5 #ifndef ClientHintsPreferences_h |
| 6 #define ClientHintsPreferences_h | 6 #define ClientHintsPreferences_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class ResourceFetcher; | |
| 15 | |
| 16 class CORE_EXPORT ClientHintsPreferences { | 14 class CORE_EXPORT ClientHintsPreferences { |
| 17 DISALLOW_NEW(); | 15 DISALLOW_NEW(); |
| 18 | 16 |
| 19 public: | 17 public: |
| 18 class Context { |
| 19 public: |
| 20 virtual void countClientHintsDPR() = 0; |
| 21 virtual void countClientHintsResourceWidth() = 0; |
| 22 virtual void countClientHintsViewportWidth() = 0; |
| 23 |
| 24 protected: |
| 25 virtual ~Context() {} |
| 26 }; |
| 27 |
| 20 ClientHintsPreferences(); | 28 ClientHintsPreferences(); |
| 21 | 29 |
| 22 void updateFrom(const ClientHintsPreferences&); | 30 void updateFrom(const ClientHintsPreferences&); |
| 23 void updateFromAcceptClientHintsHeader(const String& headerValue, | 31 void updateFromAcceptClientHintsHeader(const String& headerValue, Context*); |
| 24 ResourceFetcher*); | |
| 25 | 32 |
| 26 bool shouldSendDPR() const { return m_shouldSendDPR; } | 33 bool shouldSendDPR() const { return m_shouldSendDPR; } |
| 27 void setShouldSendDPR(bool should) { m_shouldSendDPR = should; } | 34 void setShouldSendDPR(bool should) { m_shouldSendDPR = should; } |
| 28 | 35 |
| 29 bool shouldSendResourceWidth() const { return m_shouldSendResourceWidth; } | 36 bool shouldSendResourceWidth() const { return m_shouldSendResourceWidth; } |
| 30 void setShouldSendResourceWidth(bool should) { | 37 void setShouldSendResourceWidth(bool should) { |
| 31 m_shouldSendResourceWidth = should; | 38 m_shouldSendResourceWidth = should; |
| 32 } | 39 } |
| 33 | 40 |
| 34 bool shouldSendViewportWidth() const { return m_shouldSendViewportWidth; } | 41 bool shouldSendViewportWidth() const { return m_shouldSendViewportWidth; } |
| 35 void setShouldSendViewportWidth(bool should) { | 42 void setShouldSendViewportWidth(bool should) { |
| 36 m_shouldSendViewportWidth = should; | 43 m_shouldSendViewportWidth = should; |
| 37 } | 44 } |
| 38 | 45 |
| 39 private: | 46 private: |
| 40 bool m_shouldSendDPR; | 47 bool m_shouldSendDPR; |
| 41 bool m_shouldSendResourceWidth; | 48 bool m_shouldSendResourceWidth; |
| 42 bool m_shouldSendViewportWidth; | 49 bool m_shouldSendViewportWidth; |
| 43 }; | 50 }; |
| 44 | 51 |
| 45 } // namespace blink | 52 } // namespace blink |
| 46 | 53 |
| 47 #endif | 54 #endif |
| OLD | NEW |