Chromium Code Reviews| 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 |