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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc

Issue 1380933002: Set exp id in the CP header if user is in Lo-Fi control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, addressed comment Created 5 years, 2 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
index 24be61b0998bdf0d2ccf1d351a23bc011451d626..6a52cdf18446ea1cabf8224b51949a8aadafcf55 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
@@ -4,6 +4,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h"
+#include <algorithm>
#include <vector>
#include "base/bind.h"
@@ -49,6 +50,7 @@ const char kPatchNumberHeaderOption[] = "p";
const char kClientHeaderOption[] = "c";
const char kLoFiHeaderOption[] = "q";
const char kExperimentsOption[] = "exp";
+const char kLoFiExperimentID[] = "lofi_active_control";
// The empty version for the authentication protocol. Currently used by
// Android webview.
@@ -182,6 +184,29 @@ void DataReductionProxyRequestOptions::MayRegenerateHeaderBasedOnLoFi(
RegenerateRequestHeaderValue();
return;
}
+
+ // User was not part of Lo-Fi active control experiment, but now is.
+ if (std::find(experiments_.begin(), experiments_.end(),
+ std::string(kLoFiExperimentID)) == experiments_.end() &&
+ data_reduction_proxy_config_->IsInLoFiActiveControlExperiment()) {
+ experiments_.push_back(kLoFiExperimentID);
+ RegenerateRequestHeaderValue();
+ DCHECK(std::find(experiments_.begin(), experiments_.end(),
+ kLoFiExperimentID) != experiments_.end());
+ return;
+ }
+
+ // User was part of Lo-Fi active control experiment, but now is not.
+ auto it = std::find(experiments_.begin(), experiments_.end(),
+ std::string(kLoFiExperimentID));
+ if (it != experiments_.end() &&
+ !data_reduction_proxy_config_->IsInLoFiActiveControlExperiment()) {
+ experiments_.erase(it);
+ RegenerateRequestHeaderValue();
+ DCHECK(std::find(experiments_.begin(), experiments_.end(),
+ std::string(kLoFiExperimentID)) == experiments_.end());
+ return;
+ }
}
void DataReductionProxyRequestOptions::UpdateExperiments() {

Powered by Google App Engine
This is Rietveld 408576698