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

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

Issue 734263003: Move data reduction proxy logic out of chrome and android webview network delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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_network_delegate.h
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..dd177fe56f8aaa06d1dc0127e204e57a402e5ac7
--- /dev/null
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h
@@ -0,0 +1,170 @@
+// Copyright 2014 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 COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWORK_DELEGATE_H_
+#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWORK_DELEGATE_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
+#include "net/base/wrapping_network_delegate.h"
+#include "net/proxy/proxy_retry_info.h"
+
+template<class T> class PrefMember;
+
+typedef PrefMember<bool> BooleanPrefMember;
+
+class PrefService;
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace net {
+class ProxyConfig;
+class ProxyInfo;
+class ProxyServer;
+class NetworkDelegate;
+class URLRequest;
+}
+
+namespace data_reduction_proxy {
+
+class DataReductionProxyAuthRequestHandler;
+class DataReductionProxyParams;
+class DataReductionProxyStatisticsPrefs;
+class DataReductionProxyUsageStats;
+
+class DataReductionProxyNetworkDelegate : public net::WrappingNetworkDelegate {
bengr 2014/11/18 19:30:56 Please add a comment describing what this class do
megjablon 2014/11/19 19:23:41 Next patch
+ public:
+ DataReductionProxyNetworkDelegate(
+ scoped_ptr<net::NetworkDelegate> network_delegate);
+ ~DataReductionProxyNetworkDelegate() override;
bengr 2014/11/18 19:30:56 I think you want this to be virtual.
megjablon 2014/11/19 19:23:41 Done.
+
+ // Provides an opportunity to interpose on proxy resolution. Called before
+ // ProxyService.ResolveProxy() returns. Two proxy configurations are provided
+ // that specify the data reduction proxy's configuration and the effective
+ // configuration according to the proxy service, respectively. Retry info is
+ // presumed to be from the proxy service.
+ typedef base::Callback<void(
+ const GURL& url,
+ int load_flags,
+ const net::ProxyConfig& data_reduction_proxy_config,
+ const net::ProxyConfig& proxy_service_proxy_config,
+ const net::ProxyRetryInfoMap& proxy_retry_info_map,
+ const DataReductionProxyParams* params,
+ net::ProxyInfo* result)> OnResolveProxyHandler;
+
+ // Provides an additional proxy configuration that can be consulted after
+ // proxy resolution.
+ typedef base::Callback<const net::ProxyConfig&()> ProxyConfigGetter;
+
+ void set_profile_prefs(PrefService* profile_prefs);
+
+ void set_ui_thread_proxy(
+ scoped_refptr<base::MessageLoopProxy> ui_thread_proxy);
+
+ void set_data_reduction_proxy_enabled_pref(
+ BooleanPrefMember* data_reduction_proxy_enabled) {
+ data_reduction_proxy_enabled_ = data_reduction_proxy_enabled;
+ }
+
+ // |data_reduction_proxy_params_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ void set_data_reduction_proxy_params(DataReductionProxyParams* params) {
+ data_reduction_proxy_params_ = params;
+ }
+
+ // |data_reduction_proxy_usage_stats_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ void set_data_reduction_proxy_usage_stats(
+ DataReductionProxyUsageStats* usage_stats) {
+ data_reduction_proxy_usage_stats_ = usage_stats;
+ }
+
+ // |data_reduction_proxy_auth_request_handler_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ void set_data_reduction_proxy_auth_request_handler(
+ DataReductionProxyAuthRequestHandler* handler) {
+ data_reduction_proxy_auth_request_handler_ = handler;
+ }
+
+ // |data_reduction_proxy_statistics_prefs_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ void set_data_reduction_proxy_statistics_prefs(
+ DataReductionProxyStatisticsPrefs*
+ statistics_prefs) {
+ data_reduction_proxy_statistics_prefs_ = statistics_prefs;
+ }
+
+ void set_on_resolve_proxy_handler(OnResolveProxyHandler handler) {
bengr 2014/11/18 19:30:56 Can this be a const &?
megjablon 2014/11/19 19:23:41 Done.
+ on_resolve_proxy_handler_ = handler;
+ }
+
+ void set_proxy_config_getter(const ProxyConfigGetter& getter) {
+ proxy_config_getter_ = getter;
+ }
+
+ // Creates a Value summary of the persistent state of the network session.
+ // The caller is responsible for deleting the returned value.
+ // Must be called on the UI thread.
+ static base::Value* HistoricNetworkStatsInfoToValue(
+ PrefService* profile_prefs);
+
+ // Creates a Value summary of the state of the network session. The caller is
+ // responsible for deleting the returned value.
+ base::Value* SessionNetworkStatsInfoToValue() const;
+
+ private:
+ void OnResolveProxyInternal(const GURL& url,
+ int load_flags,
+ const net::ProxyService& proxy_service,
+ net::ProxyInfo* result) override;
+ void OnProxyFallbackInternal(const net::ProxyServer& bad_proxy,
+ int net_error) override;
+ void OnBeforeSendProxyHeadersInternal(
+ net::URLRequest* request,
+ const net::ProxyInfo& proxy_info,
+ net::HttpRequestHeaders* headers) override;
+ void OnCompletedInternal(net::URLRequest* request,
bengr 2014/11/18 19:30:56 Add a blank line above and between all methods.
megjablon 2014/11/19 19:23:41 Done.
+ bool started) override;
+
+ void AccumulateContentLength(int64 received_payload_byte_count,
+ int64 original_payload_byte_count,
+ DataReductionProxyRequestType request_type);
+
+ PrefService* profile_prefs_;
+ scoped_refptr<base::MessageLoopProxy> ui_thread_proxy_;
+
+ // Total size of all content (excluding headers) that has been received
+ // over the network.
+ int64 received_content_length_;
+
+ // Total original size of all content before it was transferred.
+ int64 original_content_length_;
+
+ //Weak, owned by our owner.
+ BooleanPrefMember* data_reduction_proxy_enabled_;
+
+ // |data_reduction_proxy_params_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ DataReductionProxyParams* data_reduction_proxy_params_;
+ // |data_reduction_proxy_usage_stats_| must outlive this
+ // DataReductionProxyNetworkDelegate.
+ DataReductionProxyUsageStats* data_reduction_proxy_usage_stats_;
bengr 2014/11/18 19:30:56 Add a blank line between each member variable.
megjablon 2014/11/19 19:23:41 Done.
+ DataReductionProxyAuthRequestHandler*
+ data_reduction_proxy_auth_request_handler_;
+ DataReductionProxyStatisticsPrefs* data_reduction_proxy_statistics_prefs_;
+
+ OnResolveProxyHandler on_resolve_proxy_handler_;
+ ProxyConfigGetter proxy_config_getter_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataReductionProxyNetworkDelegate);
+};
+
+} // namespace data_reduction_proxy
+
+#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_NETWORK_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698