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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed code review comments by asvitkine@. Created 6 years, 5 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 unified diff | Download patch
OLDNEW
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/browser/data_reduction_proxy_metrics.h " 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h "
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 DailyContentLengthUpdate original_; 289 DailyContentLengthUpdate original_;
290 DailyContentLengthUpdate received_; 290 DailyContentLengthUpdate received_;
291 }; 291 };
292 292
293 // Returns true if the request is bypassed by all configured data reduction 293 // Returns true if the request is bypassed by all configured data reduction
294 // proxies. It returns the bypass delay in delay_seconds (if not NULL). If 294 // proxies. It returns the bypass delay in delay_seconds (if not NULL). If
295 // the request is bypassed by more than one proxy, delay_seconds returns 295 // the request is bypassed by more than one proxy, delay_seconds returns
296 // shortest delay. 296 // shortest delay.
297 bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) { 297 bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) {
298 // TODO(bengr): Add support for other data reduction proxy configurations. 298 // TODO(bengr): Add support for other data reduction proxy configurations.
299 #if defined(SPDY_PROXY_AUTH_ORIGIN) 299 // TODO(kundaji): Reuse params associated with profile instead of creating a
300 // new one here.
300 DataReductionProxyParams params( 301 DataReductionProxyParams params(
301 DataReductionProxyParams::kAllowed | 302 DataReductionProxyParams::kAllowed |
302 DataReductionProxyParams::kFallbackAllowed | 303 DataReductionProxyParams::kFallbackAllowed |
303 DataReductionProxyParams::kPromoAllowed); 304 DataReductionProxyParams::kPromoAllowed);
304 DataReductionProxyParams::DataReductionProxyList proxies = 305 DataReductionProxyParams::DataReductionProxyList proxies =
305 params.GetAllowedProxies(); 306 params.GetAllowedProxies();
306 if (proxies.size() == 0) 307 if (proxies.size() == 0)
307 return false; 308 return false;
308 309
309 if (request == NULL || request->context() == NULL || 310 if (request == NULL || request->context() == NULL ||
(...skipping 18 matching lines...) Expand all
328 if (found == retry_map.end()) 329 if (found == retry_map.end())
329 return false; 330 return false;
330 if (shortest_delay == 0 || 331 if (shortest_delay == 0 ||
331 shortest_delay > found->second.current_delay.InSeconds()) { 332 shortest_delay > found->second.current_delay.InSeconds()) {
332 shortest_delay = found->second.current_delay.InSeconds(); 333 shortest_delay = found->second.current_delay.InSeconds();
333 } 334 }
334 } 335 }
335 if (delay_seconds != NULL) 336 if (delay_seconds != NULL)
336 *delay_seconds = shortest_delay; 337 *delay_seconds = shortest_delay;
337 return true; 338 return true;
338 #else
339 return false;
340 #endif
341 } 339 }
342 340
343 } // namespace 341 } // namespace
344 342
345 DataReductionProxyRequestType GetDataReductionProxyRequestType( 343 DataReductionProxyRequestType GetDataReductionProxyRequestType(
346 const net::URLRequest* request) { 344 const net::URLRequest* request) {
347 if (request->url().SchemeIs("https")) 345 if (request->url().SchemeIs("https"))
348 return HTTPS; 346 return HTTPS;
349 if (!request->url().SchemeIs("http")) { 347 if (!request->url().SchemeIs("http")) {
350 NOTREACHED(); 348 NOTREACHED();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 UpdateContentLengthPrefsForDataReductionProxy( 532 UpdateContentLengthPrefsForDataReductionProxy(
535 received_content_length, 533 received_content_length,
536 original_content_length, 534 original_content_length,
537 with_data_reduction_proxy_enabled, 535 with_data_reduction_proxy_enabled,
538 request_type, 536 request_type,
539 base::Time::Now(), 537 base::Time::Now(),
540 prefs); 538 prefs);
541 } 539 }
542 540
543 } // namespace data_reduction_proxy 541 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698