Chromium Code Reviews| 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..4bfc8ece5c13d3ac870b280b95df133f8afdc5b1 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[] = "LoFiControl"; |
| // The empty version for the authentication protocol. Currently used by |
| // Android webview. |
| @@ -169,33 +171,49 @@ void DataReductionProxyRequestOptions::MayRegenerateHeaderBasedOnLoFi( |
| !(request && request->load_flags() & net::LOAD_BYPASS_CACHE) && |
| data_reduction_proxy_config_->ShouldUseLoFiHeaderForRequests(); |
| - // Lo-Fi was not enabled, but now is. Add the header option. |
| + bool regenerate = false; |
|
megjablon
2015/10/01 18:54:44
Do we need this? It's more lines than just calling
tbansal1
2015/10/02 16:50:43
Done.
|
| + |
| if (lofi_.empty() && lofi_now_enabled) { |
| + // Lo-Fi was not enabled, but now is. Add the header option. |
| lofi_ = "low"; |
| - RegenerateRequestHeaderValue(); |
| - return; |
| + regenerate = true; |
| + } else if (!lofi_.empty() && !lofi_now_enabled) { |
| + // Lo-Fi was enabled, but no longer is. Remove the header option. |
| + lofi_ = std::string(); |
| + regenerate = true; |
| + } else if (std::find(experiments_.begin(), experiments_.end(), |
| + std::string(kLoFiExperimentID)) == experiments_.end() && |
| + data_reduction_proxy_config_->IsInLoFiControlExperiment()) { |
| + // User was not part of Lo-Fi control experiment, but now is. |
|
megjablon
2015/10/01 18:54:44
We also need the case where the user is part of th
tbansal1
2015/10/02 16:50:42
Done.
|
| + experiments_.push_back(kLoFiExperimentID); |
| + regenerate = true; |
| } |
| - // Lo-Fi was enabled, but no longer is. Remove the header option. |
| - if (!lofi_.empty() && !lofi_now_enabled) { |
| - lofi_ = std::string(); |
| + if (regenerate) |
| RegenerateRequestHeaderValue(); |
| - return; |
| - } |
| + DCHECK_IMPLIES(data_reduction_proxy_config_->IsInLoFiControlExperiment(), |
| + std::find(experiments_.begin(), experiments_.end(), |
| + kLoFiExperimentID) != experiments_.end()); |
| } |
| void DataReductionProxyRequestOptions::UpdateExperiments() { |
| + experiments_.clear(); |
|
megjablon
2015/10/01 18:54:44
Why is this needed? This is only called on initial
tbansal1
2015/10/02 16:50:43
Done.
|
| std::string experiments = |
| base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| data_reduction_proxy::switches::kDataReductionProxyExperiment); |
| - if (experiments.empty()) |
| + if (experiments.empty() && |
| + !data_reduction_proxy_config_->IsInLoFiControlExperiment()) { |
| return; |
| + } |
|
megjablon
2015/10/01 18:54:44
UpdateExperiments() is only called from Init(). Do
tbansal1
2015/10/02 16:50:43
Done.
|
| base::StringTokenizer experiment_tokenizer(experiments, ", "); |
| experiment_tokenizer.set_quote_chars("\""); |
| while (experiment_tokenizer.GetNext()) { |
| if (!experiment_tokenizer.token().empty()) |
| experiments_.push_back(experiment_tokenizer.token()); |
| } |
| + if (data_reduction_proxy_config_->IsInLoFiControlExperiment()) |
| + experiments_.push_back(kLoFiExperimentID); |
| + |
| RegenerateRequestHeaderValue(); |
| } |