Chromium Code Reviews| 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 7d9623c931a113ab3ac8b84eed593d49c2c7dc88..d27b02463d8e15c76ce7299f64a413ad4ed32006 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 |
| @@ -7,27 +7,32 @@ |
| #include <list> |
| #include <memory> |
| #include <string> |
| #include "base/macros.h" |
| #include "base/threading/thread_checker.h" |
| #include "net/url_request/url_fetcher_delegate.h" |
| #include "url/gurl.h" |
| +namespace base { |
| +class Time; |
| +} |
| + |
| namespace net { |
| class URLFetcher; |
| class URLRequestContextGetter; |
| } |
| namespace data_reduction_proxy { |
| class DataReductionProxyData; |
| +class RecordPageloadMetricsRequest; |
|
tbansal1
2016/07/15 17:44:04
lexicographical order.
RyanSturm
2016/07/15 18:16:03
Done.
|
| struct DataReductionProxyPageLoadTiming; |
| // Manages pingbacks about page load timing information to the data saver proxy |
| // server. This class is not thread safe. |
| class DataReductionProxyPingbackClient : public net::URLFetcherDelegate { |
| public: |
| // The caller must ensure that |url_request_context| remains alive for the |
| // lifetime of the |DataReductionProxyPingbackClient| instance. |
| explicit DataReductionProxyPingbackClient( |
| net::URLRequestContextGetter* url_request_context); |
| @@ -39,42 +44,45 @@ class DataReductionProxyPingbackClient : public net::URLFetcherDelegate { |
| const DataReductionProxyPageLoadTiming& timing); |
| // Sets the probability of actually sending a pingback to the server for any |
| // call to SendPingback. |
| void SetPingbackReportingFraction(float pingback_reporting_fraction); |
| protected: |
| // Generates a float in the range [0, 1). Virtualized in testing. |
| virtual float GenerateRandomFloat() const; |
| + // Returns the current time. Virtualized in testing. |
| + virtual base::Time CurrentTime() const; |
| + |
| private: |
| // URLFetcherDelegate implmentation: |
| void OnURLFetchComplete(const net::URLFetcher* source) override; |
| // Whether a pingback should be sent. |
| bool ShouldSendPingback() const; |
| // Creates an URLFetcher that will POST to |secure_proxy_url_| using |
| // |url_request_context_|. The max retires is set to 5. |
| std::unique_ptr<net::URLFetcher> MaybeCreateFetcherForDataAndStart( |
| - const std::string& data); |
| + RecordPageloadMetricsRequest* request_data); |
|
tbansal1
2016/07/15 17:44:04
Say something about the ownership in comments. e.g
RyanSturm
2016/07/15 18:16:03
Done.
|
| net::URLRequestContextGetter* url_request_context_; |
| // The URL for the data saver proxy's ping back service. |
| const GURL pingback_url_; |
| // The currently running fetcher. |
| std::unique_ptr<net::URLFetcher> current_fetcher_; |
| // Serialized data to send to the data saver proxy server. |
| - std::list<std::string> data_to_send_; |
| + std::list<std::unique_ptr<RecordPageloadMetricsRequest>> data_to_send_; |
| // The probability of sending a pingback to the server. |
| float pingback_reporting_fraction_; |
| base::ThreadChecker thread_checker_; |
| DISALLOW_COPY_AND_ASSIGN(DataReductionProxyPingbackClient); |
| }; |
| } // namespace data_reduction_proxy |