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

Side by Side 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: updating dependent cl 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/previews/previews_data_savings.h"
6
7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "components/data_reduction_proxy/core/common/data_saver_status.h"
10 #include "components/data_reduction_proxy/core/common/data_savings_recorder.h"
11
12 namespace previews {
13
14 PreviewsDataSavings::PreviewsDataSavings(
15 data_reduction_proxy::DataSavingsRecorder* data_savings_recorder,
16 data_reduction_proxy::DataSaverStatus* data_saver_status)
17 : data_savings_recorder_(data_savings_recorder),
18 data_saver_status_(data_saver_status) {
19 DCHECK(data_savings_recorder);
20 DCHECK(data_saver_status);
21 }
22
23 PreviewsDataSavings::~PreviewsDataSavings() {
24 DCHECK(thread_checker_.CalledOnValidThread());
25 }
26
27 void PreviewsDataSavings::RecordDataSavings(const std::string& host,
28 int64_t data_used,
29 int64_t original_size) {
30 DCHECK(thread_checker_.CalledOnValidThread());
31
32 // Only record savings when data saver is enabled.
bengr 2016/08/25 23:04:19 Again, this class shouldn't know about Data Saver.
RyanSturm 2016/08/26 17:47:39 I think it's fundamental to previews/ to understan
33 if (!data_savings_recorder_ || !data_saver_status_ ||
bengr 2016/08/25 23:04:19 You don't need to check these if they're expected
RyanSturm 2016/08/26 17:47:39 Good point, these were left over from when this wa
34 !data_saver_status_->IsDataSaverEnabled()) {
bengr 2016/08/25 23:04:19 Use a callback called should_record_data_savings_
RyanSturm 2016/08/26 17:47:39 See other comment.
35 return;
36 }
37 data_savings_recorder_->UpdateDataSavings(host, data_used, original_size);
38 }
39
40 } // namespace previews
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698