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

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

Issue 1024553009: Add the ability to use DataReductionProxyParams from DataReductionProxyConfigServiceClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_control_local
Patch Set: Address sclittle comment Created 5 years, 9 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_config_service_client.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h
index 648cee4ab009cf8a34cddef19823fb09236b8f48..3f6ae23bb7cf2db222d31314a88a874db22aa084 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h
@@ -9,38 +9,95 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/timer/timer.h"
+#include "net/base/backoff_entry.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+class Time;
+class TimeDelta;
+}
namespace data_reduction_proxy {
+class DataReductionProxyConfig;
+class DataReductionProxyMutableConfigValues;
class DataReductionProxyParams;
class DataReductionProxyRequestOptions;
+// Retrieves the default net::BackoffEntry::Policy for the Data Reduction Proxy
+// configuration service client.
+const net::BackoffEntry::Policy& GetBackoffPolicy();
+
// Retrieves the Data Reduction Proxy configuration from a remote service. This
// object lives on the IO thread.
class DataReductionProxyConfigServiceClient {
public:
// The caller must ensure that all parameters remain alive for the lifetime of
- // the |DataReductionProxyConfigClient|.
+ // the |DataReductionProxyConfigClient|, with the exception of |params|
+ // which this instance will own.
DataReductionProxyConfigServiceClient(
- DataReductionProxyParams* params,
- DataReductionProxyRequestOptions* request_options);
+ scoped_ptr<DataReductionProxyParams> params,
+ const net::BackoffEntry::Policy& backoff_policy,
+ DataReductionProxyRequestOptions* request_options,
+ DataReductionProxyMutableConfigValues* config_values,
+ DataReductionProxyConfig* config,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
- ~DataReductionProxyConfigServiceClient();
+ virtual ~DataReductionProxyConfigServiceClient();
- private:
- FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigClientTest,
- TestConstructStaticResponse);
+ // Request the retrieval of the Data Reduction Proxy configuration.
+ void RetrieveConfig();
+
+ protected:
+ // Retrieves the backoff entry object being used to throttle request failures.
+ // Virtual for testing.
+ virtual net::BackoffEntry* GetBackoffEntry();
+
+ // Sets a timer to determine when to next refresh the Data Reduction Proxy
+ // configuration.
+ // Virtual for testing.
+ virtual void SetConfigRefreshTimer(const base::TimeDelta& delay);
+
+ // Returns the current time.
+ // Virtual for testing.
+ virtual base::Time Now() const;
// Constructs a synthetic response based on |params_|.
- std::string ConstructStaticResponse() const;
+ // Virtual for testing.
+ virtual std::string ConstructStaticResponse() const;
- // The caller must ensure that the |params_| outlives this instance.
- DataReductionProxyParams* params_;
+ private:
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigServiceClientTest,
+ TestConstructStaticResponse);
+ friend class TestDataReductionProxyConfigServiceClient;
+
+ // Contains the static configuration data to use.
+ scoped_ptr<DataReductionProxyParams> params_;
// The caller must ensure that the |request_options_| outlives this instance.
DataReductionProxyRequestOptions* request_options_;
+ // The caller must ensure that the |config_values_| outlives this instance.
+ DataReductionProxyMutableConfigValues* config_values_;
+
+ // The caller must ensure that the |config_| outlives this instance.
+ DataReductionProxyConfig* config_;
+
+ // |io_task_runner_| should be the task runner for running operations on the
+ // IO thread.
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+
+ // Used to calculate the backoff time on request failures.
+ net::BackoffEntry backoff_entry_;
+
+ // An event that fires when it is time to refresh the Data Reduction Proxy
+ // configuration.
+ base::OneShotTimer<DataReductionProxyConfigServiceClient>
+ config_refresh_timer_;
+
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfigServiceClient);
};

Powered by Google App Engine
This is Rietveld 408576698