summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 16:39:44 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 16:39:44 +0000
commitac039524eca084f5169500f5d977276d122d2a02 (patch)
tree0f96468a44177234f2c7d4fd63bd84b38b982c9e
parent7c186b16ffa7f386a60223157daa08a897052681 (diff)
downloadchromium_src-ac039524eca084f5169500f5d977276d122d2a02.zip
chromium_src-ac039524eca084f5169500f5d977276d122d2a02.tar.gz
chromium_src-ac039524eca084f5169500f5d977276d122d2a02.tar.bz2
Add a net::HttpNetworkDelegate and a ChromeNetworkDelegate.
net::HttpNetworkDelegate is an interface for providing hooks into http network activity. ChromeNetworkDelgate implements this interface in chrome/ code. In the future, it might also implement other interfaces. My only current intended consumer for this would be extensions. There's no actual behavior change, this is all just plumbing for now. BUG=29314 Review URL: http://codereview.chromium.org/2749015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49804 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/io_thread.h2
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc18
-rw-r--r--chrome/browser/net/chrome_network_delegate.h30
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc37
-rw-r--r--chrome/browser/net/chrome_url_request_context.h5
-rw-r--r--chrome/browser/net/connection_tester.cc2
-rwxr-xr-xchrome/chrome_browser.gypi2
-rw-r--r--chrome/service/net/service_url_request_context.cc4
-rw-r--r--chrome_frame/test/test_server_test.cc1
-rw-r--r--net/http/http_cache.cc2
-rw-r--r--net/http/http_cache.h2
-rw-r--r--net/http/http_network_delegate.h24
-rw-r--r--net/http/http_network_layer.cc7
-rw-r--r--net/http/http_network_layer.h4
-rw-r--r--net/http/http_network_layer_unittest.cc6
-rw-r--r--net/http/http_network_session.cc2
-rw-r--r--net/http/http_network_session.h8
-rw-r--r--net/http/http_network_transaction.cc5
-rw-r--r--net/http/http_network_transaction_unittest.cc4
-rw-r--r--net/net.gyp1
-rw-r--r--net/proxy/proxy_script_fetcher_unittest.cc2
-rw-r--r--net/spdy/spdy_http_stream_unittest.cc1
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc1
-rw-r--r--net/spdy/spdy_session_unittest.cc1
-rw-r--r--net/tools/fetch/fetch_client.cc2
-rw-r--r--net/url_request/url_request_context.h3
-rw-r--r--net/url_request/url_request_unittest.h1
-rw-r--r--webkit/tools/test_shell/test_shell_request_context.cc2
28 files changed, 156 insertions, 23 deletions
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index c624a99..4c7374e 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -10,6 +10,7 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "chrome/browser/browser_process_sub_thread.h"
+#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/common/net/dns.h"
#include "net/base/host_resolver.h"
@@ -36,6 +37,7 @@ class IOThread : public BrowserProcessSubThread {
scoped_refptr<net::HostResolver> host_resolver;
scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory;
scoped_ptr<net::URLSecurityManager> url_security_manager;
+ ChromeNetworkDelegate network_delegate;
};
IOThread();
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
new file mode 100644
index 0000000..0944559
--- /dev/null
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -0,0 +1,18 @@
+// 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.
+
+#include "chrome/browser/net/chrome_network_delegate.h"
+
+#include "base/logging.h"
+#include "net/http/http_request_headers.h"
+
+ChromeNetworkDelegate::ChromeNetworkDelegate() {}
+ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
+
+void ChromeNetworkDelegate::OnSendHttpRequest(
+ net::HttpRequestHeaders* headers) {
+ DCHECK(headers);
+
+ // TODO(willchan): Add Chrome-side hooks to listen / mutate requests here.
+}
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
new file mode 100644
index 0000000..75de4c7
--- /dev/null
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -0,0 +1,30 @@
+// 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 CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_
+#define CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_
+
+#include "base/basictypes.h"
+#include "net/http/http_network_delegate.h"
+
+// ChromeNetworkDelegate is the central point from within the chrome code to
+// add hooks into the network stack. In the future, we can use this for
+// extensions to register hooks for the network stack.
+class ChromeNetworkDelegate : public net::HttpNetworkDelegate {
+ public:
+ ChromeNetworkDelegate();
+ ~ChromeNetworkDelegate();
+
+ // net::HttpNetworkDelegate methods:
+
+ virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers);
+
+ // TODO(willchan): Add functions for consumers to register ways to
+ // access/modify the request.
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
+};
+
+#endif // CHROME_BROWSER_NET_CHROME_NETWORK_DELEGATE_H_
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index ed36a1c..ff90824 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -232,16 +232,18 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
ChromeURLRequestContext* context = new ChromeURLRequestContext;
ApplyProfileParametersToContext(context);
+ IOThread::Globals* io_thread_globals = io_thread()->globals();
+
// Global host resolver for the context.
- context->set_host_resolver(io_thread()->globals()->host_resolver);
+ context->set_host_resolver(io_thread_globals->host_resolver);
context->set_http_auth_handler_factory(
- io_thread()->globals()->http_auth_handler_factory.get());
+ io_thread_globals->http_auth_handler_factory.get());
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
context->set_proxy_service(
- CreateProxyService(io_thread()->globals()->network_change_notifier.get(),
- io_thread()->globals()->net_log.get(),
+ CreateProxyService(io_thread_globals->network_change_notifier.get(),
+ io_thread_globals->net_log.get(),
context,
proxy_config_service_.release(),
command_line,
@@ -251,12 +253,13 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
net::DISK_CACHE, disk_cache_path_, cache_size_,
ChromeThread::GetMessageLoopProxyForThread(ChromeThread::CACHE));
net::HttpCache* cache =
- new net::HttpCache(io_thread()->globals()->network_change_notifier.get(),
+ new net::HttpCache(io_thread_globals->network_change_notifier.get(),
context->host_resolver(),
context->proxy_service(),
context->ssl_config_service(),
context->http_auth_handler_factory(),
- io_thread()->globals()->net_log.get(),
+ &io_thread_globals->network_delegate,
+ io_thread_globals->net_log.get(),
backend);
if (command_line.HasSwitch(switches::kDisableByteRangeSupport))
@@ -300,7 +303,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
net::SetURLRequestContextForOCSP(context);
#endif
- context->set_net_log(io_thread()->globals()->net_log.get());
+ context->set_net_log(io_thread_globals->net_log.get());
return context;
}
@@ -322,6 +325,8 @@ ChromeURLRequestContext* FactoryForExtensions::Create() {
ChromeURLRequestContext* context = new ChromeURLRequestContext;
ApplyProfileParametersToContext(context);
+ IOThread::Globals* io_thread_globals = io_thread()->globals();
+
// All we care about for extensions is the cookie store.
DCHECK(!cookie_store_path_.empty());
@@ -336,7 +341,7 @@ ChromeURLRequestContext* FactoryForExtensions::Create() {
context->set_cookie_store(cookie_monster);
// TODO(cbentzel): How should extensions handle HTTP Authentication?
context->set_http_auth_handler_factory(
- io_thread()->globals()->http_auth_handler_factory.get());
+ io_thread_globals->http_auth_handler_factory.get());
return context;
}
@@ -364,6 +369,8 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
ChromeURLRequestContext* original_context =
original_context_getter_->GetIOContext();
+ IOThread::Globals* io_thread_globals = io_thread()->globals();
+
// Share the same proxy service, host resolver, and http_auth_handler_factory
// as the original profile.
context->set_host_resolver(original_context->host_resolver());
@@ -375,12 +382,13 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
net::HttpCache::DefaultBackend::InMemory(0);
net::HttpCache* cache =
- new net::HttpCache(io_thread()->globals()->network_change_notifier.get(),
+ new net::HttpCache(io_thread_globals->network_change_notifier.get(),
context->host_resolver(),
context->proxy_service(),
context->ssl_config_service(),
context->http_auth_handler_factory(),
- io_thread()->globals()->net_log.get(),
+ &io_thread_globals->network_delegate,
+ io_thread_globals->net_log.get(),
backend);
context->set_cookie_store(new net::CookieMonster(NULL,
cookie_monster_delegate_));
@@ -399,7 +407,7 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() {
context->set_appcache_service(
new ChromeAppCacheService(profile_dir_path_, context));
- context->set_net_log(io_thread()->globals()->net_log.get());
+ context->set_net_log(io_thread_globals->net_log.get());
return context;
}
@@ -436,6 +444,8 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
ChromeURLRequestContext* main_context =
main_context_getter_->GetIOContext();
+ IOThread::Globals* io_thread_globals = io_thread()->globals();
+
// Share the same proxy service of the common profile.
context->set_proxy_service(main_context->proxy_service());
context->set_http_auth_handler_factory(
@@ -471,12 +481,13 @@ ChromeURLRequestContext* FactoryForMedia::Create() {
// If original HttpCache doesn't exist, simply construct one with a whole
// new set of network stack.
cache = new net::HttpCache(
- io_thread()->globals()->network_change_notifier.get(),
+ io_thread_globals->network_change_notifier.get(),
main_context->host_resolver(),
main_context->proxy_service(),
main_context->ssl_config_service(),
main_context->http_auth_handler_factory(),
- io_thread()->globals()->net_log.get(),
+ &io_thread_globals->network_delegate,
+ io_thread_globals->net_log.get(),
backend);
}
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index f43f971..8f08d87 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -29,6 +29,7 @@ class CommandLine;
class Profile;
namespace net {
+class NetworkDelegate;
class ProxyConfig;
}
@@ -218,6 +219,10 @@ class ChromeURLRequestContext : public URLRequestContext {
void set_net_log(net::NetLog* net_log) {
net_log_ = net_log;
}
+ void set_network_delegate(
+ net::HttpNetworkDelegate* network_delegate) {
+ network_delegate_ = network_delegate;
+ }
// Callback for when the accept language changes.
void OnAcceptLanguageChange(const std::string& accept_language);
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 6e72380..3c7c299 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -59,6 +59,7 @@ class ExperimentURLRequestContext : public URLRequestContext {
proxy_service_,
ssl_config_service_,
http_auth_handler_factory_,
+ NULL,
NULL),
net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
@@ -401,4 +402,3 @@ void ConnectionTester::OnExperimentCompleted(int result) {
StartNextExperiment();
}
}
-
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index de982fd..3cd9e04 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1692,6 +1692,8 @@
'browser/net/chrome_cookie_policy.h',
'browser/net/chrome_net_log.cc',
'browser/net/chrome_net_log.h',
+ 'browser/net/chrome_network_delegate.cc',
+ 'browser/net/chrome_network_delegate.h',
'browser/net/chrome_url_request_context.cc',
'browser/net/chrome_url_request_context.h',
'browser/net/connection_tester.cc',
diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc
index 572ccb8..3ca57cd 100644
--- a/chrome/service/net/service_url_request_context.cc
+++ b/chrome/service/net/service_url_request_context.cc
@@ -40,7 +40,8 @@ ServiceURLRequestContext::ServiceURLRequestContext() {
proxy_service_,
ssl_config_service_,
http_auth_handler_factory_,
- NULL /*net_log*/),
+ NULL /* network_delegate */,
+ NULL /* net_log */),
net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
cookie_store_ = new net::CookieMonster(NULL, NULL);
@@ -53,4 +54,3 @@ ServiceURLRequestContext::~ServiceURLRequestContext() {
delete http_transaction_factory_;
delete http_auth_handler_factory_;
}
-
diff --git a/chrome_frame/test/test_server_test.cc b/chrome_frame/test/test_server_test.cc
index 4ea7c1b..f658f0f 100644
--- a/chrome_frame/test/test_server_test.cc
+++ b/chrome_frame/test/test_server_test.cc
@@ -71,6 +71,7 @@ class URLRequestTestContext : public URLRequestContext {
proxy_service_,
ssl_config_service_,
http_auth_handler_factory_,
+ NULL,
NULL),
net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 162cc26..ef9198c 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -226,6 +226,7 @@ HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier,
HostResolver* host_resolver, ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log,
BackendFactory* backend_factory)
: backend_factory_(backend_factory),
@@ -235,6 +236,7 @@ HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier,
network_layer_(HttpNetworkLayer::CreateFactory(
network_change_notifier, host_resolver, proxy_service,
ssl_config_service, http_auth_handler_factory,
+ network_delegate,
net_log)),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
enable_range_support_(true) {
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index 04dc144..9ed20b4 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -40,6 +40,7 @@ namespace net {
class HostResolver;
class HttpAuthHandlerFactory;
+class HttpNetworkDelegate;
class HttpNetworkSession;
struct HttpRequestInfo;
class HttpResponseInfo;
@@ -116,6 +117,7 @@ class HttpCache : public HttpTransactionFactory,
HostResolver* host_resolver, ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log,
BackendFactory* backend_factory);
diff --git a/net/http/http_network_delegate.h b/net/http/http_network_delegate.h
new file mode 100644
index 0000000..51c6766
--- /dev/null
+++ b/net/http/http_network_delegate.h
@@ -0,0 +1,24 @@
+// 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_
+
+namespace net {
+
+class HttpRequestHeaders;
+
+class HttpNetworkDelegate {
+ public:
+ // 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;
+
+ protected:
+ virtual ~HttpNetworkDelegate() {}
+};
+
+} // namespace net
+
+#endif // NET_HTTP_HTTP_NETWORK_DELEGATE_H_
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 0b8ed96..2329627 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -26,6 +26,7 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log) {
DCHECK(proxy_service);
@@ -33,6 +34,7 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
network_change_notifier,
host_resolver, proxy_service, ssl_config_service,
http_auth_handler_factory,
+ network_delegate,
net_log);
}
@@ -54,6 +56,7 @@ HttpNetworkLayer::HttpNetworkLayer(
ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log)
: socket_factory_(socket_factory),
network_change_notifier_(network_change_notifier),
@@ -63,6 +66,7 @@ HttpNetworkLayer::HttpNetworkLayer(
session_(NULL),
spdy_session_pool_(NULL),
http_auth_handler_factory_(http_auth_handler_factory),
+ network_delegate_(network_delegate),
net_log_(net_log),
suspended_(false) {
DCHECK(proxy_service_);
@@ -76,6 +80,7 @@ HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session)
session_(session),
spdy_session_pool_(session->spdy_session_pool()),
http_auth_handler_factory_(NULL),
+ network_delegate_(NULL),
net_log_(NULL),
suspended_(false) {
DCHECK(session_.get());
@@ -114,6 +119,7 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() {
network_change_notifier_, host_resolver_, proxy_service_,
socket_factory_, ssl_config_service_, spdy_pool,
http_auth_handler_factory_,
+ network_delegate_,
net_log_);
// These were just temps for lazy-initializing HttpNetworkSession.
network_change_notifier_ = NULL;
@@ -122,6 +128,7 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() {
socket_factory_ = NULL;
http_auth_handler_factory_ = NULL;
net_log_ = NULL;
+ network_delegate_ = NULL;
}
return session_;
}
diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h
index a045798..54989410 100644
--- a/net/http/http_network_layer.h
+++ b/net/http/http_network_layer.h
@@ -16,6 +16,7 @@ namespace net {
class ClientSocketFactory;
class HostResolver;
class HttpAuthHandlerFactory;
+class HttpNetworkDelegate;
class HttpNetworkSession;
class NetLog;
class NetworkChangeNotifier;
@@ -33,6 +34,7 @@ class HttpNetworkLayer : public HttpTransactionFactory {
HostResolver* host_resolver, ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log);
// Construct a HttpNetworkLayer with an existing HttpNetworkSession which
// contains a valid ProxyService.
@@ -47,6 +49,7 @@ class HttpNetworkLayer : public HttpTransactionFactory {
ProxyService* proxy_service,
SSLConfigService* ssl_config_service,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log);
// Create a transaction factory that instantiate a network layer over an
// existing network session. Network session contains some valuable
@@ -88,6 +91,7 @@ class HttpNetworkLayer : public HttpTransactionFactory {
scoped_refptr<SpdySessionPool> spdy_session_pool_;
HttpAuthHandlerFactory* http_auth_handler_factory_;
+ HttpNetworkDelegate* network_delegate_;
NetLog* net_log_;
bool suspended_;
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc
index 780ab68..9f20943 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -18,7 +18,7 @@ class HttpNetworkLayerTest : public PlatformTest {
TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
net::HttpNetworkLayer factory(
NULL, NULL, new net::MockHostResolver, net::ProxyService::CreateNull(),
- new net::SSLConfigServiceDefaults, NULL, NULL);
+ new net::SSLConfigServiceDefaults, NULL, NULL, NULL);
scoped_ptr<net::HttpTransaction> trans;
int rv = factory.CreateTransaction(&trans);
@@ -29,7 +29,7 @@ TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
TEST_F(HttpNetworkLayerTest, Suspend) {
net::HttpNetworkLayer factory(
NULL, NULL, new net::MockHostResolver, net::ProxyService::CreateNull(),
- new net::SSLConfigServiceDefaults, NULL, NULL);
+ new net::SSLConfigServiceDefaults, NULL, NULL, NULL);
scoped_ptr<net::HttpTransaction> trans;
int rv = factory.CreateTransaction(&trans);
@@ -71,7 +71,7 @@ TEST_F(HttpNetworkLayerTest, GET) {
new net::MockHostResolver,
net::ProxyService::CreateNull(),
new net::SSLConfigServiceDefaults,
- NULL, NULL);
+ NULL, NULL, NULL);
TestCompletionCallback callback;
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index c9a716e..1083626 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -43,6 +43,7 @@ HttpNetworkSession::HttpNetworkSession(
SSLConfigService* ssl_config_service,
SpdySessionPool* spdy_session_pool,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log)
: network_change_notifier_(network_change_notifier),
// TODO(vandebo) when we've completely converted to pools, the base TCP
@@ -62,6 +63,7 @@ HttpNetworkSession::HttpNetworkSession(
ssl_config_service_(ssl_config_service),
spdy_session_pool_(spdy_session_pool),
http_auth_handler_factory_(http_auth_handler_factory),
+ network_delegate_(network_delegate),
net_log_(net_log) {
DCHECK(proxy_service);
DCHECK(ssl_config_service);
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index a6e10b1..1288197 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -14,6 +14,8 @@
#include "net/base/ssl_config_service.h"
#include "net/http/http_alternate_protocols.h"
#include "net/http/http_auth_cache.h"
+#include "net/http/http_network_delegate.h"
+#include "net/http/http_network_transaction.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/client_socket_pool_histograms.h"
#include "net/socket/socks_client_socket_pool.h"
@@ -24,6 +26,7 @@ namespace net {
class ClientSocketFactory;
class HttpAuthHandlerFactory;
+class HttpNetworkDelegate;
class HttpNetworkSessionPeer;
class NetworkChangeNotifier;
class SpdySessionPool;
@@ -39,6 +42,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
SSLConfigService* ssl_config_service,
SpdySessionPool* spdy_session_pool,
HttpAuthHandlerFactory* http_auth_handler_factory,
+ HttpNetworkDelegate* network_delegate,
NetLog* net_log);
HttpAuthCache* auth_cache() { return &auth_cache_; }
@@ -83,6 +87,9 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
HttpAuthHandlerFactory* http_auth_handler_factory() {
return http_auth_handler_factory_;
}
+ HttpNetworkDelegate* network_delegate() {
+ return network_delegate_;
+ }
static void set_max_sockets_per_group(int socket_count);
@@ -120,6 +127,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
scoped_refptr<SSLConfigService> ssl_config_service_;
scoped_refptr<SpdySessionPool> spdy_session_pool_;
HttpAuthHandlerFactory* http_auth_handler_factory_;
+ HttpNetworkDelegate* const network_delegate_;
NetLog* net_log_;
SpdySettingsStorage spdy_settings_;
};
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 13fbf9d..27db570 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1220,12 +1220,17 @@ int HttpNetworkTransaction::DoSendRequest() {
BuildRequestHeaders(request_, authorization_headers, request_body,
!using_ssl_ && proxy_info_.is_http(), &request_line,
&request_headers);
+
+ if (session_->network_delegate())
+ session_->network_delegate()->OnSendHttpRequest(&request_headers);
+
if (net_log_.HasListener()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
new NetLogHttpRequestParameter(
request_line, request_headers));
}
+
request_headers_ = request_line + request_headers.ToString();
}
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index aaa2a19..2f0971c 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -75,8 +75,7 @@ class HttpNetworkSessionPeer {
// Helper to manage the lifetimes of the dependencies for a
// HttpNetworkTransaction.
-class SessionDependencies {
- public:
+struct SessionDependencies {
// Default set of dependencies -- "null" proxy service.
SessionDependencies()
: host_resolver(new MockHostResolver),
@@ -115,6 +114,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->ssl_config_service,
session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get(),
+ NULL,
NULL);
}
diff --git a/net/net.gyp b/net/net.gyp
index 543fbb1..5a61b6d 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -355,6 +355,7 @@
'http/http_cache_transaction.h',
'http/http_chunked_decoder.cc',
'http/http_chunked_decoder.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/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc
index 5d147b1..ff12ebc 100644
--- a/net/proxy/proxy_script_fetcher_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_unittest.cc
@@ -40,7 +40,7 @@ class RequestContext : public URLRequestContext {
new net::HttpCache(
net::HttpNetworkLayer::CreateFactory(
NULL, host_resolver_, proxy_service_, ssl_config_service_,
- NULL, NULL),
+ NULL, NULL, NULL),
net::HttpCache::DefaultBackend::InMemory(0));
}
diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc
index 4057131..5d20aa9a 100644
--- a/net/spdy/spdy_http_stream_unittest.cc
+++ b/net/spdy/spdy_http_stream_unittest.cc
@@ -79,6 +79,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->ssl_config_service,
session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get(),
+ NULL,
NULL);
}
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 09bfd7b..3c60ba9 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -88,6 +88,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->ssl_config_service,
session_deps->spdy_session_pool,
session_deps->http_auth_handler_factory.get(),
+ NULL,
NULL);
}
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index bbcf8d1..6b443e1 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -59,6 +59,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
session_deps->ssl_config_service,
session_deps->spdy_session_pool,
NULL,
+ NULL,
NULL);
}
diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc
index f939c2d..d6ba673 100644
--- a/net/tools/fetch/fetch_client.cc
+++ b/net/tools/fetch/fetch_client.cc
@@ -147,11 +147,13 @@ int main(int argc, char**argv) {
ssl_config_service,
http_auth_handler_factory.get(),
NULL,
+ NULL,
net::HttpCache::DefaultBackend::InMemory(0));
} else {
factory = new net::HttpNetworkLayer(
net::ClientSocketFactory::GetDefaultFactory(), NULL, host_resolver,
proxy_service, ssl_config_service, http_auth_handler_factory.get(),
+ NULL,
NULL);
}
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index cd1736b..36b42b3 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -24,6 +24,7 @@ namespace net {
class CookiePolicy;
class FtpTransactionFactory;
class HttpAuthHandlerFactory;
+class HttpNetworkDelegate;
class HttpTransactionFactory;
class SocketStream;
}
@@ -38,6 +39,7 @@ class URLRequestContext
http_transaction_factory_(NULL),
ftp_transaction_factory_(NULL),
http_auth_handler_factory_(NULL),
+ network_delegate_(NULL),
cookie_policy_(NULL),
transport_security_state_(NULL) {
}
@@ -138,6 +140,7 @@ class URLRequestContext
net::HttpTransactionFactory* http_transaction_factory_;
net::FtpTransactionFactory* ftp_transaction_factory_;
net::HttpAuthHandlerFactory* http_auth_handler_factory_;
+ net::HttpNetworkDelegate* network_delegate_;
scoped_refptr<net::CookieStore> cookie_store_;
net::CookiePolicy* cookie_policy_;
scoped_refptr<net::TransportSecurityState> transport_security_state_;
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 3546832..02f8ab0 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -166,6 +166,7 @@ class TestURLRequestContext : public URLRequestContext {
proxy_service_,
ssl_config_service_,
http_auth_handler_factory_,
+ network_delegate_,
NULL),
net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc
index a688c13..33ed651 100644
--- a/webkit/tools/test_shell/test_shell_request_context.cc
+++ b/webkit/tools/test_shell/test_shell_request_context.cc
@@ -71,7 +71,7 @@ void TestShellRequestContext::Init(
net::HttpCache* cache =
new net::HttpCache(NULL, host_resolver_, proxy_service_,
ssl_config_service_, http_auth_handler_factory_,
- NULL, backend);
+ NULL, NULL, backend);
cache->set_mode(cache_mode);
http_transaction_factory_ = cache;