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 DCHECK(request); | |
tbansal1
2016/05/06 23:36:51
This DCHECK is not necessary. If |request| is null
megjablon
2016/05/07 00:29:08
Done.
| |
161 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) | |
162 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame(false); | |
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()) |
163 return; | 172 return; |
173 if (!proxy_info.proxy_server().is_valid()) | |
174 return; | |
175 if (proxy_info.proxy_server().is_direct()) | |
176 return; | |
177 if (proxy_info.proxy_server().host_port_pair().IsEmpty()) | |
178 return; | |
179 if (!data_reduction_proxy_config_->IsDataReductionProxy( | |
180 proxy_info.proxy_server().host_port_pair(), nullptr)) { | |
181 return; | |
182 } | |
164 | 183 |
165 if (data_reduction_proxy_io_data_ && | 184 if (data_reduction_proxy_io_data_ && |
166 data_reduction_proxy_io_data_->lofi_decider() && request) { | 185 data_reduction_proxy_io_data_->lofi_decider() && request) { |
167 LoFiDecider* lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); | 186 LoFiDecider* lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); |
168 bool is_using_lofi_mode = lofi_decider->MaybeAddLoFiDirectiveToHeaders( | 187 bool is_using_lofi_mode = |
169 *request, headers, proxy_info.proxy_server(), | 188 lofi_decider->MaybeAddLoFiDirectiveToHeaders(*request, headers); |
170 data_reduction_proxy_config_); | |
171 | 189 |
172 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { | 190 if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { |
173 // TODO(megjablon): Need to switch to per page. | |
174 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( | 191 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( |
175 is_using_lofi_mode); | 192 is_using_lofi_mode); |
176 } | 193 } |
177 } | 194 } |
178 | 195 |
179 if (data_reduction_proxy_request_options_) { | 196 if (data_reduction_proxy_request_options_) { |
180 data_reduction_proxy_request_options_->MaybeAddRequestHeader( | 197 data_reduction_proxy_request_options_->AddRequestHeader(headers); |
181 proxy_info.proxy_server(), headers); | |
182 } | 198 } |
183 } | 199 } |
184 | 200 |
185 void DataReductionProxyNetworkDelegate::OnCompletedInternal( | 201 void DataReductionProxyNetworkDelegate::OnCompletedInternal( |
186 net::URLRequest* request, | 202 net::URLRequest* request, |
187 bool started) { | 203 bool started) { |
188 DCHECK(request); | 204 DCHECK(request); |
189 if (data_reduction_proxy_bypass_stats_) | 205 if (data_reduction_proxy_bypass_stats_) |
190 data_reduction_proxy_bypass_stats_->OnUrlRequestCompleted(request, started); | 206 data_reduction_proxy_bypass_stats_->OnUrlRequestCompleted(request, started); |
191 | 207 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 } | 330 } |
315 } | 331 } |
316 | 332 |
317 void DataReductionProxyNetworkDelegate::RecordLoFiTransformationType( | 333 void DataReductionProxyNetworkDelegate::RecordLoFiTransformationType( |
318 LoFiTransformationType type) { | 334 LoFiTransformationType type) { |
319 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.LoFi.TransformationType", type, | 335 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.LoFi.TransformationType", type, |
320 LO_FI_TRANSFORMATION_TYPES_INDEX_BOUNDARY); | 336 LO_FI_TRANSFORMATION_TYPES_INDEX_BOUNDARY); |
321 } | 337 } |
322 | 338 |
323 } // namespace data_reduction_proxy | 339 } // namespace data_reduction_proxy |
OLD | NEW |