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

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

Issue 951303003: Added basic client hints support. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed expected files Created 5 years, 10 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/ResourceFetcher.h ('k') | Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceFetcher.cpp
diff --git a/Source/core/fetch/ResourceFetcher.cpp b/Source/core/fetch/ResourceFetcher.cpp
index 97f4708fcefe8d0b7f42ec42487333e639b23beb..9ffcd8963beda6ce98d17ba4fae6a7ed51e2b8cf 100644
--- a/Source/core/fetch/ResourceFetcher.cpp
+++ b/Source/core/fetch/ResourceFetcher.cpp
@@ -46,6 +46,7 @@
#include "core/fetch/UniqueIdentifier.h"
#include "core/fetch/XSLStyleSheetResource.h"
#include "core/frame/FrameHost.h"
+#include "core/frame/FrameView.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
@@ -720,6 +721,7 @@ ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
TRACE_EVENT0("blink", "ResourceFetcher::requestResource");
upgradeInsecureRequest(request);
+ addClientHintsIfNeccessary(request);
KURL url = request.resourceRequest().url();
@@ -933,6 +935,19 @@ void ResourceFetcher::upgradeInsecureRequest(FetchRequest& fetchRequest)
}
}
+void ResourceFetcher::addClientHintsIfNeccessary(FetchRequest& fetchRequest)
+{
+ if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document || !frame())
+ return;
+
+ if (frame()->shouldSendDPRHint())
+ fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicString(String::number(m_document->devicePixelRatio())));
+
+ // FIXME: Send the RW hint based on the actual resource width, when we have it.
+ if (frame()->shouldSendRWHint() && frame()->view())
+ fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicString(String::number(frame()->view()->viewportWidth())));
+}
+
ResourcePtr<Resource> ResourceFetcher::createResourceForRevalidation(const FetchRequest& request, Resource* resource)
{
ASSERT(resource);
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698