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 "platform/loader/fetch/ClientHintsPreferences.h" | 5 #include "platform/loader/fetch/ClientHintsPreferences.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/network/HTTPParsers.h" | 8 #include "platform/network/HTTPParsers.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 ClientHintsPreferences::ClientHintsPreferences() | 12 ClientHintsPreferences::ClientHintsPreferences() |
13 : should_send_dpr_(false), | 13 : should_send_device_ram_(false), |
14 should_send_dpr_(false), | |
14 should_send_resource_width_(false), | 15 should_send_resource_width_(false), |
15 should_send_viewport_width_(false) {} | 16 should_send_viewport_width_(false) {} |
16 | 17 |
17 void ClientHintsPreferences::UpdateFrom( | 18 void ClientHintsPreferences::UpdateFrom( |
18 const ClientHintsPreferences& preferences) { | 19 const ClientHintsPreferences& preferences) { |
20 should_send_device_ram_ = preferences.should_send_device_ram_; | |
19 should_send_dpr_ = preferences.should_send_dpr_; | 21 should_send_dpr_ = preferences.should_send_dpr_; |
20 should_send_resource_width_ = preferences.should_send_resource_width_; | 22 should_send_resource_width_ = preferences.should_send_resource_width_; |
21 should_send_viewport_width_ = preferences.should_send_viewport_width_; | 23 should_send_viewport_width_ = preferences.should_send_viewport_width_; |
22 } | 24 } |
23 | 25 |
24 void ClientHintsPreferences::UpdateFromAcceptClientHintsHeader( | 26 void ClientHintsPreferences::UpdateFromAcceptClientHintsHeader( |
25 const String& header_value, | 27 const String& header_value, |
26 Context* context) { | 28 Context* context) { |
27 if (!RuntimeEnabledFeatures::clientHintsEnabled() || header_value.IsEmpty()) | 29 if (!RuntimeEnabledFeatures::clientHintsEnabled() || header_value.IsEmpty()) |
28 return; | 30 return; |
29 | 31 |
30 CommaDelimitedHeaderSet accept_client_hints_header; | 32 CommaDelimitedHeaderSet accept_client_hints_header; |
31 ParseCommaDelimitedHeader(header_value, accept_client_hints_header); | 33 ParseCommaDelimitedHeader(header_value, accept_client_hints_header); |
34 if (RuntimeEnabledFeatures::deviceRAMHeaderEnabled()) { | |
35 if (accept_client_hints_header.Contains("device-ram")) { | |
Yoav Weiss
2017/05/26 20:48:15
Can you `&&` these two conditions?
fmeawad
2017/05/30 17:20:59
Done.
| |
36 if (context) | |
37 context->CountClientHintsDeviceRAM(); | |
38 should_send_device_ram_ = true; | |
39 } | |
40 } | |
41 | |
32 if (accept_client_hints_header.Contains("dpr")) { | 42 if (accept_client_hints_header.Contains("dpr")) { |
33 if (context) | 43 if (context) |
34 context->CountClientHintsDPR(); | 44 context->CountClientHintsDPR(); |
35 should_send_dpr_ = true; | 45 should_send_dpr_ = true; |
36 } | 46 } |
37 | 47 |
38 if (accept_client_hints_header.Contains("width")) { | 48 if (accept_client_hints_header.Contains("width")) { |
39 if (context) | 49 if (context) |
40 context->CountClientHintsResourceWidth(); | 50 context->CountClientHintsResourceWidth(); |
41 should_send_resource_width_ = true; | 51 should_send_resource_width_ = true; |
42 } | 52 } |
43 | 53 |
44 if (accept_client_hints_header.Contains("viewport-width")) { | 54 if (accept_client_hints_header.Contains("viewport-width")) { |
45 if (context) | 55 if (context) |
46 context->CountClientHintsViewportWidth(); | 56 context->CountClientHintsViewportWidth(); |
47 should_send_viewport_width_ = true; | 57 should_send_viewport_width_ = true; |
48 } | 58 } |
49 } | 59 } |
50 | 60 |
51 } // namespace blink | 61 } // namespace blink |
OLD | NEW |