diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 00:24:51 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 00:24:51 +0000 |
commit | d13c32787737f1822202802f062c41c38b90e5f5 (patch) | |
tree | f616a6dcf08fee7cc6f5c023e53be4fa501e9ef2 /net | |
parent | 9becad4ad1adcd4e4339b45f8b90d299fd968a08 (diff) | |
download | chromium_src-d13c32787737f1822202802f062c41c38b90e5f5.zip chromium_src-d13c32787737f1822202802f062c41c38b90e5f5.tar.gz chromium_src-d13c32787737f1822202802f062c41c38b90e5f5.tar.bz2 |
Pass the NetworkChangeNotifier to HostResolver.
This requires the following refactors:
(1) NetworkChangeNotifier moves out of HttpNetworkSession into IOThread.
(2) HostResolver gets initialized with NetworkChangeNotifier.
(3) NetworkChangeNotifier needs to get passed into HttpCache and HttpNetworkSession (required updating a lot of files).
(4) NetworkChangeNotifier is no longer reference counted. It is owned by IOThread.
(5) IOThread gains a new struct: Globals. It can only be used on the io thread.
(6) ChromeURLRequestContextFactory uses IOThread::Globals to initialize ChromeURLRequest objects with the host resolver and network change notifier.
BUG=26159
Review URL: http://codereview.chromium.org/552117
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
30 files changed, 100 insertions, 73 deletions
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 6ce3c67..32706a0 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -20,6 +20,7 @@ namespace net { class AddressList; class HostCache; class LoadLog; +class NetworkChangeNotifier; // This class represents the task of resolving hostnames (or IP address // literal) to an AddressList object. @@ -219,7 +220,10 @@ class SingleRequestHostResolver { // Creates a HostResolver implementation that queries the underlying system. // (Except if a unit-test has changed the global HostResolverProc using // ScopedHostResolverProc to intercept requests to the system). -HostResolver* CreateSystemHostResolver(); +// |network_change_notifier| must outlive HostResolver. It can optionally be +// NULL, in which case HostResolver will not respond to network changes. +HostResolver* CreateSystemHostResolver( + NetworkChangeNotifier* network_change_notifier); } // namespace net diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index b654ad3..94c3857 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -43,14 +43,15 @@ HostCache* CreateDefaultCache() { } // anonymous namespace -HostResolver* CreateSystemHostResolver() { +HostResolver* CreateSystemHostResolver( + NetworkChangeNotifier* network_change_notifier) { // Maximum of 50 concurrent threads. // TODO(eroman): Adjust this, do some A/B experiments. static const size_t kMaxJobs = 50u; // TODO(willchan): Pass in the NetworkChangeNotifier. HostResolverImpl* resolver = new HostResolverImpl( - NULL, CreateDefaultCache(), NULL, kMaxJobs); + NULL, CreateDefaultCache(), network_change_notifier, kMaxJobs); return resolver; } @@ -525,7 +526,7 @@ class HostResolverImpl::JobPool { HostResolverImpl::HostResolverImpl( HostResolverProc* resolver_proc, HostCache* cache, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier, + NetworkChangeNotifier* network_change_notifier, size_t max_jobs) : cache_(cache), max_jobs_(max_jobs), diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index f3684b8..feedc05 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -69,12 +69,13 @@ class HostResolverImpl : public HostResolver, // thread-safe since it is run from multiple worker threads. If // |resolver_proc| is NULL then the default host resolver procedure is // used (which is SystemHostResolverProc except if overridden). - // + // |notifier| must outlive HostResolverImpl. It can optionally be NULL, in + // which case HostResolverImpl will not respond to network changes. // |max_jobs| specifies the maximum number of threads that the host resolver // will use. Use SetPoolConstraints() to specify finer-grain settings. HostResolverImpl(HostResolverProc* resolver_proc, HostCache* cache, - const scoped_refptr<NetworkChangeNotifier>& notifier, + NetworkChangeNotifier* notifier, size_t max_jobs); // HostResolver methods: @@ -236,7 +237,7 @@ class HostResolverImpl : public HostResolver, // TODO(eroman): temp hack for http://crbug.com/15513 bool shutdown_; - const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; + NetworkChangeNotifier* const network_change_notifier_; scoped_refptr<RequestsTrace> requests_trace_; diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc index f3d350c..8ca58f0 100644 --- a/net/base/host_resolver_impl_unittest.cc +++ b/net/base/host_resolver_impl_unittest.cc @@ -978,11 +978,10 @@ TEST_F(HostResolverImplTest, CancellationObserver) { // Test that IP address changes flush the cache. TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) { - scoped_refptr<MockNetworkChangeNotifier> mock_network_change_notifier( - new MockNetworkChangeNotifier); + MockNetworkChangeNotifier mock_network_change_notifier; scoped_refptr<HostResolver> host_resolver( new HostResolverImpl(NULL, CreateDefaultCache(), - mock_network_change_notifier, + &mock_network_change_notifier, kMaxJobs)); AddressList addrlist; @@ -1000,7 +999,7 @@ TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) { ASSERT_EQ(OK, rv); // Should complete synchronously. // Flush cache by triggering an IP address change. - mock_network_change_notifier->NotifyIPAddressChange(); + mock_network_change_notifier.NotifyIPAddressChange(); // Resolve "host1" again -- this time it won't be served from cache, so it // will complete asynchronously. diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc index 241f419..aeca2ab 100644 --- a/net/base/network_change_notifier.cc +++ b/net/base/network_change_notifier.cc @@ -15,8 +15,8 @@ namespace net { // static -scoped_refptr<NetworkChangeNotifier> - NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier() { +NetworkChangeNotifier* +NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier() { #if defined(OS_WIN) return new NetworkChangeNotifierWin(); #elif defined(OS_LINUX) diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h index d66830a..67d57ff 100644 --- a/net/base/network_change_notifier.h +++ b/net/base/network_change_notifier.h @@ -6,13 +6,13 @@ #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ #include "base/basictypes.h" -#include "base/ref_counted.h" +#include "base/non_thread_safe.h" namespace net { // NetworkChangeNotifier monitors the system for network changes, and notifies // observers on those events. -class NetworkChangeNotifier : public base::RefCounted<NetworkChangeNotifier> { +class NetworkChangeNotifier : public NonThreadSafe { public: class Observer { public: @@ -30,6 +30,7 @@ class NetworkChangeNotifier : public base::RefCounted<NetworkChangeNotifier> { }; NetworkChangeNotifier() {} + virtual ~NetworkChangeNotifier() {} // These functions add and remove observers to/from the NetworkChangeNotifier. // Each call to AddObserver() must be matched with a corresponding call to @@ -40,12 +41,7 @@ class NetworkChangeNotifier : public base::RefCounted<NetworkChangeNotifier> { virtual void RemoveObserver(Observer* observer) = 0; // This will create the platform specific default NetworkChangeNotifier. - static scoped_refptr<NetworkChangeNotifier> - CreateDefaultNetworkChangeNotifier(); - - protected: - friend class base::RefCounted<NetworkChangeNotifier>; - virtual ~NetworkChangeNotifier() {} + static NetworkChangeNotifier* CreateDefaultNetworkChangeNotifier(); private: DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); diff --git a/net/flip/flip_network_transaction_unittest.cc b/net/flip/flip_network_transaction_unittest.cc index 47c54c2..af6ca0e 100644 --- a/net/flip/flip_network_transaction_unittest.cc +++ b/net/flip/flip_network_transaction_unittest.cc @@ -71,7 +71,8 @@ ProxyService* CreateFixedProxyService(const std::string& proxy) { HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { - return new HttpNetworkSession(session_deps->host_resolver, + return new HttpNetworkSession(NULL, + session_deps->host_resolver, session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, diff --git a/net/flip/flip_stream_unittest.cc b/net/flip/flip_stream_unittest.cc index 643aa60..5b3064a 100644 --- a/net/flip/flip_stream_unittest.cc +++ b/net/flip/flip_stream_unittest.cc @@ -68,7 +68,8 @@ class SessionDependencies { }; HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { - return new HttpNetworkSession(session_deps->host_resolver, + return new HttpNetworkSession(NULL, + session_deps->host_resolver, session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index c99caca..b7989d1 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -124,7 +124,8 @@ class HttpCache::BackendCallback : public CallbackRunner<Tuple1<int> > { //----------------------------------------------------------------------------- -HttpCache::HttpCache(HostResolver* host_resolver, +HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, + HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, const FilePath& cache_dir, @@ -133,7 +134,8 @@ HttpCache::HttpCache(HostResolver* host_resolver, mode_(NORMAL), type_(DISK_CACHE), network_layer_(HttpNetworkLayer::CreateFactory( - host_resolver, proxy_service, ssl_config_service)), + network_change_notifier, host_resolver, proxy_service, + ssl_config_service)), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), enable_range_support_(true), cache_size_(cache_size) { @@ -151,14 +153,16 @@ HttpCache::HttpCache(HttpNetworkSession* session, cache_size_(cache_size) { } -HttpCache::HttpCache(HostResolver* host_resolver, +HttpCache::HttpCache(NetworkChangeNotifier* network_change_notifier, + HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, int cache_size) : mode_(NORMAL), type_(MEMORY_CACHE), network_layer_(HttpNetworkLayer::CreateFactory( - host_resolver, proxy_service, ssl_config_service)), + network_change_notifier, host_resolver, proxy_service, + ssl_config_service)), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), enable_range_support_(true), cache_size_(cache_size) { diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 90dac74..1985f9b 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -38,6 +38,7 @@ class HostResolver; class HttpNetworkSession; class HttpRequestInfo; class HttpResponseInfo; +class NetworkChangeNotifier; class ProxyService; class SSLConfigService; @@ -63,7 +64,8 @@ class HttpCache : public HttpTransactionFactory, // Initialize the cache from the directory where its data is stored. The // disk cache is initialized lazily (by CreateTransaction) in this case. If // |cache_size| is zero, a default value will be calculated automatically. - HttpCache(HostResolver* host_resolver, + HttpCache(NetworkChangeNotifier* network_change_notifier, + HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, const FilePath& cache_dir, @@ -81,7 +83,8 @@ class HttpCache : public HttpTransactionFactory, // Initialize using an in-memory cache. The cache is initialized lazily // (by CreateTransaction) in this case. If |cache_size| is zero, a default // value will be calculated automatically. - HttpCache(HostResolver* host_resolver, + HttpCache(NetworkChangeNotifier* network_change_notifier, + HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, int cache_size); diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 72c377f..c8022b7 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -20,12 +20,14 @@ namespace net { // static HttpTransactionFactory* HttpNetworkLayer::CreateFactory( + NetworkChangeNotifier* network_change_notifier, HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service) { DCHECK(proxy_service); return new HttpNetworkLayer(ClientSocketFactory::GetDefaultFactory(), + network_change_notifier, host_resolver, proxy_service, ssl_config_service); } @@ -40,11 +42,14 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory( //----------------------------------------------------------------------------- bool HttpNetworkLayer::force_flip_ = false; -HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory, - HostResolver* host_resolver, - ProxyService* proxy_service, - SSLConfigService* ssl_config_service) +HttpNetworkLayer::HttpNetworkLayer( + ClientSocketFactory* socket_factory, + NetworkChangeNotifier* network_change_notifier, + HostResolver* host_resolver, + ProxyService* proxy_service, + SSLConfigService* ssl_config_service) : socket_factory_(socket_factory), + network_change_notifier_(network_change_notifier), host_resolver_(host_resolver), proxy_service_(proxy_service), ssl_config_service_(ssl_config_service), @@ -57,6 +62,7 @@ HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory, HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) : socket_factory_(ClientSocketFactory::GetDefaultFactory()), + network_change_notifier_(NULL), ssl_config_service_(NULL), session_(session), flip_session_pool_(session->flip_session_pool()), @@ -94,9 +100,10 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() { DCHECK(proxy_service_); FlipSessionPool* flip_pool = new FlipSessionPool; session_ = new HttpNetworkSession( - host_resolver_, proxy_service_, socket_factory_, - ssl_config_service_, flip_pool); + network_change_notifier_, host_resolver_, proxy_service_, + socket_factory_, ssl_config_service_, flip_pool); // These were just temps for lazy-initializing HttpNetworkSession. + network_change_notifier_ = NULL; host_resolver_ = NULL; proxy_service_ = NULL; socket_factory_ = NULL; diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index 4dbf9a4..38c10c7 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -17,15 +17,17 @@ class ClientSocketFactory; class FlipSessionPool; class HostResolver; class HttpNetworkSession; +class NetworkChangeNotifier; class ProxyInfo; class ProxyService; class SSLConfigService; class HttpNetworkLayer : public HttpTransactionFactory { public: - // |socket_factory|, |proxy_service| and |host_resolver| must remain valid - // for the lifetime of HttpNetworkLayer. + // |socket_factory|, |network_change_notifier|, |proxy_service| and + // |host_resolver| must remain valid for the lifetime of HttpNetworkLayer. HttpNetworkLayer(ClientSocketFactory* socket_factory, + NetworkChangeNotifier* network_change_notifier, HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service); // Construct a HttpNetworkLayer with an existing HttpNetworkSession which @@ -36,6 +38,7 @@ class HttpNetworkLayer : public HttpTransactionFactory { // This function hides the details of how a network layer gets instantiated // and allows other implementations to be substituted. static HttpTransactionFactory* CreateFactory( + NetworkChangeNotifier* network_change_notifier, HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service); @@ -65,6 +68,8 @@ class HttpNetworkLayer : public HttpTransactionFactory { // The factory we will use to create network sockets. ClientSocketFactory* socket_factory_; + NetworkChangeNotifier* network_change_notifier_; + // The host resolver and proxy service that will be used when lazily // creating |session_|. scoped_refptr<HostResolver> host_resolver_; diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc index d8240e1..1e75ece 100644 --- a/net/http/http_network_layer_unittest.cc +++ b/net/http/http_network_layer_unittest.cc @@ -16,7 +16,7 @@ class HttpNetworkLayerTest : public PlatformTest { TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { net::HttpNetworkLayer factory( - NULL, new net::MockHostResolver, net::ProxyService::CreateNull(), + NULL, NULL, new net::MockHostResolver, net::ProxyService::CreateNull(), new net::SSLConfigServiceDefaults); scoped_ptr<net::HttpTransaction> trans; @@ -27,7 +27,7 @@ TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { TEST_F(HttpNetworkLayerTest, Suspend) { net::HttpNetworkLayer factory( - NULL, new net::MockHostResolver, net::ProxyService::CreateNull(), + NULL, NULL, new net::MockHostResolver, net::ProxyService::CreateNull(), new net::SSLConfigServiceDefaults); scoped_ptr<net::HttpTransaction> trans; @@ -65,7 +65,8 @@ TEST_F(HttpNetworkLayerTest, GET) { net::StaticSocketDataProvider data(data_reads, data_writes); mock_socket_factory.AddSocketDataProvider(&data); - net::HttpNetworkLayer factory(&mock_socket_factory, new net::MockHostResolver, + net::HttpNetworkLayer factory(&mock_socket_factory, NULL, + new net::MockHostResolver, net::ProxyService::CreateNull(), new net::SSLConfigServiceDefaults); diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 150c6f0..9f4cba7 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -5,7 +5,6 @@ #include "net/http/http_network_session.h" #include "base/logging.h" -#include "net/base/network_change_notifier.h" #include "net/flip/flip_session_pool.h" namespace net { @@ -21,13 +20,13 @@ uint16 HttpNetworkSession::g_fixed_http_port = 0; uint16 HttpNetworkSession::g_fixed_https_port = 0; HttpNetworkSession::HttpNetworkSession( + NetworkChangeNotifier* network_change_notifier, HostResolver* host_resolver, ProxyService* proxy_service, ClientSocketFactory* client_socket_factory, SSLConfigService* ssl_config_service, FlipSessionPool* flip_session_pool) - : network_change_notifier_( - NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier()), + : network_change_notifier_(network_change_notifier), tcp_socket_pool_(new TCPClientSocketPool( max_sockets_, max_sockets_per_group_, host_resolver, client_socket_factory, network_change_notifier_)), diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 684da16..32bcdee 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -17,11 +17,13 @@ namespace net { class ClientSocketFactory; class FlipSessionPool; +class NetworkChangeNotifier; // This class holds session objects used by HttpNetworkTransaction objects. class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { public: HttpNetworkSession( + NetworkChangeNotifier* network_change_notifier, HostResolver* host_resolver, ProxyService* proxy_service, ClientSocketFactory* client_socket_factory, @@ -75,7 +77,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { HttpAuthCache auth_cache_; SSLClientAuthCache ssl_client_auth_cache_; - const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; + NetworkChangeNotifier* const network_change_notifier_; scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; ClientSocketFactory* socket_factory_; scoped_refptr<HostResolver> host_resolver_; diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 7be3390..9639457 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -72,7 +72,8 @@ ProxyService* CreateFixedProxyService(const std::string& proxy) { HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { - return new HttpNetworkSession(session_deps->host_resolver, + return new HttpNetworkSession(NULL, + session_deps->host_resolver, session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc index ff78e33..741e7d4 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -32,13 +32,13 @@ class RequestContext : public URLRequestContext { public: RequestContext() { net::ProxyConfig no_proxy; - host_resolver_ = net::CreateSystemHostResolver(); + host_resolver_ = net::CreateSystemHostResolver(NULL); proxy_service_ = net::ProxyService::CreateFixed(no_proxy); ssl_config_service_ = new net::SSLConfigServiceDefaults; http_transaction_factory_ = new net::HttpCache(net::HttpNetworkLayer::CreateFactory( - host_resolver_, proxy_service_, ssl_config_service_), + NULL, host_resolver_, proxy_service_, ssl_config_service_), disk_cache::CreateInMemoryCacheBackend(0)); } diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 9a8a1eb..8614d555 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -306,7 +306,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // The (possibly NULL) network change notifier that we use to decide when // to refetch PAC scripts or re-run WPAD. - scoped_refptr<NetworkChangeNotifier> network_change_notifier_; + NetworkChangeNotifier* const network_change_notifier_; DISALLOW_COPY_AND_ASSIGN(ProxyService); }; diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index 0a026a0..2e57e51 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -1791,11 +1791,10 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; - scoped_refptr<MockNetworkChangeNotifier> network_change_notifier( - new MockNetworkChangeNotifier()); + MockNetworkChangeNotifier network_change_notifier; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, network_change_notifier)); + new ProxyService(config_service, resolver, &network_change_notifier)); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1840,7 +1839,7 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { // going to return the same PAC URL as before, but this URL needs to be // refetched on the new network. - network_change_notifier->NotifyIPAddressChange(); + network_change_notifier.NotifyIPAddressChange(); // Start a second request. ProxyInfo info2; diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc index 24c2dc6..4a5c88c 100644 --- a/net/socket/client_socket_pool_base.cc +++ b/net/socket/client_socket_pool_base.cc @@ -96,7 +96,7 @@ ClientSocketPoolBaseHelper::ClientSocketPoolBaseHelper( base::TimeDelta unused_idle_socket_timeout, base::TimeDelta used_idle_socket_timeout, ConnectJobFactory* connect_job_factory, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier) + NetworkChangeNotifier* network_change_notifier) : idle_socket_count_(0), connecting_socket_count_(0), handed_out_socket_count_(0), diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index 8d3fba7..d4e9deb 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -168,7 +168,7 @@ class ClientSocketPoolBaseHelper base::TimeDelta unused_idle_socket_timeout, base::TimeDelta used_idle_socket_timeout, ConnectJobFactory* connect_job_factory, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier); + NetworkChangeNotifier* network_change_notifier); // See ClientSocketPool::RequestSocket for documentation on this function. // Note that |request| must be heap allocated. If ERR_IO_PENDING is returned, @@ -383,7 +383,7 @@ class ClientSocketPoolBaseHelper const scoped_ptr<ConnectJobFactory> connect_job_factory_; - const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; + NetworkChangeNotifier* const network_change_notifier_; }; } // namespace internal @@ -443,7 +443,7 @@ class ClientSocketPoolBase { base::TimeDelta unused_idle_socket_timeout, base::TimeDelta used_idle_socket_timeout, ConnectJobFactory* connect_job_factory, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier) + NetworkChangeNotifier* network_change_notifier) : helper_(new internal::ClientSocketPoolBaseHelper( max_sockets, max_sockets_per_group, unused_idle_socket_timeout, used_idle_socket_timeout, diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc index a3556dc..f44f1ab 100644 --- a/net/socket/ssl_client_socket_unittest.cc +++ b/net/socket/ssl_client_socket_unittest.cc @@ -25,7 +25,7 @@ const net::SSLConfig kDefaultSSLConfig; class SSLClientSocketTest : public PlatformTest { public: SSLClientSocketTest() - : resolver_(net::CreateSystemHostResolver()), + : resolver_(net::CreateSystemHostResolver(NULL)), socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) { } diff --git a/net/socket/ssl_test_util.cc b/net/socket/ssl_test_util.cc index 60b1f1f..941b693 100644 --- a/net/socket/ssl_test_util.cc +++ b/net/socket/ssl_test_util.cc @@ -309,7 +309,8 @@ bool TestServerLauncher::WaitToStart(const std::string& host_name, int port) { // Verify that the webserver is actually started. // Otherwise tests can fail if they run faster than Python can start. net::AddressList addr; - scoped_refptr<net::HostResolver> resolver(net::CreateSystemHostResolver()); + scoped_refptr<net::HostResolver> resolver( + net::CreateSystemHostResolver(NULL)); net::HostResolver::RequestInfo info(host_name, port); int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL); if (rv != net::OK) diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc index 823cce7..3ea6700 100644 --- a/net/socket/tcp_client_socket_pool.cc +++ b/net/socket/tcp_client_socket_pool.cc @@ -171,7 +171,7 @@ TCPClientSocketPool::TCPClientSocketPool( int max_sockets_per_group, HostResolver* host_resolver, ClientSocketFactory* client_socket_factory, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier) + NetworkChangeNotifier* network_change_notifier) : base_(max_sockets, max_sockets_per_group, base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h index 6e36ec3..fb1a93b 100644 --- a/net/socket/tcp_client_socket_pool.h +++ b/net/socket/tcp_client_socket_pool.h @@ -83,7 +83,7 @@ class TCPClientSocketPool : public ClientSocketPool { int max_sockets_per_group, HostResolver* host_resolver, ClientSocketFactory* client_socket_factory, - const scoped_refptr<NetworkChangeNotifier>& network_change_notifier); + NetworkChangeNotifier* network_change_notifier); // ClientSocketPool methods: diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc index 95b37f1..719d280 100644 --- a/net/socket/tcp_client_socket_pool_unittest.cc +++ b/net/socket/tcp_client_socket_pool_unittest.cc @@ -207,12 +207,11 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest { TCPClientSocketPoolTest() : ignored_request_info_("ignored", 80), host_resolver_(new MockHostResolver), - notifier_(new MockNetworkChangeNotifier), pool_(new TCPClientSocketPool(kMaxSockets, kMaxSocketsPerGroup, host_resolver_, &client_socket_factory_, - notifier_)) { + ¬ifier_)) { } int StartRequest(const std::string& group_name, RequestPriority priority) { @@ -223,7 +222,7 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest { HostResolver::RequestInfo ignored_request_info_; scoped_refptr<MockHostResolver> host_resolver_; MockClientSocketFactory client_socket_factory_; - scoped_refptr<MockNetworkChangeNotifier> notifier_; + MockNetworkChangeNotifier notifier_; scoped_refptr<TCPClientSocketPool> pool_; }; @@ -623,7 +622,7 @@ TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) { EXPECT_EQ(1, pool_->IdleSocketCount()); // After an IP address change, we should have 0 idle sockets. - notifier_->NotifyIPAddressChange(); + notifier_.NotifyIPAddressChange(); EXPECT_EQ(0, pool_->IdleSocketCount()); } diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc index eebdc9f..e1e08ab 100644 --- a/net/socket/tcp_client_socket_unittest.cc +++ b/net/socket/tcp_client_socket_unittest.cc @@ -88,7 +88,7 @@ void TCPClientSocketTest::SetUp() { listen_port_ = port; AddressList addr; - scoped_refptr<HostResolver> resolver(CreateSystemHostResolver()); + scoped_refptr<HostResolver> resolver(CreateSystemHostResolver(NULL)); HostResolver::RequestInfo info("localhost", listen_port_); int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL); CHECK(rv == OK); diff --git a/net/socket/tcp_pinger_unittest.cc b/net/socket/tcp_pinger_unittest.cc index 1714ebe..2cffa8a 100644 --- a/net/socket/tcp_pinger_unittest.cc +++ b/net/socket/tcp_pinger_unittest.cc @@ -65,7 +65,8 @@ void TCPPingerTest::SetUp() { TEST_F(TCPPingerTest, Ping) { net::AddressList addr; - scoped_refptr<net::HostResolver> resolver(net::CreateSystemHostResolver()); + scoped_refptr<net::HostResolver> resolver( + net::CreateSystemHostResolver(NULL)); net::HostResolver::RequestInfo info("localhost", listen_port_); int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL); @@ -78,7 +79,8 @@ TEST_F(TCPPingerTest, Ping) { TEST_F(TCPPingerTest, PingFail) { net::AddressList addr; - scoped_refptr<net::HostResolver> resolver(net::CreateSystemHostResolver()); + scoped_refptr<net::HostResolver> resolver( + net::CreateSystemHostResolver(NULL)); // "Kill" "server" listen_sock_ = NULL; diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc index 07be9c9..120b5ca 100644 --- a/net/tools/fetch/fetch_client.cc +++ b/net/tools/fetch/fetch_client.cc @@ -132,7 +132,7 @@ int main(int argc, char**argv) { MessageLoop loop(MessageLoop::TYPE_IO); scoped_refptr<net::HostResolver> host_resolver( - net::CreateSystemHostResolver()); + net::CreateSystemHostResolver(NULL)); scoped_refptr<net::ProxyService> proxy_service( net::ProxyService::CreateNull()); @@ -140,11 +140,11 @@ int main(int argc, char**argv) { net::SSLConfigService::CreateSystemSSLConfigService()); net::HttpTransactionFactory* factory = NULL; if (use_cache) { - factory = new net::HttpCache(host_resolver, proxy_service, + factory = new net::HttpCache(NULL, host_resolver, proxy_service, ssl_config_service, 0); } else { factory = new net::HttpNetworkLayer( - net::ClientSocketFactory::GetDefaultFactory(), host_resolver, + net::ClientSocketFactory::GetDefaultFactory(), NULL, host_resolver, proxy_service, ssl_config_service); } diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index e912ab9..6c1be78 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -126,13 +126,13 @@ class TestCookiePolicy : public net::CookiePolicy { class TestURLRequestContext : public URLRequestContext { public: TestURLRequestContext() { - host_resolver_ = net::CreateSystemHostResolver(); + host_resolver_ = net::CreateSystemHostResolver(NULL); proxy_service_ = net::ProxyService::CreateNull(); Init(); } explicit TestURLRequestContext(const std::string& proxy) { - host_resolver_ = net::CreateSystemHostResolver(); + host_resolver_ = net::CreateSystemHostResolver(NULL); net::ProxyConfig proxy_config; proxy_config.proxy_rules.ParseFromString(proxy); proxy_service_ = net::ProxyService::CreateFixed(proxy_config); @@ -155,7 +155,8 @@ class TestURLRequestContext : public URLRequestContext { ssl_config_service_ = new net::SSLConfigServiceDefaults; http_transaction_factory_ = new net::HttpCache( - net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, + net::HttpNetworkLayer::CreateFactory(NULL, host_resolver_, + proxy_service_, ssl_config_service_), disk_cache::CreateInMemoryCacheBackend(0)); // In-memory cookie store. |