OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const { | 146 DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const { |
147 base::DictionaryValue* dict = new base::DictionaryValue(); | 147 base::DictionaryValue* dict = new base::DictionaryValue(); |
148 // Use strings to avoid overflow. base::Value only supports 32-bit integers. | 148 // Use strings to avoid overflow. base::Value only supports 32-bit integers. |
149 dict->SetString("session_received_content_length", | 149 dict->SetString("session_received_content_length", |
150 base::Int64ToString(total_received_bytes_)); | 150 base::Int64ToString(total_received_bytes_)); |
151 dict->SetString("session_original_content_length", | 151 dict->SetString("session_original_content_length", |
152 base::Int64ToString(total_original_received_bytes_)); | 152 base::Int64ToString(total_original_received_bytes_)); |
153 return dict; | 153 return dict; |
154 } | 154 } |
155 | 155 |
156 void DataReductionProxyNetworkDelegate::OnBeforeURLRequestInternal( | |
157 net::URLRequest* request, | |
158 const net::CompletionCallback& callback, | |
159 GURL* new_url) { | |
160 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { | |
tbansal1
2016/05/04 05:16:57
braces not needed.
tbansal1
2016/05/04 05:16:57
Is request guaranteed to be non-null here? I think
megjablon
2016/05/06 22:13:00
Yes, see https://code.google.com/p/chromium/codese
megjablon
2016/05/06 22:13:00
Done.
| |
161 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame(false); | |
162 } | |
163 } | |
164 | |
156 void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal( | 165 void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal( |
157 net::URLRequest* request, | 166 net::URLRequest* request, |
158 const net::ProxyInfo& proxy_info, | 167 const net::ProxyInfo& proxy_info, |
159 net::HttpRequestHeaders* headers) { | 168 net::HttpRequestHeaders* headers) { |
160 DCHECK(data_reduction_proxy_config_); | 169 DCHECK(data_reduction_proxy_config_); |
161 | 170 |
162 if (proxy_info.is_empty()) | 171 if (proxy_info.is_empty()) |
tbansal1
2016/05/04 05:16:56
Is it useful to add a check here that proxy_info.p
megjablon
2016/05/06 22:13:00
Done.
| |
163 return; | 172 return; |
164 | 173 |
165 if (data_reduction_proxy_io_data_ && | 174 if (data_reduction_proxy_io_data_ && |
166 data_reduction_proxy_io_data_->lofi_decider() && request) { | 175 data_reduction_proxy_io_data_->lofi_decider() && request) { |
167 LoFiDecider* lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); | 176 LoFiDecider* lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); |
168 bool is_using_lofi_mode = lofi_decider->MaybeAddLoFiDirectiveToHeaders( | 177 bool is_using_lofi_mode = lofi_decider->MaybeAddLoFiDirectiveToHeaders( |
169 *request, headers, proxy_info.proxy_server(), | 178 *request, headers, proxy_info.proxy_server(), |
170 data_reduction_proxy_config_); | 179 data_reduction_proxy_config_); |
171 | 180 |
172 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { | 181 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { |
173 // TODO(megjablon): Need to switch to per page. | |
tbansal1
2016/05/04 01:46:23
Why is this TODO gone? Seems like the Lo-Fi state
megjablon
2016/05/04 03:02:44
This isn't going to be fixable. This TODO was adde
tbansal1
2016/05/04 05:16:57
Acknowledged.
| |
174 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( | 182 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( |
175 is_using_lofi_mode); | 183 is_using_lofi_mode); |
176 } | 184 } |
177 } | 185 } |
178 | 186 |
179 if (data_reduction_proxy_request_options_) { | 187 if (data_reduction_proxy_request_options_) { |
180 data_reduction_proxy_request_options_->MaybeAddRequestHeader( | 188 data_reduction_proxy_request_options_->MaybeAddRequestHeader( |
181 proxy_info.proxy_server(), headers); | 189 proxy_info.proxy_server(), headers); |
182 } | 190 } |
183 } | 191 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 } | 322 } |
315 } | 323 } |
316 | 324 |
317 void DataReductionProxyNetworkDelegate::RecordLoFiTransformationType( | 325 void DataReductionProxyNetworkDelegate::RecordLoFiTransformationType( |
318 LoFiTransformationType type) { | 326 LoFiTransformationType type) { |
319 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.LoFi.TransformationType", type, | 327 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.LoFi.TransformationType", type, |
320 LO_FI_TRANSFORMATION_TYPES_INDEX_BOUNDARY); | 328 LO_FI_TRANSFORMATION_TYPES_INDEX_BOUNDARY); |
321 } | 329 } |
322 | 330 |
323 } // namespace data_reduction_proxy | 331 } // namespace data_reduction_proxy |
OLD | NEW |