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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: bengr comments Created 3 years, 8 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/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h
index a91a44cf0d9dac350922339e08c146670b768e6b..1f437b6a85c8e047444c734e2acc544d9fe998d3 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h
@@ -5,8 +5,12 @@
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_PINGBACK_CLIENT_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_PINGBACK_CLIENT_H_
+#include <stdint.h>
+
#include <memory>
+#include <set>
#include <string>
+#include <utility>
#include "base/macros.h"
#include "base/threading/thread_checker.h"
@@ -27,6 +31,8 @@ namespace data_reduction_proxy {
class DataReductionProxyData;
struct DataReductionProxyPageLoadTiming;
+using NavigationID = std::pair<uint64_t, std::string>;
+
// Manages pingbacks about page load timing information to the data saver proxy
// server. This class is not thread safe.
class DataReductionProxyPingbackClient : public net::URLFetcherDelegate {
@@ -46,6 +52,17 @@ class DataReductionProxyPingbackClient : public net::URLFetcherDelegate {
// call to SendPingback.
void SetPingbackReportingFraction(float pingback_reporting_fraction);
+ // Adds an opt out for |tab_identifier_key| for a data saver |page_id|. An opt
+ // out occurs when users dismiss the preview in favor of the full page.
+ void AddOptOut(const NavigationID& navigation_id);
+
+ // Removes any stored data associated with |tab_identifier_key| in a task that
+ // runs later.
+ void ClearNavigationKeyAsync(const NavigationID& navigation_id);
+
+ // The total number of pending loads being tracked due to opt outs.
+ size_t OptOutsSizeForTesting() const;
+
protected:
// Generates a float in the range [0, 1). Virtualized in testing.
virtual float GenerateRandomFloat() const;
@@ -66,6 +83,9 @@ class DataReductionProxyPingbackClient : public net::URLFetcherDelegate {
// reset to an empty RecordPageloadMetricsRequest.
void CreateFetcherForDataAndStart();
+ // Removes any stored data associated with |tab_identifier_key|.
+ void ClearNavigationKeySync(const NavigationID& navigation_id);
+
net::URLRequestContextGetter* url_request_context_;
// The URL for the data saver proxy's ping back service.
@@ -80,6 +100,9 @@ class DataReductionProxyPingbackClient : public net::URLFetcherDelegate {
// The probability of sending a pingback to the server.
float pingback_reporting_fraction_;
+ // The map of tab identifier keys to page IDs.
+ std::set<NavigationID> opt_outs_;
+
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyPingbackClient);

Powered by Google App Engine
This is Rietveld 408576698