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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc

Issue 1173343009: LevelDB storage for data reduction proxy to store data usage stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use raw pointers for arguments instead of ref counting Created 5 years, 6 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/core/browser/data_reduction_proxy_compression_stats.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc
index f272fd999af26c7f841be8920a2fd3135d417fb7..169ac51c0cafe1c4d040f6995456e2b2eb0bf6fb 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.cc
@@ -4,6 +4,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h"
+#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -20,7 +21,10 @@
#include "base/time/time.h"
#include "base/values.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h"
+#include "components/data_reduction_proxy/core/browser/data_usage_storage_helper.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
+#include "components/data_reduction_proxy/proto/store.pb.h"
namespace data_reduction_proxy {
@@ -302,10 +306,14 @@ class DailyDataSavingUpdate {
DataReductionProxyCompressionStats::DataReductionProxyCompressionStats(
PrefService* prefs,
- scoped_refptr<base::SequencedTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
bengr 2015/06/25 23:22:54 #include single_thread_task_runner.h
Not at Google. Contact bengr 2015/06/29 20:53:26 Reverted.
+ scoped_refptr<base::SingleThreadTaskRunner> db_task_runner,
+ scoped_refptr<DataReductionProxyStore> store,
const base::TimeDelta& delay)
: pref_service_(prefs),
- task_runner_(task_runner),
+ ui_task_runner_(ui_task_runner),
+ db_task_runner_(db_task_runner),
+ data_usage_store_(new DataUsageStorageHelper(store)),
michaeln 2015/06/26 20:15:00 Why the double wrapping of refcounted objects wher
Not at Google. Contact bengr 2015/06/29 20:53:26 DataReductionProxyStore will have uses outside thi
Not at Google. Contact bengr 2015/06/29 21:17:46 Note that calls to |data_usage_store_| will be pos
delay_(delay),
delayed_task_posted_(false),
pref_change_registrar_(new PrefChangeRegistrar()),
@@ -319,7 +327,6 @@ DataReductionProxyCompressionStats::~DataReductionProxyCompressionStats() {
DCHECK(thread_checker_.CalledOnValidThread());
WritePrefs();
pref_change_registrar_->RemoveAll();
- weak_factory_.InvalidateWeakPtrs();
}
void DataReductionProxyCompressionStats::Init() {
@@ -383,6 +390,8 @@ void DataReductionProxyCompressionStats::UpdateContentLengths(
SetInt64(data_reduction_proxy::prefs::kHttpOriginalContentLength,
total_original);
+ // TODO(kundaji): Collect data usage metrics broken down by site and store
+ // in |data_usage_store_|.
RecordContentLengthPrefs(
received_content_length,
original_content_length,
@@ -559,10 +568,9 @@ void DataReductionProxyCompressionStats::DelayedWritePrefs() {
if (delayed_task_posted_)
return;
- task_runner_->PostDelayedTask(
- FROM_HERE,
- base::Bind(&DataReductionProxyCompressionStats::WritePrefs,
- weak_factory_.GetWeakPtr()),
+ ui_task_runner_->PostDelayedTask(
+ FROM_HERE, base::Bind(&DataReductionProxyCompressionStats::WritePrefs,
+ weak_factory_.GetWeakPtr()),
delay_);
delayed_task_posted_ = true;

Powered by Google App Engine
This is Rietveld 408576698