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

Unified Diff: components/previews/previews_data_savings.cc

Issue 2257533003: Adding a previews object, PreviewsDataSavings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and design change. Created 4 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/previews/previews_data_savings.cc
diff --git a/components/previews/previews_data_savings.cc b/components/previews/previews_data_savings.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7fabc38e9fc9db2432dc2061585b2a57d4fb95fc
--- /dev/null
+++ b/components/previews/previews_data_savings.cc
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/previews/previews_data_savings.h"
+
+#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
+#include "components/data_reduction_proxy/core/common/data_savings_recorder.h"
+
+namespace previews {
+
+PreviewsDataSavings::PreviewsDataSavings(
+ data_reduction_proxy::DataSavingsRecorder* data_savings_recorder)
+ : data_savings_recorder_(data_savings_recorder) {
+ DCHECK(data_savings_recorder);
+}
+
+PreviewsDataSavings::~PreviewsDataSavings() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+void PreviewsDataSavings::RecordDataSavings(
+ const std::string& fully_qualified_domain_name,
+ int64_t data_used,
+ int64_t original_size) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // Only record savings when data saver is enabled.
+ if (!data_savings_recorder_->ShouldRecordDataSavings()) {
bengr 2016/08/31 22:02:26 Can this be an implementation detail of UpdateData
RyanSturm 2016/09/02 01:17:51 Done.
+ return;
+ }
+ data_savings_recorder_->UpdateDataSavings(fully_qualified_domain_name,
+ data_used, original_size);
+}
+
+} // namespace previews

Powered by Google App Engine
This is Rietveld 408576698