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

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

Issue 949533004: Rename DataReductionProxyStatisticsPrefs to DataReductionProxyCompressionStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/core/browser/data_reduction_proxy_metr ics.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr ics.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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" 12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h"
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h"
14 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 14 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
16 #include "net/base/host_port_pair.h" 16 #include "net/base/host_port_pair.h"
17 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
18 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
19 #include "net/proxy/proxy_config.h" 19 #include "net/proxy/proxy_config.h"
20 #include "net/proxy/proxy_retry_info.h" 20 #include "net/proxy/proxy_retry_info.h"
21 #include "net/proxy/proxy_server.h" 21 #include "net/proxy/proxy_server.h"
22 #include "net/proxy/proxy_service.h" 22 #include "net/proxy/proxy_service.h"
23 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 list->AppendString(base::Int64ToString(0)); 190 list->AppendString(base::Int64ToString(0));
191 DCHECK_EQ(length, list->GetSize()); 191 DCHECK_EQ(length, list->GetSize());
192 } 192 }
193 193
194 // DailyContentLengthUpdate maintains a data saving pref. The pref is a list 194 // DailyContentLengthUpdate maintains a data saving pref. The pref is a list
195 // of |kNumDaysInHistory| elements of daily total content lengths for the past 195 // of |kNumDaysInHistory| elements of daily total content lengths for the past
196 // |kNumDaysInHistory| days. 196 // |kNumDaysInHistory| days.
197 class DailyContentLengthUpdate { 197 class DailyContentLengthUpdate {
198 public: 198 public:
199 DailyContentLengthUpdate(const char* pref, 199 DailyContentLengthUpdate(const char* pref,
200 DataReductionProxyStatisticsPrefs* pref_service) 200 DataReductionProxyCompressionStats* pref_service)
201 : update_(pref_service->GetList(pref)) { 201 : update_(pref_service->GetList(pref)) {
202 } 202 }
203 203
204 void UpdateForDataChange(int days_since_last_update) { 204 void UpdateForDataChange(int days_since_last_update) {
205 // New empty lists may have been created. Maintain the invariant that 205 // New empty lists may have been created. Maintain the invariant that
206 // there should be exactly |kNumDaysInHistory| days in the histories. 206 // there should be exactly |kNumDaysInHistory| days in the histories.
207 MaintainContentLengthPrefsWindow(update_, kNumDaysInHistory); 207 MaintainContentLengthPrefsWindow(update_, kNumDaysInHistory);
208 if (days_since_last_update) { 208 if (days_since_last_update) {
209 MaintainContentLengthPrefForDateChange(days_since_last_update); 209 MaintainContentLengthPrefForDateChange(days_since_last_update);
210 } 210 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // DailyDataSavingUpdate maintains a pair of data saving prefs, original_update_ 260 // DailyDataSavingUpdate maintains a pair of data saving prefs, original_update_
261 // and received_update_. pref_original is a list of |kNumDaysInHistory| elements 261 // and received_update_. pref_original is a list of |kNumDaysInHistory| elements
262 // of daily total original content lengths for the past |kNumDaysInHistory| 262 // of daily total original content lengths for the past |kNumDaysInHistory|
263 // days. pref_received is the corresponding list of the daily total received 263 // days. pref_received is the corresponding list of the daily total received
264 // content lengths. 264 // content lengths.
265 class DailyDataSavingUpdate { 265 class DailyDataSavingUpdate {
266 public: 266 public:
267 DailyDataSavingUpdate(const char* pref_original, 267 DailyDataSavingUpdate(const char* pref_original,
268 const char* pref_received, 268 const char* pref_received,
269 DataReductionProxyStatisticsPrefs* prefs) 269 DataReductionProxyCompressionStats* prefs)
270 : original_(pref_original, prefs), 270 : original_(pref_original, prefs),
271 received_(pref_received, prefs) { 271 received_(pref_received, prefs) {
272 } 272 }
273 273
274 void UpdateForDataChange(int days_since_last_update) { 274 void UpdateForDataChange(int days_since_last_update) {
275 original_.UpdateForDataChange(days_since_last_update); 275 original_.UpdateForDataChange(days_since_last_update);
276 received_.UpdateForDataChange(days_since_last_update); 276 received_.UpdateForDataChange(days_since_last_update);
277 } 277 }
278 278
279 // Update the lengths for the current day. 279 // Update the lengths for the current day.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 351 }
352 return original_content_length; 352 return original_content_length;
353 } 353 }
354 354
355 void UpdateContentLengthPrefsForDataReductionProxy( 355 void UpdateContentLengthPrefsForDataReductionProxy(
356 int received_content_length, 356 int received_content_length,
357 int original_content_length, 357 int original_content_length,
358 bool with_data_reduction_proxy_enabled, 358 bool with_data_reduction_proxy_enabled,
359 DataReductionProxyRequestType request_type, 359 DataReductionProxyRequestType request_type,
360 base::Time now, 360 base::Time now,
361 DataReductionProxyStatisticsPrefs* prefs) { 361 DataReductionProxyCompressionStats* prefs) {
362 // TODO(bengr): Remove this check once the underlying cause of 362 // TODO(bengr): Remove this check once the underlying cause of
363 // http://crbug.com/287821 is fixed. For now, only continue if the current 363 // http://crbug.com/287821 is fixed. For now, only continue if the current
364 // year is reported as being between 1972 and 2970. 364 // year is reported as being between 1972 and 2970.
365 base::TimeDelta time_since_unix_epoch = now - base::Time::UnixEpoch(); 365 base::TimeDelta time_since_unix_epoch = now - base::Time::UnixEpoch();
366 const int kMinDaysSinceUnixEpoch = 365 * 2; // 2 years. 366 const int kMinDaysSinceUnixEpoch = 365 * 2; // 2 years.
367 const int kMaxDaysSinceUnixEpoch = 365 * 1000; // 1000 years. 367 const int kMaxDaysSinceUnixEpoch = 365 * 1000; // 1000 years.
368 if (time_since_unix_epoch.InDays() < kMinDaysSinceUnixEpoch || 368 if (time_since_unix_epoch.InDays() < kMinDaysSinceUnixEpoch ||
369 time_since_unix_epoch.InDays() > kMaxDaysSinceUnixEpoch) { 369 time_since_unix_epoch.InDays() > kMaxDaysSinceUnixEpoch) {
370 return; 370 return;
371 } 371 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 via_proxy.GetReceivedListPrefValue(kNumDaysInHistory - 2), 482 via_proxy.GetReceivedListPrefValue(kNumDaysInHistory - 2),
483 https.GetListPrefValue(kNumDaysInHistory - 2), 483 https.GetListPrefValue(kNumDaysInHistory - 2),
484 short_bypass.GetListPrefValue(kNumDaysInHistory - 2), 484 short_bypass.GetListPrefValue(kNumDaysInHistory - 2),
485 long_bypass.GetListPrefValue(kNumDaysInHistory - 2), 485 long_bypass.GetListPrefValue(kNumDaysInHistory - 2),
486 unknown.GetListPrefValue(kNumDaysInHistory - 2)); 486 unknown.GetListPrefValue(kNumDaysInHistory - 2));
487 } 487 }
488 } 488 }
489 } 489 }
490 490
491 } // namespace data_reduction_proxy 491 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698