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

Unified Diff: components/previews/previews_data_savings.h

Issue 2257533003: Adding a previews object, PreviewsDataSavings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr comment Created 4 years, 3 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
« no previous file with comments | « components/previews/DEPS ('k') | components/previews/previews_data_savings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/previews/previews_data_savings.h
diff --git a/components/previews/previews_data_savings.h b/components/previews/previews_data_savings.h
new file mode 100644
index 0000000000000000000000000000000000000000..bce79448a7f78e42ae75e08284f998a6e51eac00
--- /dev/null
+++ b/components/previews/previews_data_savings.h
@@ -0,0 +1,51 @@
+// 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.
+
+#ifndef CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_
+#define CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+
+namespace data_reduction_proxy {
+class DataSavingsRecorder;
+}
+
+namespace previews {
+
+// Provides an interface for previews to report data savings.
+class PreviewsDataSavings {
+ public:
+ // Embedder must guarantee that |data_savings_recorder| and
+ // |data_reduction_proxy_settings| outlive this instance.
+ PreviewsDataSavings(
+ data_reduction_proxy::DataSavingsRecorder* data_savings_recorder);
+ ~PreviewsDataSavings();
+
+ // Records the amount of data used by the preview, and the amount of data
+ // that would have been used if the original page had been loaded instead of
+ // the preview. |fully_qualified_domain_name| is the full host name to
+ // attribute the data savings to (e.g., codereview.chromium.org).
+ void RecordDataSavings(const std::string& fully_qualified_domain_name,
+ int64_t data_used,
+ int64_t original_size);
+
+ private:
+ // Owned by the embedder, must be valid for the lifetime of |this|.
+ // Provides a method to record data savings.
+ data_reduction_proxy::DataSavingsRecorder* data_savings_recorder_;
+
+ // Enforce usage on the UI thread.
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreviewsDataSavings);
+};
+
+} // namespace previews
+
+#endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_DATA_SAVINGS_H_
« no previous file with comments | « components/previews/DEPS ('k') | components/previews/previews_data_savings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698