summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/io_thread.cc20
-rw-r--r--chrome/browser/io_thread.h5
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc30
-rw-r--r--chrome/browser/net/chrome_network_delegate.h17
-rw-r--r--chrome/browser/net/chrome_url_request_context.h9
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.cc13
-rw-r--r--chrome/browser/profiles/off_the_record_profile_io_data.h2
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc15
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h9
-rw-r--r--chrome/browser/profiles/profile_io_data.cc3
-rw-r--r--net/base/network_delegate.cc35
-rw-r--r--net/base/network_delegate.h59
-rw-r--r--net/http/http_cache.cc4
-rw-r--r--net/http/http_cache.h4
-rw-r--r--net/http/http_network_delegate.h34
-rw-r--r--net/http/http_network_layer.h2
-rw-r--r--net/http/http_network_session.h8
-rw-r--r--net/http/http_network_transaction.cc4
-rw-r--r--net/net.gyp3
-rw-r--r--net/url_request/url_request.cc6
-rw-r--r--net/url_request/url_request_context.h8
-rw-r--r--net/url_request/url_request_context_storage.cc4
-rw-r--r--net/url_request/url_request_context_storage.h6
-rw-r--r--net/url_request/url_request_job.cc9
-rw-r--r--net/url_request/url_request_test_util.cc13
-rw-r--r--net/url_request/url_request_test_util.h18
-rw-r--r--net/url_request/url_request_unittest.cc4
27 files changed, 212 insertions, 132 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index e966707..139bf9e 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -37,6 +37,7 @@
#include "net/base/host_resolver_impl.h"
#include "net/base/mapped_host_resolver.h"
#include "net/base/net_util.h"
+#include "net/base/network_delegate.h"
#include "net/http/http_auth_filter.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_network_layer.h"
@@ -178,6 +179,22 @@ class LoggingNetworkChangeObserver
DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver);
};
+class SystemNetworkDelegate : public net::NetworkDelegate {
+ public:
+ SystemNetworkDelegate() {}
+ ~SystemNetworkDelegate() {}
+
+ // NetworkDelegate methods:
+ // TODO(willchan): Implement these functions!
+ virtual void OnBeforeURLRequest(net::URLRequest* request) {}
+ virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers) {}
+ virtual void OnResponseStarted(net::URLRequest* request) {}
+ virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SystemNetworkDelegate);
+};
+
scoped_refptr<net::URLRequestContext>
ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
net::NetLog* net_log) {
@@ -327,6 +344,7 @@ void IOThread::Init() {
network_change_observer_.reset(
new LoggingNetworkChangeObserver(net_log_));
+ globals_->system_network_delegate.reset(new SystemNetworkDelegate);
globals_->host_resolver.reset(
CreateGlobalHostResolver(net_log_));
globals_->cert_verifier.reset(new net::CertVerifier);
@@ -347,7 +365,7 @@ void IOThread::Init() {
session_params.http_auth_handler_factory =
globals_->http_auth_handler_factory.get();
// TODO(willchan): Enable for proxy script fetcher context.
- session_params.network_delegate = NULL;
+ session_params.network_delegate = globals_->system_network_delegate.get();
session_params.net_log = net_log_;
session_params.ssl_config_service = globals_->ssl_config_service;
scoped_refptr<net::HttpNetworkSession> network_session(
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index 10cac6fa..d0c58de 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -12,7 +12,6 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/browser_process_sub_thread.h"
-#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/common/net/predictor_common.h"
#include "net/base/network_change_notifier.h"
@@ -32,6 +31,7 @@ class DnsRRResolver;
class HostResolver;
class HttpAuthHandlerFactory;
class HttpTransactionFactory;
+class NetworkDelegate;
class ProxyScriptFetcher;
class ProxyService;
class SSLConfigService;
@@ -45,6 +45,8 @@ class IOThread : public BrowserProcessSubThread {
Globals();
~Globals();
+ // The "system" NetworkDelegate, used for Profile-agnostic network events.
+ scoped_ptr<net::NetworkDelegate> system_network_delegate;
scoped_ptr<net::HostResolver> host_resolver;
scoped_ptr<net::CertVerifier> cert_verifier;
scoped_ptr<net::DnsRRResolver> dnsrr_resolver;
@@ -54,7 +56,6 @@ class IOThread : public BrowserProcessSubThread {
scoped_ptr<net::HttpTransactionFactory>
proxy_script_fetcher_http_transaction_factory;
scoped_ptr<net::URLSecurityManager> url_security_manager;
- ChromeNetworkDelegate network_delegate;
scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context;
};
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index ce79045..5452b96 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -14,52 +14,46 @@
namespace {
-// Get the event router from the request context. Currently only
-// ChromeURLRequestContexts use a network delegate, so the cast is guaranteed to
-// work.
-const ExtensionIOEventRouter* GetIOEventRouter(
- net::URLRequestContext* context) {
- return static_cast<ChromeURLRequestContext*>(context)->
- extension_io_event_router();
-}
-
// If the |request| failed due to problems with a proxy, forward the error to
// the proxy extension API.
-void ForwardProxyErrors(net::URLRequest* request) {
+void ForwardProxyErrors(net::URLRequest* request,
+ ExtensionIOEventRouter* router) {
if (request->status().status() == net::URLRequestStatus::FAILED) {
switch (request->status().os_error()) {
case net::ERR_PROXY_AUTH_UNSUPPORTED:
case net::ERR_PROXY_CONNECTION_FAILED:
case net::ERR_TUNNEL_CONNECTION_FAILED:
ExtensionProxyEventRouter::GetInstance()->OnProxyError(
- GetIOEventRouter(request->context()),
- request->status().os_error());
+ router, request->status().os_error());
}
}
}
} // namespace
-ChromeNetworkDelegate::ChromeNetworkDelegate() {}
+ChromeNetworkDelegate::ChromeNetworkDelegate(
+ ExtensionIOEventRouter* extension_io_event_router)
+ : extension_io_event_router_(extension_io_event_router) {
+ DCHECK(extension_io_event_router);
+}
+
ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
void ChromeNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
- GetIOEventRouter(request->context()), request->url(), request->method());
+ extension_io_event_router_, request->url(), request->method());
}
void ChromeNetworkDelegate::OnSendHttpRequest(
net::HttpRequestHeaders* headers) {
DCHECK(headers);
-
- // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here.
}
void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
- ForwardProxyErrors(request);
+ ForwardProxyErrors(request, extension_io_event_router_);
}
void ChromeNetworkDelegate::OnReadCompleted(net::URLRequest* request,
int bytes_read) {
- ForwardProxyErrors(request);
+ ForwardProxyErrors(request, extension_io_event_router_);
}
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index 06c7c93..fbac036 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -7,25 +7,26 @@
#pragma once
#include "base/basictypes.h"
-#include "net/http/http_network_delegate.h"
+#include "net/base/network_delegate.h"
+
+class ExtensionIOEventRouter;
// ChromeNetworkDelegate is the central point from within the chrome code to
// add hooks into the network stack.
-class ChromeNetworkDelegate : public net::HttpNetworkDelegate {
+class ChromeNetworkDelegate : public net::NetworkDelegate {
public:
- ChromeNetworkDelegate();
+ explicit ChromeNetworkDelegate(
+ ExtensionIOEventRouter* extension_io_event_router);
~ChromeNetworkDelegate();
- // net::HttpNetworkDelegate methods:
+ private:
+ // NetworkDelegate methods:
virtual void OnBeforeURLRequest(net::URLRequest* request);
virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers);
virtual void OnResponseStarted(net::URLRequest* request);
virtual void OnReadCompleted(net::URLRequest* request, int bytes_read);
- // TODO(willchan): Add functions for consumers to register ways to
- // access/modify the request.
-
- private:
+ ExtensionIOEventRouter* const extension_io_event_router_;
DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
};
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 8dbf13d..081b5e5 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -15,7 +15,6 @@
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_io_event_router.h"
#include "chrome/browser/extensions/extension_webrequest_api.h"
#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
@@ -91,10 +90,6 @@ class ChromeURLRequestContext : public net::URLRequestContext {
return extension_info_map_;
}
- const ExtensionIOEventRouter* extension_io_event_router() const {
- return extension_io_event_router_;
- }
-
prerender::PrerenderManager* prerender_manager() {
return prerender_manager_.get();
}
@@ -136,9 +131,6 @@ class ChromeURLRequestContext : public net::URLRequestContext {
void set_extension_info_map(ExtensionInfoMap* map) {
extension_info_map_ = map;
}
- void set_extension_io_event_router(ExtensionIOEventRouter* router) {
- extension_io_event_router_ = router;
- }
void set_prerender_manager(prerender::PrerenderManager* prerender_manager) {
prerender_manager_ = prerender_manager;
}
@@ -169,7 +161,6 @@ class ChromeURLRequestContext : public net::URLRequestContext {
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
// TODO(aa): This should use chrome/common/extensions/extension_set.h.
scoped_refptr<ExtensionInfoMap> extension_info_map_;
- scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
scoped_refptr<prerender::PrerenderManager> prerender_manager_;
scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_;
scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_;
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc
index ac8cf03..72cce73 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc
@@ -9,10 +9,12 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/extensions/extension_io_event_router.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_cookie_policy.h"
#include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h"
#include "chrome/browser/net/chrome_net_log.h"
+#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/common/url_constants.h"
#include "net/ftp/ftp_network_layer.h"
@@ -101,18 +103,17 @@ void OffTheRecordProfileIOData::LazyInitializeInternal() const {
main_request_context_->set_net_log(lazy_params_->io_thread->net_log());
extensions_request_context_->set_net_log(lazy_params_->io_thread->net_log());
+ extension_io_event_router_ = profile_params.extension_io_event_router;
+ network_delegate_.reset(
+ new ChromeNetworkDelegate(extension_io_event_router_));
+ main_request_context_->set_network_delegate(network_delegate_.get());
+
main_request_context_->set_host_resolver(
io_thread_globals->host_resolver.get());
main_request_context_->set_cert_verifier(
io_thread_globals->cert_verifier.get());
main_request_context_->set_dnsrr_resolver(
io_thread_globals->dnsrr_resolver.get());
- // TODO(willchan): Enable this when we can support ExtensionIOEventRouter for
- // OTR profiles.
-#if 0
- main_request_context_->set_network_delegate(
- &io_thread_globals->network_delegate);
-#endif
main_request_context_->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h
index 6ce50f3..98d73f7 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.h
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.h
@@ -101,6 +101,8 @@ class OffTheRecordProfileIOData : public ProfileIOData {
mutable scoped_refptr<RequestContext> media_request_context_;
mutable scoped_refptr<RequestContext> extensions_request_context_;
+ mutable scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
+ mutable scoped_ptr<net::NetworkDelegate> network_delegate_;
mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_;
mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index c746a63..3fe1945 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -8,10 +8,12 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/extensions/extension_io_event_router.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_cookie_policy.h"
#include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h"
#include "chrome/browser/net/chrome_net_log.h"
+#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -141,6 +143,12 @@ void ProfileImplIOData::LazyInitializeInternal() const {
media_request_context_->set_net_log(lazy_params_->io_thread->net_log());
extensions_request_context_->set_net_log(lazy_params_->io_thread->net_log());
+ extension_io_event_router_ = profile_params.extension_io_event_router;
+ network_delegate_.reset(
+ new ChromeNetworkDelegate(extension_io_event_router_));
+ main_request_context_->set_network_delegate(network_delegate_.get());
+ media_request_context_->set_network_delegate(network_delegate_.get());
+
main_request_context_->set_host_resolver(
io_thread_globals->host_resolver.get());
media_request_context_->set_host_resolver(
@@ -153,13 +161,6 @@ void ProfileImplIOData::LazyInitializeInternal() const {
io_thread_globals->dnsrr_resolver.get());
media_request_context_->set_dnsrr_resolver(
io_thread_globals->dnsrr_resolver.get());
- main_request_context_->set_network_delegate(
- &io_thread_globals->network_delegate);
- // TODO(willchan): Enable for media request context.
-#if 0
- media_request_context_->set_network_delegate(
- &io_thread_globals->network_delegate);
-#endif
main_request_context_->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
media_request_context_->set_http_auth_handler_factory(
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index ffc5e82..d4fcfc0 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -10,6 +10,13 @@
#include "base/ref_counted.h"
#include "chrome/browser/profiles/profile_io_data.h"
+class ExtensionIOEventRouter;
+namespace net {
+class NetworkDelegate;
+class DnsCertProvenanceChecker;
+class HttpTransactionFactory;
+} // namespace net
+
class ProfileImplIOData : public ProfileIOData {
public:
class Handle {
@@ -104,6 +111,8 @@ class ProfileImplIOData : public ProfileIOData {
mutable scoped_refptr<RequestContext> media_request_context_;
mutable scoped_refptr<RequestContext> extensions_request_context_;
+ mutable scoped_refptr<ExtensionIOEventRouter> extension_io_event_router_;
+ mutable scoped_ptr<net::NetworkDelegate> network_delegate_;
mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_;
mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_;
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 57313e5..9553c85 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -10,6 +10,7 @@
#include "base/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/extensions/extension_io_event_router.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
#include "chrome/browser/net/pref_proxy_config_service.h"
@@ -253,8 +254,6 @@ void ProfileIOData::ApplyProfileParamsToContext(
context->set_blob_storage_context(profile_params.blob_storage_context);
context->set_file_system_context(profile_params.file_system_context);
context->set_extension_info_map(profile_params.extension_info_map);
- context->set_extension_io_event_router(
- profile_params.extension_io_event_router);
context->set_prerender_manager(profile_params.prerender_manager);
context->set_protocol_handler_registry(
profile_params.protocol_handler_registry);
diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc
new file mode 100644
index 0000000..b00e671
--- /dev/null
+++ b/net/base/network_delegate.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 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.
+
+#include "net/base/network_delegate.h"
+
+#include "base/logging.h"
+
+namespace net {
+
+void NetworkDelegate::NotifyBeforeURLRequest(URLRequest* request) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(request);
+ OnBeforeURLRequest(request);
+}
+
+void NetworkDelegate::NotifySendHttpRequest(HttpRequestHeaders* headers) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(headers);
+ OnSendHttpRequest(headers);
+}
+
+void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(request);
+ OnResponseStarted(request);
+}
+
+void NetworkDelegate::NotifyReadCompleted(URLRequest* request, int bytes_read) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(request);
+ OnReadCompleted(request, bytes_read);
+}
+
+} // namespace net
diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h
new file mode 100644
index 0000000..c4f2b65
--- /dev/null
+++ b/net/base/network_delegate.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 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 NET_BASE_NETWORK_DELEGATE_H_
+#define NET_BASE_NETWORK_DELEGATE_H_
+#pragma once
+
+#include "base/threading/non_thread_safe.h"
+
+namespace net {
+
+// NOTE: Layering violations!
+// We decided to accept these violations (depending
+// on other net/ submodules from net/base/), because otherwise NetworkDelegate
+// would have to be broken up into too many smaller interfaces targeted to each
+// submodule. Also, since the lower levels in net/ may callback into higher
+// levels, we may encounter dangerous casting issues.
+//
+// NOTE: It is not okay to add any compile-time dependencies on symbols outside
+// of net/base here, because we have a net_base library. Forward declarations
+// are ok.
+class HttpRequestHeaders;
+class URLRequest;
+
+class NetworkDelegate : public base::NonThreadSafe {
+ public:
+ virtual ~NetworkDelegate() {}
+
+ // Notification interface called by the network stack. Note that these
+ // functions mostly forward to the private virtuals. They also add some sanity
+ // checking on parameters.
+ void NotifyBeforeURLRequest(URLRequest* request);
+ void NotifySendHttpRequest(HttpRequestHeaders* headers);
+ void NotifyResponseStarted(URLRequest* request);
+ void NotifyReadCompleted(URLRequest* request, int bytes_read);
+
+ private:
+ // This is the interface for subclasses of NetworkDelegate to implement. This
+ // member functions will be called by the respective public notification
+ // member function, which will perform basic sanity checking.
+
+ // Called before a request is sent.
+ virtual void OnBeforeURLRequest(URLRequest* request) = 0;
+
+ // Called right before the HTTP headers are sent. Allows the delegate to
+ // read/write |headers| before they get sent out.
+ virtual void OnSendHttpRequest(HttpRequestHeaders* headers) = 0;
+
+ // This corresponds to URLRequestDelegate::OnResponseStarted.
+ virtual void OnResponseStarted(URLRequest* request) = 0;
+
+ // This corresponds to URLRequestDelegate::OnReadCompleted.
+ virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0;
+};
+
+} // namespace net
+
+#endif // NET_BASE_NETWORK_DELEGATE_H_
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index a821a30..830fbaa 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -48,7 +48,7 @@ HttpNetworkSession* CreateNetworkSession(
SSLHostInfoFactory* ssl_host_info_factory,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
- HttpNetworkDelegate* network_delegate,
+ NetworkDelegate* network_delegate,
NetLog* net_log) {
HttpNetworkSession::Params params;
params.host_resolver = host_resolver;
@@ -316,7 +316,7 @@ HttpCache::HttpCache(HostResolver* host_resolver,
ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
- HttpNetworkDelegate* network_delegate,
+ NetworkDelegate* network_delegate,
NetLog* net_log,
BackendFactory* backend_factory)
: net_log_(net_log),
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index ba7a18e..b33689d 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -46,12 +46,12 @@ class DnsCertProvenanceChecker;
class DnsRRResolver;
class HostResolver;
class HttpAuthHandlerFactory;
-class HttpNetworkDelegate;
class HttpNetworkSession;
struct HttpRequestInfo;
class HttpResponseInfo;
class IOBuffer;
class NetLog;
+class NetworkDelegate;
class ProxyService;
class SSLConfigService;
class ViewCacheHelper;
@@ -124,7 +124,7 @@ class HttpCache : public HttpTransactionFactory,
ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
- HttpNetworkDelegate* network_delegate,
+ NetworkDelegate* network_delegate,
NetLog* net_log,
BackendFactory* backend_factory);
diff --git a/net/http/http_network_delegate.h b/net/http/http_network_delegate.h
deleted file mode 100644
index a4b217a..0000000
--- a/net/http/http_network_delegate.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2010 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 NET_HTTP_HTTP_NETWORK_DELEGATE_H_
-#define NET_HTTP_HTTP_NETWORK_DELEGATE_H_
-#pragma once
-
-namespace net {
-
-class HttpRequestHeaders;
-class URLRequest;
-
-class HttpNetworkDelegate {
- public:
- virtual ~HttpNetworkDelegate() {}
-
- // Called before a request is sent.
- virtual void OnBeforeURLRequest(URLRequest* request) = 0;
-
- // Called right before the HTTP headers are sent. Allows the delegate to
- // read/write |headers| before they get sent out.
- virtual void OnSendHttpRequest(HttpRequestHeaders* headers) = 0;
-
- // This corresponds to URLRequestDelegate::OnResponseStarted.
- virtual void OnResponseStarted(URLRequest* request) = 0;
-
- // This corresponds to URLRequestDelegate::OnReadCompleted.
- virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0;
-};
-
-} // namespace net
-
-#endif // NET_HTTP_HTTP_NETWORK_DELEGATE_H_
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h
index da92761..db3d809 100644
--- a/net/http/http_network_layer.h
+++ b/net/http/http_network_layer.h
@@ -21,9 +21,9 @@ class DnsCertProvenanceChecker;
class DnsRRResolver;
class HostResolver;
class HttpAuthHandlerFactory;
-class HttpNetworkDelegate;
class HttpNetworkSession;
class NetLog;
+class NetworkDelegate;
class ProxyService;
class SpdySessionPool;
class SSLConfigService;
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 5c8f705..9a4b85c 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -29,11 +29,11 @@ class DnsCertProvenanceChecker;
class DnsRRResolver;
class HostResolver;
class HttpAuthHandlerFactory;
-class HttpNetworkDelegate;
class HttpNetworkSessionPeer;
class HttpProxyClientSocketPool;
class HttpResponseBodyDrainer;
class NetLog;
+class NetworkDelegate;
class ProxyService;
class SSLConfigService;
class SSLHostInfoFactory;
@@ -65,7 +65,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
SSLHostInfoFactory* ssl_host_info_factory;
SSLConfigService* ssl_config_service;
HttpAuthHandlerFactory* http_auth_handler_factory;
- HttpNetworkDelegate* network_delegate;
+ NetworkDelegate* network_delegate;
NetLog* net_log;
};
@@ -117,7 +117,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
HttpAuthHandlerFactory* http_auth_handler_factory() {
return http_auth_handler_factory_;
}
- HttpNetworkDelegate* network_delegate() {
+ NetworkDelegate* network_delegate() {
return network_delegate_;
}
@@ -156,7 +156,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
~HttpNetworkSession();
NetLog* const net_log_;
- HttpNetworkDelegate* const network_delegate_;
+ NetworkDelegate* const network_delegate_;
CertVerifier* const cert_verifier_;
HttpAuthHandlerFactory* const http_auth_handler_factory_;
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 98b9cd7..d3ed391 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -24,6 +24,7 @@
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
+#include "net/base/network_delegate.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_connection_status_flags.h"
#include "net/base/upload_data_stream.h"
@@ -33,7 +34,6 @@
#include "net/http/http_basic_stream.h"
#include "net/http/http_chunked_decoder.h"
#include "net/http/http_net_log_params.h"
-#include "net/http/http_network_delegate.h"
#include "net/http/http_network_session.h"
#include "net/http/http_proxy_client_socket.h"
#include "net/http/http_proxy_client_socket_pool.h"
@@ -685,7 +685,7 @@ int HttpNetworkTransaction::DoSendRequest() {
&request_headers_);
if (session_->network_delegate())
- session_->network_delegate()->OnSendHttpRequest(&request_headers_);
+ session_->network_delegate()->NotifySendHttpRequest(&request_headers_);
}
headers_valid_ = false;
diff --git a/net/net.gyp b/net/net.gyp
index c923165..58cf8fe 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -142,6 +142,8 @@
'base/network_change_notifier_win.h',
'base/network_config_watcher_mac.cc',
'base/network_config_watcher_mac.h',
+ 'base/network_delegate.cc',
+ 'base/network_delegate.h',
'base/nss_memio.c',
'base/nss_memio.h',
'base/openssl_memory_private_key_store.cc',
@@ -484,7 +486,6 @@
'http/http_chunked_decoder.h',
'http/http_net_log_params.cc',
'http/http_net_log_params.h',
- 'http/http_network_delegate.h',
'http/http_network_layer.cc',
'http/http_network_layer.h',
'http/http_network_session.cc',
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index ca8aacb..e25bac6 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -13,9 +13,9 @@
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
+#include "net/base/network_delegate.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/upload_data.h"
-#include "net/http/http_network_delegate.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request_context.h"
@@ -370,7 +370,7 @@ void URLRequest::StartJob(URLRequestJob* job) {
// TODO(mpcomplete): pass in request ID?
// TODO(mpcomplete): allow delegate to potentially delay/cancel request.
if (context_ && context_->network_delegate())
- context_->network_delegate()->OnBeforeURLRequest(this);
+ context_->network_delegate()->NotifyBeforeURLRequest(this);
net_log_.BeginEvent(
net::NetLog::TYPE_URL_REQUEST_START_JOB,
@@ -494,7 +494,7 @@ void URLRequest::ResponseStarted() {
RestartWithJob(job);
} else {
if (context_ && context_->network_delegate())
- context_->network_delegate()->OnResponseStarted(this);
+ context_->network_delegate()->NotifyResponseStarted(this);
if (delegate_)
delegate_->OnResponseStarted(this);
}
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index fa61297..7976126 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -29,8 +29,8 @@ class DnsRRResolver;
class FtpTransactionFactory;
class HostResolver;
class HttpAuthHandlerFactory;
-class HttpNetworkDelegate;
class HttpTransactionFactory;
+class NetworkDelegate;
class SSLConfigService;
class URLRequest;
@@ -120,10 +120,10 @@ class URLRequestContext
ftp_transaction_factory_ = factory;
}
- void set_network_delegate(HttpNetworkDelegate* network_delegate) {
+ void set_network_delegate(NetworkDelegate* network_delegate) {
network_delegate_ = network_delegate;
}
- HttpNetworkDelegate* network_delegate() const { return network_delegate_; }
+ NetworkDelegate* network_delegate() const { return network_delegate_; }
// Gets the cookie store for this context (may be null, in which case
// cookies are not stored).
@@ -196,7 +196,7 @@ class URLRequestContext
HttpAuthHandlerFactory* http_auth_handler_factory_;
scoped_refptr<ProxyService> proxy_service_;
scoped_refptr<SSLConfigService> ssl_config_service_;
- HttpNetworkDelegate* network_delegate_;
+ NetworkDelegate* network_delegate_;
scoped_refptr<CookieStore> cookie_store_;
CookiePolicy* cookie_policy_;
scoped_refptr<TransportSecurityState> transport_security_state_;
diff --git a/net/url_request/url_request_context_storage.cc b/net/url_request/url_request_context_storage.cc
index 24b49ce..dd48887 100644
--- a/net/url_request/url_request_context_storage.cc
+++ b/net/url_request/url_request_context_storage.cc
@@ -11,9 +11,9 @@
#include "net/base/dnsrr_resolver.h"
#include "net/base/host_resolver.h"
#include "net/base/net_log.h"
+#include "net/base/network_delegate.h"
#include "net/ftp/ftp_transaction_factory.h"
#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_network_delegate.h"
#include "net/http/http_transaction_factory.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h"
@@ -72,7 +72,7 @@ void URLRequestContextStorage::set_ssl_config_service(
}
void URLRequestContextStorage::set_network_delegate(
- HttpNetworkDelegate* network_delegate) {
+ NetworkDelegate* network_delegate) {
context_->set_network_delegate(network_delegate);
network_delegate_.reset(network_delegate);
}
diff --git a/net/url_request/url_request_context_storage.h b/net/url_request/url_request_context_storage.h
index 2bcd8f0a..faa6c69 100644
--- a/net/url_request/url_request_context_storage.h
+++ b/net/url_request/url_request_context_storage.h
@@ -20,9 +20,9 @@ class DnsRRResolver;
class FtpTransactionFactory;
class HostResolver;
class HttpAuthHandlerFactory;
-class HttpNetworkDelegate;
class HttpTransactionFactory;
class NetLog;
+class NetworkDelegate;
class ProxyService;
class SSLConfigService;
class TransportSecurityState;
@@ -50,7 +50,7 @@ class URLRequestContextStorage {
HttpAuthHandlerFactory* http_auth_handler_factory);
void set_proxy_service(ProxyService* proxy_service);
void set_ssl_config_service(SSLConfigService* ssl_config_service);
- void set_network_delegate(HttpNetworkDelegate* network_delegate);
+ void set_network_delegate(NetworkDelegate* network_delegate);
void set_cookie_store(CookieStore* cookie_store);
void set_cookie_policy(CookiePolicy* cookie_policy);
void set_transport_security_state(
@@ -76,7 +76,7 @@ class URLRequestContextStorage {
// TODO(willchan): Remove refcounting on these members.
scoped_refptr<ProxyService> proxy_service_;
scoped_refptr<SSLConfigService> ssl_config_service_;
- scoped_ptr<HttpNetworkDelegate> network_delegate_;
+ scoped_ptr<NetworkDelegate> network_delegate_;
scoped_refptr<CookieStore> cookie_store_;
scoped_ptr<CookiePolicy> cookie_policy_;
scoped_refptr<TransportSecurityState> transport_security_state_;
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 2aede15..c13b8f5 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -14,7 +14,7 @@
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
-#include "net/http/http_network_delegate.h"
+#include "net/base/network_delegate.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
@@ -538,7 +538,7 @@ void URLRequestJob::NotifyReadComplete(int bytes_read) {
if (ReadFilteredData(&filter_bytes_read)) {
postfilter_bytes_read_ += filter_bytes_read;
if (request_->context() && request_->context()->network_delegate()) {
- request_->context()->network_delegate()->OnReadCompleted(
+ request_->context()->network_delegate()->NotifyReadCompleted(
request_, filter_bytes_read);
}
request_->delegate()->OnReadCompleted(request_, filter_bytes_read);
@@ -546,7 +546,7 @@ void URLRequestJob::NotifyReadComplete(int bytes_read) {
} else {
postfilter_bytes_read_ += bytes_read;
if (request_->context() && request_->context()->network_delegate()) {
- request_->context()->network_delegate()->OnReadCompleted(
+ request_->context()->network_delegate()->NotifyReadCompleted(
request_, bytes_read);
}
request_->delegate()->OnReadCompleted(request_, bytes_read);
@@ -621,7 +621,8 @@ void URLRequestJob::CompleteNotifyDone() {
if (has_handled_response_) {
// We signal the error by calling OnReadComplete with a bytes_read of -1.
if (request_->context() && request_->context()->network_delegate())
- request_->context()->network_delegate()->OnReadCompleted(request_, -1);
+ request_->context()->network_delegate()->NotifyReadCompleted(
+ request_, -1);
request_->delegate()->OnReadCompleted(request_, -1);
} else {
has_handled_response_ = true;
diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc
index 4a518c0..5e76729 100644
--- a/net/url_request/url_request_test_util.cc
+++ b/net/url_request/url_request_test_util.cc
@@ -289,27 +289,28 @@ void TestDelegate::OnResponseCompleted(net::URLRequest* request) {
MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
-TestHttpNetworkDelegate::TestHttpNetworkDelegate()
+TestNetworkDelegate::TestNetworkDelegate()
: last_os_error_(0),
error_count_(0) {
}
-TestHttpNetworkDelegate::~TestHttpNetworkDelegate() {}
+TestNetworkDelegate::~TestNetworkDelegate() {}
-void TestHttpNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
+void TestNetworkDelegate::OnBeforeURLRequest(net::URLRequest* request) {
}
-void TestHttpNetworkDelegate::OnSendHttpRequest(
+void TestNetworkDelegate::OnSendHttpRequest(
net::HttpRequestHeaders* headers) {
}
-void TestHttpNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
+void TestNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
if (request->status().status() == net::URLRequestStatus::FAILED) {
error_count_++;
last_os_error_ = request->status().os_error();
}
}
-void TestHttpNetworkDelegate::OnReadCompleted(net::URLRequest* request,
+
+void TestNetworkDelegate::OnReadCompleted(net::URLRequest* request,
int bytes_read) {
if (request->status().status() == net::URLRequestStatus::FAILED) {
error_count_++;
diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h
index c02344c..47ecff4 100644
--- a/net/url_request/url_request_test_util.h
+++ b/net/url_request/url_request_test_util.h
@@ -23,12 +23,12 @@
#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/base/network_delegate.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/disk_cache/disk_cache.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
-#include "net/http/http_network_delegate.h"
#include "net/http/http_network_layer.h"
#include "net/test/test_server.h"
#include "net/url_request/url_request.h"
@@ -191,21 +191,21 @@ class TestDelegate : public net::URLRequest::Delegate {
//-----------------------------------------------------------------------------
-class TestHttpNetworkDelegate : public net::HttpNetworkDelegate {
+class TestNetworkDelegate : public net::NetworkDelegate {
public:
- TestHttpNetworkDelegate();
- virtual ~TestHttpNetworkDelegate();
+ TestNetworkDelegate();
+ virtual ~TestNetworkDelegate();
- // net::HttpNetworkDelegate:
+ int last_os_error() const { return last_os_error_; }
+ int error_count() const { return error_count_; }
+
+ private:
+ // net::NetworkDelegate:
virtual void OnBeforeURLRequest(net::URLRequest* request);
virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers);
virtual void OnResponseStarted(net::URLRequest* request);
virtual void OnReadCompleted(net::URLRequest* request, int bytes_read);
- int last_os_error() const { return last_os_error_; }
- int error_count() const { return error_count_; }
-
- private:
int last_os_error_;
int error_count_;
};
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index c3b8e37..5e03f9b 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -241,7 +241,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) {
net::URLRequest r(GURL("https://www.redirect.com/"), &d);
scoped_refptr<TestURLRequestContext> context(
new TestURLRequestContext(test_server_.host_port_pair().ToString()));
- TestHttpNetworkDelegate network_delegate;
+ TestNetworkDelegate network_delegate;
context->set_network_delegate(&network_delegate);
r.set_context(context);
@@ -2408,9 +2408,9 @@ TEST_F(URLRequestTest, NetworkDelegateProxyError) {
scoped_ptr<net::MockHostResolverBase> host_resolver(
new net::MockHostResolver);
host_resolver->rules()->AddSimulatedFailure("*");
+ TestNetworkDelegate network_delegate;
scoped_refptr<TestURLRequestContext> context(
new TestURLRequestContext("myproxy:70", host_resolver.release()));
- TestHttpNetworkDelegate network_delegate;
context->set_network_delegate(&network_delegate);
req.set_context(context);