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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc

Issue 473723002: Update data reduction proxy statistics prefs less often on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tooManyWritesPatch
Patch Set: Addressed bengr comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
index 22bd57c8263d396ba20eb6f132d167b328e0b908..196fcd3ac5da981345300d518564fd970770d528 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
@@ -5,11 +5,10 @@
#include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h"
#include "base/metrics/histogram.h"
-#include "base/prefs/pref_service.h"
-#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_statistics_prefs.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names.h"
#include "net/base/host_port_pair.h"
@@ -194,14 +193,14 @@ class DailyContentLengthUpdate {
public:
DailyContentLengthUpdate(
const char* pref,
bengr 2014/08/28 21:38:34 This can be moved up a line: DailyContentLength
megjablon 2014/08/30 01:10:04 Done.
- PrefService* pref_service)
- : update_(pref_service, pref) {
+ DataReductionProxyStatisticsPrefs* pref_service)
+ : update_(pref_service->GetList(pref)) {
}
void UpdateForDataChange(int days_since_last_update) {
// New empty lists may have been created. Maintain the invariant that
// there should be exactly |kNumDaysInHistory| days in the histories.
- MaintainContentLengthPrefsWindow(update_.Get(), kNumDaysInHistory);
+ MaintainContentLengthPrefsWindow(update_, kNumDaysInHistory);
if (days_since_last_update) {
MaintainContentLengthPrefForDateChange(days_since_last_update);
}
@@ -209,7 +208,7 @@ class DailyContentLengthUpdate {
// Update the lengths for the current day.
void Add(int content_length) {
- AddInt64ToListPref(kNumDaysInHistory - 1, content_length, update_.Get());
+ AddInt64ToListPref(kNumDaysInHistory - 1, content_length, update_);
}
int64 GetListPrefValue(size_t index) {
@@ -248,10 +247,10 @@ class DailyContentLengthUpdate {
// Entries for new days may have been appended. Maintain the invariant that
// there should be exactly |kNumDaysInHistory| days in the histories.
- MaintainContentLengthPrefsWindow(update_.Get(), kNumDaysInHistory);
+ MaintainContentLengthPrefsWindow(update_, kNumDaysInHistory);
}
- ListPrefUpdate update_;
+ base::ListValue* update_;
};
// DailyDataSavingUpdate maintains a pair of data saving prefs, original_update_
@@ -264,9 +263,9 @@ class DailyDataSavingUpdate {
DailyDataSavingUpdate(
const char* pref_original,
bengr 2014/08/28 21:38:34 These can probably move up a line
megjablon 2014/08/30 01:10:04 Done.
const char* pref_received,
- PrefService* pref_service)
- : original_(pref_original, pref_service),
- received_(pref_received, pref_service) {
+ DataReductionProxyStatisticsPrefs* prefs)
+ : original_(pref_original, prefs),
+ received_(pref_received, prefs) {
}
void UpdateForDataChange(int days_since_last_update) {
@@ -340,7 +339,8 @@ void UpdateContentLengthPrefsForDataReductionProxy(
int original_content_length,
bool with_data_reduction_proxy_enabled,
DataReductionProxyRequestType request_type,
- base::Time now, PrefService* prefs) {
+ base::Time now,
+ DataReductionProxyStatisticsPrefs* prefs) {
// TODO(bengr): Remove this check once the underlying cause of
// http://crbug.com/287821 is fixed. For now, only continue if the current
// year is reported as being between 1972 and 2970.
@@ -479,7 +479,7 @@ void UpdateContentLengthPrefs(
int original_content_length,
bool with_data_reduction_proxy_enabled,
DataReductionProxyRequestType request_type,
- PrefService* prefs) {
+ DataReductionProxyStatisticsPrefs* prefs) {
int64 total_received = prefs->GetInt64(
data_reduction_proxy::prefs::kHttpReceivedContentLength);
int64 total_original = prefs->GetInt64(

Powered by Google App Engine
This is Rietveld 408576698