OLD | NEW |
| (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 #ifndef CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_ | |
6 #define CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/macros.h" | |
13 #include "base/threading/thread_checker.h" | |
14 | |
15 namespace data_reduction_proxy { | |
16 class DataSavingsRecorder; | |
17 } | |
18 | |
19 namespace previews { | |
20 | |
21 // Provides an interface for previews to report data savings. | |
22 class PreviewsDataSavings { | |
23 public: | |
24 // Embedder must guarantee that |data_savings_recorder| and | |
25 // |data_reduction_proxy_settings| outlive this instance. | |
26 PreviewsDataSavings( | |
27 data_reduction_proxy::DataSavingsRecorder* data_savings_recorder); | |
28 ~PreviewsDataSavings(); | |
29 | |
30 // Records the amount of data used by the preview, and the amount of data | |
31 // that would have been used if the original page had been loaded instead of | |
32 // the preview. |fully_qualified_domain_name| is the full host name to | |
33 // attribute the data savings to (e.g., codereview.chromium.org). | |
34 void RecordDataSavings(const std::string& fully_qualified_domain_name, | |
35 int64_t data_used, | |
36 int64_t original_size); | |
37 | |
38 private: | |
39 // Owned by the embedder, must be valid for the lifetime of |this|. | |
40 // Provides a method to record data savings. | |
41 data_reduction_proxy::DataSavingsRecorder* data_savings_recorder_; | |
42 | |
43 // Enforce usage on the UI thread. | |
44 base::ThreadChecker thread_checker_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(PreviewsDataSavings); | |
47 }; | |
48 | |
49 } // namespace previews | |
50 | |
51 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_ | |
OLD | NEW |