Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
index 66037130cf252856d97c8c24965652c8d0f53139..63f14241d0ef3256e4a7acb618e6638a73a0532d 100644 |
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
@@ -609,6 +609,9 @@ void FrameFetchContext::AddClientHintsIfNecessary( |
if (!RuntimeEnabledFeatures::clientHintsEnabled() || !GetDocument()) |
return; |
+ bool should_send_device_ram = |
panicker
2017/05/05 17:19:30
also check if device-ram RunTimeFlagEnabled is en
fmeawad
2017/05/23 20:50:54
I don't think I need/should since ShouldSendDevice
|
+ GetDocument()->GetClientHintsPreferences().ShouldSendDeviceRam() || |
+ hints_preferences.ShouldSendDeviceRam(); |
bool should_send_dpr = |
GetDocument()->GetClientHintsPreferences().ShouldSendDPR() || |
hints_preferences.ShouldSendDPR(); |
@@ -619,6 +622,17 @@ void FrameFetchContext::AddClientHintsIfNecessary( |
GetDocument()->GetClientHintsPreferences().ShouldSendViewportWidth() || |
hints_preferences.ShouldSendViewportWidth(); |
+ if (should_send_device_ram) { |
panicker
2017/05/05 17:19:30
Nit: extract this math into a helper
Also makes un
fmeawad
2017/05/23 20:50:54
Done.
|
+ int physical_memory = Platform::Current()->AmountOfPhysicalMemoryMB(); |
+ int power = -1; |
+ while (physical_memory != 0) { |
+ physical_memory = physical_memory >> 1; |
+ power++; |
+ } |
+ request.AddHTTPHeaderField( |
+ "device-ram", AtomicString(String::Number((1 << power) / 1024.0))); |
+ } |
+ |
if (should_send_dpr) { |
request.AddHTTPHeaderField( |
"DPR", AtomicString(String::Number(GetDocument()->DevicePixelRatio()))); |