summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authormegjablon <megjablon@chromium.org>2014-12-09 11:46:47 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-09 19:47:35 +0000
commitc1751458b9409f52c56b3f84d8226c57c39369d5 (patch)
tree680b901349ec37cd953737385746bc87f5c50edf /android_webview
parente0fe19f3e05e83e820be8a8e2850853bc0434b21 (diff)
downloadchromium_src-c1751458b9409f52c56b3f84d8226c57c39369d5.zip
chromium_src-c1751458b9409f52c56b3f84d8226c57c39369d5.tar.gz
chromium_src-c1751458b9409f52c56b3f84d8226c57c39369d5.tar.bz2
Move data reduction proxy logic out of chrome and android webview network delegates
In order to move the data reduction proxy logic from ChromeNetworkDelegate and AwNetworkDelegate to DataReductionProxyNetworkDelegate, pure virtual methods in NetworkDelegate move to the new subclass NetworkDelegateImpl. All subclasses of NetworkDelegate now subclass NetworkDelegateImpl. The DataReductionProxyNetworkDelegate subclasses WrappingNetworkDelegate. WrappingNetworkDelegate subclasses NetworkDelegateand and takes a NetworkDelegate in its constructor and owns it. For every override OnFoo, WrappingNetworkDelegate provides a protected virtual void OnFooInternal(), with an empty default implementation. DataReductionProxyNetworkDelegate subclasses WrappingNetworkDelegate and moves implementations from ChromeNetworkDelegate and AwNetworkDelegate inside the On*Internal() methods. BUG=429734 Review URL: https://codereview.chromium.org/734263003 Cr-Commit-Position: refs/heads/master@{#307523}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/browser/net/aw_network_delegate.cc17
-rw-r--r--android_webview/browser/net/aw_network_delegate.h31
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc49
3 files changed, 31 insertions, 66 deletions
diff --git a/android_webview/browser/net/aw_network_delegate.cc b/android_webview/browser/net/aw_network_delegate.cc
index 85cbdcf..bc778fe 100644
--- a/android_webview/browser/net/aw_network_delegate.cc
+++ b/android_webview/browser/net/aw_network_delegate.cc
@@ -6,9 +6,6 @@
#include "android_webview/browser/aw_cookie_access_policy.h"
#include "base/android/build_info.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.h"
-#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "net/base/net_errors.h"
#include "net/base/completion_callback.h"
#include "net/proxy/proxy_info.h"
@@ -17,9 +14,7 @@
namespace android_webview {
-AwNetworkDelegate::AwNetworkDelegate()
- : data_reduction_proxy_params_(NULL),
- data_reduction_proxy_auth_request_handler_(NULL) {
+AwNetworkDelegate::AwNetworkDelegate() {
}
AwNetworkDelegate::~AwNetworkDelegate() {
@@ -44,16 +39,6 @@ int AwNetworkDelegate::OnBeforeSendHeaders(
return net::OK;
}
-void AwNetworkDelegate::OnBeforeSendProxyHeaders(
- net::URLRequest* request,
- const net::ProxyInfo& proxy_info,
- net::HttpRequestHeaders* headers) {
- if (data_reduction_proxy_auth_request_handler_) {
- data_reduction_proxy_auth_request_handler_->MaybeAddRequestHeader(
- request, proxy_info.proxy_server(), headers);
- }
-}
-
void AwNetworkDelegate::OnSendHeaders(net::URLRequest* request,
const net::HttpRequestHeaders& headers) {
}
diff --git a/android_webview/browser/net/aw_network_delegate.h b/android_webview/browser/net/aw_network_delegate.h
index 0cbdefa..c925db9 100644
--- a/android_webview/browser/net/aw_network_delegate.h
+++ b/android_webview/browser/net/aw_network_delegate.h
@@ -6,12 +6,7 @@
#define ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_DELEGATE_H_
#include "base/basictypes.h"
-#include "net/base/network_delegate.h"
-
-namespace data_reduction_proxy {
-class DataReductionProxyAuthRequestHandler;
-class DataReductionProxyParams;
-}
+#include "net/base/network_delegate_impl.h"
namespace net {
class ProxyInfo;
@@ -21,24 +16,11 @@ class URLRequest;
namespace android_webview {
// WebView's implementation of the NetworkDelegate.
-class AwNetworkDelegate : public net::NetworkDelegate {
+class AwNetworkDelegate : public net::NetworkDelegateImpl {
public:
AwNetworkDelegate();
virtual ~AwNetworkDelegate();
- // Sets the |DataReductionProxySettings| object to use. If not set, the
- // NetworkDelegate will not perform any operations related to the data
- // reduction proxy.
- void set_data_reduction_proxy_params(
- data_reduction_proxy::DataReductionProxyParams* params) {
- data_reduction_proxy_params_ = params;
- }
-
- void set_data_reduction_proxy_auth_request_handler(
- data_reduction_proxy::DataReductionProxyAuthRequestHandler* handler) {
- data_reduction_proxy_auth_request_handler_ = handler;
- }
-
private:
// NetworkDelegate implementation.
virtual int OnBeforeURLRequest(net::URLRequest* request,
@@ -47,10 +29,6 @@ class AwNetworkDelegate : public net::NetworkDelegate {
virtual int OnBeforeSendHeaders(net::URLRequest* request,
const net::CompletionCallback& callback,
net::HttpRequestHeaders* headers) override;
- virtual void OnBeforeSendProxyHeaders(
- net::URLRequest* request,
- const net::ProxyInfo& proxy_info,
- net::HttpRequestHeaders* headers) override;
virtual void OnSendHeaders(net::URLRequest* request,
const net::HttpRequestHeaders& headers) override;
virtual int OnHeadersReceived(
@@ -83,11 +61,6 @@ class AwNetworkDelegate : public net::NetworkDelegate {
virtual bool OnCanThrottleRequest(
const net::URLRequest& request) const override;
- // Data reduction proxy parameters object. Must outlive this.
- data_reduction_proxy::DataReductionProxyParams* data_reduction_proxy_params_;
- data_reduction_proxy::DataReductionProxyAuthRequestHandler*
- data_reduction_proxy_auth_request_handler_;
-
DISALLOW_COPY_AND_ASSIGN(AwNetworkDelegate);
};
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index ce39602..f00ef59 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -20,6 +20,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@@ -195,8 +196,33 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
net::URLRequestContextBuilder builder;
builder.set_user_agent(GetUserAgent());
- AwNetworkDelegate* aw_network_delegate = new AwNetworkDelegate();
- builder.set_network_delegate(aw_network_delegate);
+ scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate());
+
+ AwBrowserContext* browser_context = AwBrowserContext::GetDefault();
+ DCHECK(browser_context);
+
+ // Compression statistics are not gathered for WebView, so
+ // DataReductionProxyStatisticsPrefs is not instantiated and passed to the
+ // network delegate.
+ DataReductionProxySettings* data_reduction_proxy_settings =
+ browser_context->GetDataReductionProxySettings();
+ DCHECK(data_reduction_proxy_settings);
+ data_reduction_proxy_auth_request_handler_.reset(
+ new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
+ data_reduction_proxy::Client::WEBVIEW_ANDROID,
+ data_reduction_proxy_settings->params(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
+
+ data_reduction_proxy::DataReductionProxyNetworkDelegate*
+ data_reduction_proxy_network_delegate =
+ new data_reduction_proxy::DataReductionProxyNetworkDelegate(
+ aw_network_delegate.Pass(),
+ data_reduction_proxy_settings->params(),
+ data_reduction_proxy_auth_request_handler_.get(),
+ data_reduction_proxy::DataReductionProxyNetworkDelegate::
+ ProxyConfigGetter());
+
+ builder.set_network_delegate(data_reduction_proxy_network_delegate);
#if !defined(DISABLE_FTP_SUPPORT)
builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
#endif
@@ -230,25 +256,6 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
20 * 1024 * 1024, // 20M
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
- AwBrowserContext* browser_context = AwBrowserContext::GetDefault();
- DCHECK(browser_context);
- DataReductionProxySettings* data_reduction_proxy_settings =
- browser_context->GetDataReductionProxySettings();
- DCHECK(data_reduction_proxy_settings);
- data_reduction_proxy_auth_request_handler_.reset(
- new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
- data_reduction_proxy::Client::WEBVIEW_ANDROID,
- data_reduction_proxy_settings->params(),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
-
- // Compression statistics are not gathered for WebView, so
- // DataReductionProxyStatisticsPrefs is not instantiated and passed to the
- // network delegate.
- aw_network_delegate->set_data_reduction_proxy_params(
- data_reduction_proxy_settings->params());
- aw_network_delegate->set_data_reduction_proxy_auth_request_handler(
- data_reduction_proxy_auth_request_handler_.get());
-
main_http_factory_.reset(main_cache);
url_request_context_->set_http_transaction_factory(main_cache);
url_request_context_->set_cookie_store(cookie_store_.get());