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

Unified Diff: components/data_reduction_proxy/content/browser/content_lofi_decider.cc

Issue 1455333004: Add "q=preview" directive on main frame requests on poor networks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@deciderAddLoFiHeader
Patch Set: limit flag channels Created 5 years, 1 month 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
Index: components/data_reduction_proxy/content/browser/content_lofi_decider.cc
diff --git a/components/data_reduction_proxy/content/browser/content_lofi_decider.cc b/components/data_reduction_proxy/content/browser/content_lofi_decider.cc
index 991b00e1e3e4a222d86559ef529e7ddc3dfaf7a0..d1d10d224c5a097bec4514d4efd09110617601cf 100644
--- a/components/data_reduction_proxy/content/browser/content_lofi_decider.cc
+++ b/components/data_reduction_proxy/content/browser/content_lofi_decider.cc
@@ -9,6 +9,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "content/public/browser/resource_request_info.h"
+#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
namespace data_reduction_proxy {
@@ -47,6 +48,10 @@ bool ContentLoFiDecider::MaybeAddLoFiDirectiveToHeaders(
bool lofi_enabled_via_flag_or_field_trial =
params::IsLoFiOnViaFlags() || params::IsIncludedInLoFiEnabledFieldTrial();
+ bool lofi_preview_via_flag_or_field_trial =
+ params::AreLoFiPreviewsEnabledViaFlags() ||
+ params::IsIncludedInLoFiPreviewFieldTrial();
+
std::string header_value;
// User is using Lo-Fi and not part of the "Control" group.
@@ -56,7 +61,16 @@ bool ContentLoFiDecider::MaybeAddLoFiDirectiveToHeaders(
headers->RemoveHeader(chrome_proxy_header());
header_value += ", ";
}
- header_value += chrome_proxy_lo_fi_directive();
+
+ // Only add the "q=preview" directive on mainframe requests. Otherwise,
+ // add "q=low"
+ if (lofi_preview_via_flag_or_field_trial &&
+ (request.load_flags() & net::LOAD_MAIN_FRAME)) {
+ header_value += chrome_proxy_lo_fi_preview_directive();
+ } else {
+ header_value += chrome_proxy_lo_fi_directive();
+ }
+
headers->SetHeader(chrome_proxy_header(), header_value);
return true;
}
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698