summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 17:34:25 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 17:34:25 +0000
commit287d7c21d1b15057569855d0f44c480a4f54fc98 (patch)
treea4b640b8f1f3086b00329bda3523be234015a90d
parent28d9fc63e36aa686c725c87f54ffadde7b4498ed (diff)
downloadchromium_src-287d7c21d1b15057569855d0f44c480a4f54fc98.zip
chromium_src-287d7c21d1b15057569855d0f44c480a4f54fc98.tar.gz
chromium_src-287d7c21d1b15057569855d0f44c480a4f54fc98.tar.bz2
Remove unused HostResolver::Observer.
BUG= TEST=compiles, ./net_unittests Review URL: http://codereview.chromium.org/8533011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/host_resolver.h41
-rw-r--r--net/base/host_resolver_impl.cc85
-rw-r--r--net/base/host_resolver_impl.h16
-rw-r--r--net/base/host_resolver_impl_unittest.cc182
-rw-r--r--net/base/mapped_host_resolver.cc8
-rw-r--r--net/base/mapped_host_resolver.h2
-rw-r--r--net/base/mock_host_resolver.cc25
-rw-r--r--net/base/mock_host_resolver.h9
-rw-r--r--net/base/single_request_host_resolver_unittest.cc8
-rw-r--r--net/base/test_host_resolver_observer.cc44
-rw-r--r--net/base/test_host_resolver_observer.h73
-rw-r--r--net/dns/async_host_resolver.cc31
-rw-r--r--net/dns/async_host_resolver.h10
-rw-r--r--net/dns/async_host_resolver_unittest.cc97
-rw-r--r--net/http/http_network_transaction_unittest.cc87
-rw-r--r--net/net.gyp3
-rw-r--r--net/proxy/sync_host_resolver_bridge_unittest.cc8
-rw-r--r--net/socket/socks_client_socket_pool.cc5
-rw-r--r--net/socket/socks_client_socket_unittest.cc3
-rw-r--r--net/socket/transport_client_socket_pool.cc5
20 files changed, 22 insertions, 720 deletions
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index cfd1c6e..b47fa81 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -9,7 +9,6 @@
#include <string>
#include "base/memory/scoped_ptr.h"
-#include "googleurl/src/gurl.h"
#include "net/base/address_family.h"
#include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h"
@@ -71,9 +70,6 @@ class NET_EXPORT HostResolver {
RequestPriority priority() const { return priority_; }
void set_priority(RequestPriority priority) { priority_ = priority; }
- const GURL& referrer() const { return referrer_; }
- void set_referrer(const GURL& referrer) { referrer_ = referrer; }
-
private:
// The hostname to resolve, and the port to use in resulting sockaddrs.
HostPortPair host_port_pair_;
@@ -92,31 +88,6 @@ class NET_EXPORT HostResolver {
// The priority for the request.
RequestPriority priority_;
-
- // Optional data for consumption by observers. This is the URL of the
- // page that lead us to the navigation, for DNS prefetcher's benefit.
- GURL referrer_;
- };
-
- // Interface for observing the requests that flow through a HostResolver.
- class Observer {
- public:
- virtual ~Observer() {}
-
- // Called at the start of HostResolver::Resolve(). |id| is a unique number
- // given to the request, so it can be matched up with a corresponding call
- // to OnFinishResolutionWithStatus() or OnCancelResolution().
- virtual void OnStartResolution(int id, const RequestInfo& info) = 0;
-
- // Called on completion of request |id|. Note that if the request was
- // cancelled, OnCancelResolution() will be called instead.
- virtual void OnFinishResolutionWithStatus(int id, bool was_resolved,
- const RequestInfo& info) = 0;
-
- // Called when request |id| has been cancelled. A request is "cancelled"
- // if either the HostResolver is destroyed while a resolution is in
- // progress, or HostResolver::CancelRequest() is called.
- virtual void OnCancelResolution(int id, const RequestInfo& info) = 0;
};
// Opaque type used to cancel a request.
@@ -170,17 +141,11 @@ class NET_EXPORT HostResolver {
const BoundNetLog& net_log) = 0;
// Cancels the specified request. |req| is the handle returned by Resolve().
- // After a request is cancelled, its completion callback will not be called.
+ // After a request is canceled, its completion callback will not be called.
+ // CancelRequest must NOT be called after the request's completion callback
+ // has already run or the request was canceled.
virtual void CancelRequest(RequestHandle req) = 0;
- // Adds an observer to this resolver. The observer will be notified of the
- // start and completion of all requests (excluding cancellation). |observer|
- // must remain valid for the duration of this HostResolver's lifetime.
- virtual void AddObserver(Observer* observer) = 0;
-
- // Unregisters an observer previously added by AddObserver().
- virtual void RemoveObserver(Observer* observer) = 0;
-
// Sets the default AddressFamily to use when requests have left it
// unspecified. For example, this could be used to restrict resolution
// results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index c4002e6..31f08c0 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -261,13 +261,11 @@ class HostResolverImpl::Request {
public:
Request(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int id,
const RequestInfo& info,
OldCompletionCallback* callback,
AddressList* addresses)
: source_net_log_(source_net_log),
request_net_log_(request_net_log),
- id_(id),
info_(info),
job_(NULL),
callback_(callback),
@@ -315,10 +313,6 @@ class HostResolverImpl::Request {
return request_net_log_;
}
- int id() const {
- return id_;
- }
-
const RequestInfo& info() const {
return info_;
}
@@ -327,9 +321,6 @@ class HostResolverImpl::Request {
BoundNetLog source_net_log_;
BoundNetLog request_net_log_;
- // Unique ID for this request. Used by observers to identify requests.
- int id_;
-
// The request info that started the request.
RequestInfo info_;
@@ -1063,7 +1054,6 @@ HostResolverImpl::HostResolverImpl(
max_retry_attempts_(max_retry_attempts),
unresponsive_delay_(base::TimeDelta::FromMilliseconds(6000)),
retry_factor_(2),
- next_request_id_(0),
next_job_id_(0),
resolver_proc_(resolver_proc),
default_address_family_(ADDRESS_FAMILY_UNSPECIFIED),
@@ -1137,23 +1127,20 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
DCHECK(callback);
DCHECK(CalledOnValidThread());
- // Choose a unique ID number for observers to see.
- int request_id = next_request_id_++;
-
// Make a log item for the request.
BoundNetLog request_net_log = BoundNetLog::Make(net_log_,
NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
// Update the net log and notify registered observers.
- OnStartRequest(source_net_log, request_net_log, request_id, info);
+ OnStartRequest(source_net_log, request_net_log, info);
// Build a key that identifies the request in the cache and in the
// outstanding jobs map.
Key key = GetEffectiveKeyForRequest(info);
- int rv = ResolveHelper(request_id, key, info, addresses, request_net_log);
+ int rv = ResolveHelper(key, info, addresses, request_net_log);
if (rv != ERR_DNS_CACHE_MISS) {
- OnFinishRequest(source_net_log, request_net_log, request_id, info,
+ OnFinishRequest(source_net_log, request_net_log, info,
rv,
0 /* os_error (unknown since from cache) */);
return rv;
@@ -1161,7 +1148,7 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
// Create a handle for this request, and pass it back to the user if they
// asked for it (out_req != NULL).
- Request* req = new Request(source_net_log, request_net_log, request_id, info,
+ Request* req = new Request(source_net_log, request_net_log, info,
callback, addresses);
if (out_req)
*out_req = reinterpret_cast<RequestHandle>(req);
@@ -1188,8 +1175,7 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
return ERR_IO_PENDING;
}
-int HostResolverImpl::ResolveHelper(int request_id,
- const Key& key,
+int HostResolverImpl::ResolveHelper(const Key& key,
const RequestInfo& info,
AddressList* addresses,
const BoundNetLog& request_net_log) {
@@ -1213,22 +1199,19 @@ int HostResolverImpl::ResolveFromCache(const RequestInfo& info,
DCHECK(CalledOnValidThread());
DCHECK(addresses);
- // Choose a unique ID number for observers to see.
- int request_id = next_request_id_++;
-
// Make a log item for the request.
BoundNetLog request_net_log = BoundNetLog::Make(net_log_,
NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST);
// Update the net log and notify registered observers.
- OnStartRequest(source_net_log, request_net_log, request_id, info);
+ OnStartRequest(source_net_log, request_net_log, info);
// Build a key that identifies the request in the cache and in the
// outstanding jobs map.
Key key = GetEffectiveKeyForRequest(info);
- int rv = ResolveHelper(request_id, key, info, addresses, request_net_log);
- OnFinishRequest(source_net_log, request_net_log, request_id, info,
+ int rv = ResolveHelper(key, info, addresses, request_net_log);
+ OnFinishRequest(source_net_log, request_net_log, info,
rv,
0 /* os_error (unknown since from cache) */);
return rv;
@@ -1258,24 +1241,7 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) {
// NULL out the fields of req, to mark it as cancelled.
req->MarkAsCancelled();
- OnCancelRequest(req->source_net_log(), req->request_net_log(), req->id(),
- req->info());
-}
-
-void HostResolverImpl::AddObserver(HostResolver::Observer* observer) {
- DCHECK(CalledOnValidThread());
- observers_.push_back(observer);
-}
-
-void HostResolverImpl::RemoveObserver(HostResolver::Observer* observer) {
- DCHECK(CalledOnValidThread());
- ObserversList::iterator it =
- std::find(observers_.begin(), observers_.end(), observer);
-
- // Observer must exist.
- DCHECK(it != observers_.end());
-
- observers_.erase(it);
+ OnCancelRequest(req->source_net_log(), req->request_net_log(), req->info());
}
void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) {
@@ -1415,7 +1381,7 @@ void HostResolverImpl::OnJobCompleteInternal(
NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, NULL);
// Update the net log and notify registered observers.
- OnFinishRequest(req->source_net_log(), req->request_net_log(), req->id(),
+ OnFinishRequest(req->source_net_log(), req->request_net_log(),
req->info(), net_error, os_error);
req->OnComplete(net_error, addrlist);
@@ -1432,7 +1398,6 @@ void HostResolverImpl::OnJobCompleteInternal(
void HostResolverImpl::OnStartRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info) {
source_net_log.BeginEvent(
NetLog::TYPE_HOST_RESOLVER_IMPL,
@@ -1443,32 +1408,15 @@ void HostResolverImpl::OnStartRequest(const BoundNetLog& source_net_log,
NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
make_scoped_refptr(new RequestInfoParameters(
info, source_net_log.source())));
-
- // Notify the observers of the start.
- if (!observers_.empty()) {
- for (ObserversList::iterator it = observers_.begin();
- it != observers_.end(); ++it) {
- (*it)->OnStartResolution(request_id, info);
- }
- }
}
void HostResolverImpl::OnFinishRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info,
int net_error,
int os_error) {
bool was_resolved = net_error == OK;
- // Notify the observers of the completion.
- if (!observers_.empty()) {
- for (ObserversList::iterator it = observers_.begin();
- it != observers_.end(); ++it) {
- (*it)->OnFinishResolutionWithStatus(request_id, was_resolved, info);
- }
- }
-
// Log some extra parameters on failure for synchronous requests.
scoped_refptr<NetLog::EventParameters> params;
if (!was_resolved) {
@@ -1481,18 +1429,8 @@ void HostResolverImpl::OnFinishRequest(const BoundNetLog& source_net_log,
void HostResolverImpl::OnCancelRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info) {
request_net_log.AddEvent(NetLog::TYPE_CANCELLED, NULL);
-
- // Notify the observers of the cancellation.
- if (!observers_.empty()) {
- for (ObserversList::iterator it = observers_.begin();
- it != observers_.end(); ++it) {
- (*it)->OnCancelResolution(request_id, info);
- }
- }
-
request_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, NULL);
source_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL);
}
@@ -1597,8 +1535,7 @@ int HostResolverImpl::EnqueueRequest(JobPool* pool, Request* req) {
Request* r = req_evicted_from_queue.get();
int error = ERR_HOST_RESOLVER_QUEUE_TOO_LARGE;
- OnFinishRequest(r->source_net_log(), r->request_net_log(), r->id(),
- r->info(), error,
+ OnFinishRequest(r->source_net_log(), r->request_net_log(), r->info(), error,
0 /* os_error (not applicable) */);
if (r == req)
diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h
index dd8cb4d..e699ad7 100644
--- a/net/base/host_resolver_impl.h
+++ b/net/base/host_resolver_impl.h
@@ -136,8 +136,6 @@ class NET_EXPORT HostResolverImpl
AddressList* addresses,
const BoundNetLog& source_net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle req) OVERRIDE;
- virtual void AddObserver(HostResolver::Observer* observer) OVERRIDE;
- virtual void RemoveObserver(HostResolver::Observer* observer) OVERRIDE;
virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE;
virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE;
virtual void ProbeIPv6Support() OVERRIDE;
@@ -157,14 +155,12 @@ class NET_EXPORT HostResolverImpl
typedef std::vector<Request*> RequestsList;
typedef HostCache::Key Key;
typedef std::map<Key, scoped_refptr<Job> > JobMap;
- typedef std::vector<HostResolver::Observer*> ObserversList;
// Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP
// literal and cache lookup, returns OK if successful,
// ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is
// incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache.
- int ResolveHelper(int request_id,
- const Key& key,
+ int ResolveHelper(const Key& key,
const RequestInfo& info,
AddressList* addresses,
const BoundNetLog& request_net_log);
@@ -215,13 +211,11 @@ class NET_EXPORT HostResolverImpl
// Called when a request has just been started.
void OnStartRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info);
// Called when a request has just completed (before its callback is run).
void OnFinishRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info,
int net_error,
int os_error);
@@ -229,7 +223,6 @@ class NET_EXPORT HostResolverImpl
// Called when a request has been cancelled.
void OnCancelRequest(const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int request_id,
const RequestInfo& info);
// Notify IPv6ProbeJob not to call back, and discard reference to the job.
@@ -328,13 +321,6 @@ class NET_EXPORT HostResolverImpl
// HostResolver gets deleted from within the callback).
scoped_refptr<Job> cur_completing_job_;
- // The observers to notify when a request starts/ends.
- ObserversList observers_;
-
- // Monotonically increasing ID number to assign to the next request.
- // Observers are the only consumers of this ID number.
- int next_request_id_;
-
// Monotonically increasing ID number to assign to the next job.
// The only consumer of this ID is the requests tracing code.
int next_job_id_;
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc
index 2922758..a4d1954 100644
--- a/net/base/host_resolver_impl_unittest.cc
+++ b/net/base/host_resolver_impl_unittest.cc
@@ -23,7 +23,6 @@
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
#include "net/base/test_completion_callback.h"
-#include "net/base/test_host_resolver_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
// TODO(eroman):
@@ -982,162 +981,6 @@ TEST_F(HostResolverImplTest, BypassCache) {
MessageLoop::current()->Run();
}
-// Test that registering, unregistering, and notifying of observers works.
-// Does not test the cancellation notification since all resolves are
-// synchronous.
-TEST_F(HostResolverImplTest, Observers) {
- scoped_ptr<HostResolver> host_resolver(
- CreateHostResolverImpl(NULL));
-
- TestHostResolverObserver observer;
-
- host_resolver->AddObserver(&observer);
-
- AddressList addrlist;
-
- // Resolve "host1".
- HostResolver::RequestInfo info1(HostPortPair("host1", 70));
- CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- TestOldCompletionCallback callback;
- int rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL,
- log.bound());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- EXPECT_EQ(OK, rv);
-
- CapturingNetLog::EntryList entries;
- log.GetEntries(&entries);
-
- EXPECT_EQ(2u, entries.size());
- EXPECT_TRUE(LogContainsBeginEvent(
- entries, 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
- EXPECT_TRUE(LogContainsEndEvent(
- entries, 1, NetLog::TYPE_HOST_RESOLVER_IMPL));
-
- EXPECT_EQ(1U, observer.start_log.size());
- EXPECT_EQ(1U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
- EXPECT_TRUE(observer.start_log[0] ==
- TestHostResolverObserver::StartOrCancelEntry(0, info1));
- EXPECT_TRUE(observer.finish_log[0] ==
- TestHostResolverObserver::FinishEntry(0, true, info1));
-
- // Resolve "host1" again -- this time it will be served from cache, but it
- // should still notify of completion.
- rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL, BoundNetLog());
- ASSERT_EQ(OK, rv); // Should complete synchronously.
-
- EXPECT_EQ(2U, observer.start_log.size());
- EXPECT_EQ(2U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
- EXPECT_TRUE(observer.start_log[1] ==
- TestHostResolverObserver::StartOrCancelEntry(1, info1));
- EXPECT_TRUE(observer.finish_log[1] ==
- TestHostResolverObserver::FinishEntry(1, true, info1));
-
- // Resolve "host2", setting referrer to "http://foobar.com"
- HostResolver::RequestInfo info2(HostPortPair("host2", 70));
- info2.set_referrer(GURL("http://foobar.com"));
- rv = host_resolver->Resolve(info2, &addrlist, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- EXPECT_EQ(OK, rv);
-
- EXPECT_EQ(3U, observer.start_log.size());
- EXPECT_EQ(3U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
- EXPECT_TRUE(observer.start_log[2] ==
- TestHostResolverObserver::StartOrCancelEntry(2, info2));
- EXPECT_TRUE(observer.finish_log[2] ==
- TestHostResolverObserver::FinishEntry(2, true, info2));
-
- // Unregister the observer.
- host_resolver->RemoveObserver(&observer);
-
- // Resolve "host3"
- HostResolver::RequestInfo info3(HostPortPair("host3", 70));
- host_resolver->Resolve(info3, &addrlist, &callback, NULL, BoundNetLog());
-
- // No effect this time, since observer was removed.
- EXPECT_EQ(3U, observer.start_log.size());
- EXPECT_EQ(3U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
-}
-
-// Tests that observers are sent OnCancelResolution() whenever a request is
-// cancelled. There are two ways to cancel a request:
-// (1) Delete the HostResolver while job is outstanding.
-// (2) Call HostResolver::CancelRequest() while a request is outstanding.
-TEST_F(HostResolverImplTest, CancellationObserver) {
- TestHostResolverObserver observer;
- {
- // Create a host resolver and attach an observer.
- scoped_ptr<HostResolver> host_resolver(
- CreateHostResolverImpl(NULL));
- host_resolver->AddObserver(&observer);
-
- TestOldCompletionCallback callback;
-
- EXPECT_EQ(0U, observer.start_log.size());
- EXPECT_EQ(0U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
-
- // Start an async resolve for (host1:70).
- HostResolver::RequestInfo info1(HostPortPair("host1", 70));
- HostResolver::RequestHandle req = NULL;
- AddressList addrlist;
- int rv = host_resolver->Resolve(info1, &addrlist, &callback, &req,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(NULL != req);
-
- EXPECT_EQ(1U, observer.start_log.size());
- EXPECT_EQ(0U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
-
- EXPECT_TRUE(observer.start_log[0] ==
- TestHostResolverObserver::StartOrCancelEntry(0, info1));
-
- // Cancel the request.
- host_resolver->CancelRequest(req);
-
- EXPECT_EQ(1U, observer.start_log.size());
- EXPECT_EQ(0U, observer.finish_log.size());
- EXPECT_EQ(1U, observer.cancel_log.size());
-
- EXPECT_TRUE(observer.cancel_log[0] ==
- TestHostResolverObserver::StartOrCancelEntry(0, info1));
-
- // Start an async request for (host2:60)
- HostResolver::RequestInfo info2(HostPortPair("host2", 60));
- rv = host_resolver->Resolve(info2, &addrlist, &callback, NULL,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_TRUE(NULL != req);
-
- EXPECT_EQ(2U, observer.start_log.size());
- EXPECT_EQ(0U, observer.finish_log.size());
- EXPECT_EQ(1U, observer.cancel_log.size());
-
- EXPECT_TRUE(observer.start_log[1] ==
- TestHostResolverObserver::StartOrCancelEntry(1, info2));
-
- // Upon exiting this scope, HostResolver is destroyed, so all requests are
- // implicitly cancelled.
- }
-
- // Check that destroying the HostResolver sent a notification for
- // cancellation of host2:60 request.
-
- EXPECT_EQ(2U, observer.start_log.size());
- EXPECT_EQ(0U, observer.finish_log.size());
- EXPECT_EQ(2U, observer.cancel_log.size());
-
- HostResolver::RequestInfo info(HostPortPair("host2", 60));
- EXPECT_TRUE(observer.cancel_log[1] ==
- TestHostResolverObserver::StartOrCancelEntry(1, info));
-}
-
// Test that IP address changes flush the cache.
TEST_F(HostResolverImplTest, FlushCacheOnIPAddressChange) {
scoped_ptr<HostResolver> host_resolver(
@@ -1301,9 +1144,6 @@ TEST_F(HostResolverImplTest, HigherPriorityRequestsStartedFirst) {
new HostResolverImpl(resolver_proc, HostCache::CreateDefaultCache(),
kMaxJobs, kRetryAttempts, NULL));
- TestHostResolverObserver observer;
- host_resolver->AddObserver(&observer);
-
// Note that at this point the CapturingHostResolverProc is blocked, so any
// requests we make will not complete.
@@ -1336,8 +1176,6 @@ TEST_F(HostResolverImplTest, HigherPriorityRequestsStartedFirst) {
EXPECT_EQ(OK, callback[i].WaitForResult()) << "i=" << i;
}
- host_resolver->RemoveObserver(&observer);
-
// Since we have restricted to a single concurrent thread in the jobpool,
// the requests should complete in order of priority (with the exception
// of the first request, which gets started right away, since there is
@@ -1353,26 +1191,6 @@ TEST_F(HostResolverImplTest, HigherPriorityRequestsStartedFirst) {
EXPECT_EQ("req2", capture_list[4].hostname);
EXPECT_EQ("req3", capture_list[5].hostname);
EXPECT_EQ("req6", capture_list[6].hostname);
-
- // Also check using the observer's trace.
- EXPECT_EQ(8U, observer.start_log.size());
- EXPECT_EQ(8U, observer.finish_log.size());
- EXPECT_EQ(0U, observer.cancel_log.size());
-
- EXPECT_EQ("req0", observer.finish_log[0].info.hostname());
- EXPECT_EQ("req4", observer.finish_log[1].info.hostname());
-
- // There were two requests for "req5". The highest priority
- // one should have been dispatched earlier.
- EXPECT_EQ("req5", observer.finish_log[2].info.hostname());
- EXPECT_EQ("req5", observer.finish_log[3].info.hostname());
- EXPECT_EQ(HIGHEST, observer.finish_log[2].info.priority());
- EXPECT_EQ(LOW, observer.finish_log[3].info.priority());
-
- EXPECT_EQ("req1", observer.finish_log[4].info.hostname());
- EXPECT_EQ("req2", observer.finish_log[5].info.hostname());
- EXPECT_EQ("req3", observer.finish_log[6].info.hostname());
- EXPECT_EQ("req6", observer.finish_log[7].info.hostname());
}
// Try cancelling a request which has not been attached to a job yet.
diff --git a/net/base/mapped_host_resolver.cc b/net/base/mapped_host_resolver.cc
index 5b8542f..cb036f4 100644
--- a/net/base/mapped_host_resolver.cc
+++ b/net/base/mapped_host_resolver.cc
@@ -45,14 +45,6 @@ void MappedHostResolver::CancelRequest(RequestHandle req) {
impl_->CancelRequest(req);
}
-void MappedHostResolver::AddObserver(Observer* observer) {
- impl_->AddObserver(observer);
-}
-
-void MappedHostResolver::RemoveObserver(Observer* observer) {
- impl_->RemoveObserver(observer);
-}
-
void MappedHostResolver::ProbeIPv6Support() {
impl_->ProbeIPv6Support();
}
diff --git a/net/base/mapped_host_resolver.h b/net/base/mapped_host_resolver.h
index 78736c3..aa98b97 100644
--- a/net/base/mapped_host_resolver.h
+++ b/net/base/mapped_host_resolver.h
@@ -53,8 +53,6 @@ class NET_EXPORT MappedHostResolver : public HostResolver {
AddressList* addresses,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle req) OVERRIDE;
- virtual void AddObserver(Observer* observer) OVERRIDE;
- virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual void ProbeIPv6Support() OVERRIDE;
virtual HostCache* GetHostCache() OVERRIDE;
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index 87cb408..6d4b185 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -78,11 +78,8 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
size_t id = next_request_id_++;
- FOR_EACH_OBSERVER(Observer, observers_, OnStartResolution(id, info));
int rv = ResolveFromIPLiteralOrCache(info, addresses);
if (rv != ERR_DNS_CACHE_MISS) {
- FOR_EACH_OBSERVER(Observer, observers_,
- OnFinishResolutionWithStatus(id, rv == OK, info));
return rv;
}
if (synchronous_mode_) {
@@ -104,11 +101,8 @@ int MockHostResolverBase::ResolveFromCache(const RequestInfo& info,
AddressList* addresses,
const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
- size_t id = next_request_id_++;
- FOR_EACH_OBSERVER(Observer, observers_, OnStartResolution(id, info));
+ next_request_id_++;
int rv = ResolveFromIPLiteralOrCache(info, addresses);
- FOR_EACH_OBSERVER(Observer, observers_,
- OnFinishResolutionWithStatus(id, rv == OK, info));
return rv;
}
@@ -119,20 +113,12 @@ void MockHostResolverBase::CancelRequest(RequestHandle handle) {
if (it != requests_.end()) {
scoped_ptr<Request> req(it->second);
requests_.erase(it);
- FOR_EACH_OBSERVER(Observer, observers_, OnCancelResolution(id, req->info));
+ } else {
+ NOTREACHED() << "CancelRequest must NOT be called after request is "
+ "complete or canceled.";
}
}
-void MockHostResolverBase::AddObserver(Observer* observer) {
- DCHECK(CalledOnValidThread());
- observers_.AddObserver(observer);
-}
-
-void MockHostResolverBase::RemoveObserver(Observer* observer) {
- DCHECK(CalledOnValidThread());
- observers_.RemoveObserver(observer);
-}
-
HostCache* MockHostResolverBase::GetHostCache() {
return cache_.get();
}
@@ -149,7 +135,6 @@ MockHostResolverBase::MockHostResolverBase(bool use_caching)
base::TimeDelta::FromMinutes(1),
base::TimeDelta::FromSeconds(0)));
}
- STLDeleteValues(&requests_);
}
int MockHostResolverBase::ResolveFromIPLiteralOrCache(const RequestInfo& info,
@@ -192,8 +177,6 @@ int MockHostResolverBase::ResolveProc(size_t id,
}
if (rv == OK)
*addresses = CreateAddressListUsingPort(addr, info.port());
- FOR_EACH_OBSERVER(Observer, observers_,
- OnFinishResolutionWithStatus(id, rv == OK, info));
return rv;
}
diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h
index 3c6f178..145b8c0 100644
--- a/net/base/mock_host_resolver.h
+++ b/net/base/mock_host_resolver.h
@@ -10,7 +10,6 @@
#include <map>
#include "base/memory/weak_ptr.h"
-#include "base/observer_list.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/non_thread_safe.h"
#include "net/base/host_resolver.h"
@@ -63,9 +62,6 @@ class MockHostResolverBase : public HostResolver,
synchronous_mode_ = is_synchronous;
}
- // Resets the mock.
- void Reset(HostResolverProc* interceptor);
-
// HostResolver methods:
virtual int Resolve(const RequestInfo& info,
AddressList* addresses,
@@ -76,8 +72,6 @@ class MockHostResolverBase : public HostResolver,
AddressList* addresses,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle req) OVERRIDE;
- virtual void AddObserver(Observer* observer) OVERRIDE;
- virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual HostCache* GetHostCache() OVERRIDE;
protected:
@@ -97,7 +91,6 @@ class MockHostResolverBase : public HostResolver,
void ResolveNow(size_t id);
bool synchronous_mode_;
- ObserverList<Observer> observers_;
scoped_refptr<RuleBasedHostResolverProc> rules_;
scoped_refptr<HostResolverProc> proc_;
scoped_ptr<HostCache> cache_;
@@ -193,8 +186,6 @@ class HangingHostResolver : public HostResolver {
AddressList* addresses,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle req) OVERRIDE {}
- virtual void AddObserver(Observer* observer) OVERRIDE {}
- virtual void RemoveObserver(Observer* observer) OVERRIDE {}
};
// This class sets the default HostResolverProc for a particular scope. The
diff --git a/net/base/single_request_host_resolver_unittest.cc b/net/base/single_request_host_resolver_unittest.cc
index ddf8c70e0..7106af5f 100644
--- a/net/base/single_request_host_resolver_unittest.cc
+++ b/net/base/single_request_host_resolver_unittest.cc
@@ -57,14 +57,6 @@ class HangingHostResolver : public HostResolver {
outstanding_request_ = NULL;
}
- virtual void AddObserver(Observer* observer) OVERRIDE {
- FAIL();
- }
-
- virtual void RemoveObserver(Observer* observer) OVERRIDE {
- FAIL();
- }
-
private:
RequestHandle outstanding_request_;
diff --git a/net/base/test_host_resolver_observer.cc b/net/base/test_host_resolver_observer.cc
deleted file mode 100644
index 6bd04ba..0000000
--- a/net/base/test_host_resolver_observer.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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/test_host_resolver_observer.h"
-
-namespace net {
-
-bool operator==(const HostResolver::RequestInfo& a,
- const HostResolver::RequestInfo& b) {
- return a.hostname() == b.hostname() &&
- a.port() == b.port() &&
- a.allow_cached_response() == b.allow_cached_response() &&
- a.priority() == b.priority() &&
- a.is_speculative() == b.is_speculative() &&
- a.referrer() == b.referrer();
-}
-
-TestHostResolverObserver::TestHostResolverObserver() {
-}
-
-TestHostResolverObserver::~TestHostResolverObserver() {
-}
-
-void TestHostResolverObserver::OnStartResolution(
- int id,
- const HostResolver::RequestInfo& info) {
- start_log.push_back(StartOrCancelEntry(id, info));
-}
-
-void TestHostResolverObserver::OnFinishResolutionWithStatus(
- int id,
- bool was_resolved,
- const HostResolver::RequestInfo& info) {
- finish_log.push_back(FinishEntry(id, was_resolved, info));
-}
-
-void TestHostResolverObserver::OnCancelResolution(
- int id,
- const HostResolver::RequestInfo& info) {
- cancel_log.push_back(StartOrCancelEntry(id, info));
-}
-
-} // namespace
diff --git a/net/base/test_host_resolver_observer.h b/net/base/test_host_resolver_observer.h
deleted file mode 100644
index e5ac70a..0000000
--- a/net/base/test_host_resolver_observer.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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_TEST_HOST_RESOLVER_OBSERVER_H_
-#define NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_
-#pragma once
-
-#include "net/base/host_resolver.h"
-
-#include <vector>
-
-namespace net {
-
-bool operator==(const HostResolver::RequestInfo& a,
- const HostResolver::RequestInfo& b);
-
-// Observer that just makes note of how it was called. The test code can then
-// inspect to make sure it was called with the right parameters. Used by
-// HostResolverImpl and AsyncHostResolver unit tests.
-class TestHostResolverObserver : public HostResolver::Observer {
- public:
- TestHostResolverObserver();
- virtual ~TestHostResolverObserver();
-
- // HostResolver::Observer methods:
- virtual void OnStartResolution(int id, const HostResolver::RequestInfo& info);
- virtual void OnFinishResolutionWithStatus(
- int id,
- bool was_resolved,
- const HostResolver::RequestInfo& info);
- virtual void OnCancelResolution(
- int id,
- const HostResolver::RequestInfo& info);
-
- // Tuple (id, info).
- struct StartOrCancelEntry {
- StartOrCancelEntry(int id, const HostResolver::RequestInfo& info)
- : id(id), info(info) {}
-
- bool operator==(const StartOrCancelEntry& other) const {
- return id == other.id && info == other.info;
- }
-
- int id;
- HostResolver::RequestInfo info;
- };
-
- // Tuple (id, was_resolved, info).
- struct FinishEntry {
- FinishEntry(int id, bool was_resolved,
- const HostResolver::RequestInfo& info)
- : id(id), was_resolved(was_resolved), info(info) {}
-
- bool operator==(const FinishEntry& other) const {
- return id == other.id &&
- was_resolved == other.was_resolved &&
- info == other.info;
- }
-
- int id;
- bool was_resolved;
- HostResolver::RequestInfo info;
- };
-
- std::vector<StartOrCancelEntry> start_log;
- std::vector<FinishEntry> finish_log;
- std::vector<StartOrCancelEntry> cancel_log;
-};
-
-} // namespace net
-
-#endif // NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_
diff --git a/net/dns/async_host_resolver.cc b/net/dns/async_host_resolver.cc
index 70c9277..31e612e 100644
--- a/net/dns/async_host_resolver.cc
+++ b/net/dns/async_host_resolver.cc
@@ -84,14 +84,12 @@ class AsyncHostResolver::Request {
Request(AsyncHostResolver* resolver,
const BoundNetLog& source_net_log,
const BoundNetLog& request_net_log,
- int id,
const HostResolver::RequestInfo& info,
OldCompletionCallback* callback,
AddressList* addresses)
: resolver_(resolver),
source_net_log_(source_net_log),
request_net_log_(request_net_log),
- id_(id),
info_(info),
callback_(callback),
addresses_(addresses),
@@ -109,7 +107,6 @@ class AsyncHostResolver::Request {
resolver_->OnCancel(this);
}
- int id() const { return id_; }
int result() const { return result_; }
const Key& key() const {
DCHECK(IsValid());
@@ -188,7 +185,6 @@ class AsyncHostResolver::Request {
AsyncHostResolver* resolver_;
BoundNetLog source_net_log_;
BoundNetLog request_net_log_;
- const int id_;
const HostResolver::RequestInfo info_;
Key key_;
OldCompletionCallback* callback_;
@@ -210,7 +206,6 @@ AsyncHostResolver::AsyncHostResolver(const IPEndPoint& dns_server,
rand_int_cb_(rand_int_cb),
cache_(cache),
factory_(factory),
- next_request_id_(0),
net_log_(net_log) {
}
@@ -287,21 +282,10 @@ void AsyncHostResolver::OnStart(Request* request) {
NetLog::TYPE_ASYNC_HOST_RESOLVER_REQUEST,
make_scoped_refptr(new RequestParameters(
request->info(), request->source_net_log().source())));
-
- FOR_EACH_OBSERVER(
- HostResolver::Observer, observers_,
- OnStartResolution(request->id(), request->info()));
}
void AsyncHostResolver::OnFinish(Request* request, int result) {
DCHECK(request);
- bool was_resolved = result == OK;
-
- FOR_EACH_OBSERVER(
- HostResolver::Observer, observers_,
- OnFinishResolutionWithStatus(
- request->id(), was_resolved, request->info()));
-
request->request_net_log().EndEventWithNetErrorCode(
NetLog::TYPE_ASYNC_HOST_RESOLVER_REQUEST, result);
request->source_net_log().EndEvent(
@@ -311,10 +295,6 @@ void AsyncHostResolver::OnFinish(Request* request, int result) {
void AsyncHostResolver::OnCancel(Request* request) {
DCHECK(request);
- FOR_EACH_OBSERVER(
- HostResolver::Observer, observers_,
- OnCancelResolution(request->id(), request->info()));
-
request->request_net_log().AddEvent(
NetLog::TYPE_CANCELLED, NULL);
request->request_net_log().EndEvent(
@@ -334,14 +314,6 @@ void AsyncHostResolver::CancelRequest(RequestHandle req_handle) {
pending_requests_[request->priority()].remove(request.get());
}
-void AsyncHostResolver::AddObserver(HostResolver::Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void AsyncHostResolver::RemoveObserver(HostResolver::Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
void AsyncHostResolver::SetDefaultAddressFamily(
AddressFamily address_family) {
NOTIMPLEMENTED();
@@ -415,9 +387,8 @@ AsyncHostResolver::Request* AsyncHostResolver::CreateNewRequest(
const BoundNetLog& source_net_log) {
BoundNetLog request_net_log = BoundNetLog::Make(net_log_,
NetLog::SOURCE_ASYNC_HOST_RESOLVER_REQUEST);
- int id = next_request_id_++;
return new Request(
- this, source_net_log, request_net_log, id, info, callback, addresses);
+ this, source_net_log, request_net_log, info, callback, addresses);
}
bool AsyncHostResolver::AttachToRequestList(Request* request) {
diff --git a/net/dns/async_host_resolver.h b/net/dns/async_host_resolver.h
index 9ad5c01..5d09ecf 100644
--- a/net/dns/async_host_resolver.h
+++ b/net/dns/async_host_resolver.h
@@ -9,7 +9,6 @@
#include <list>
#include <map>
-#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
#include "net/base/address_family.h"
#include "net/base/host_cache.h"
@@ -47,8 +46,6 @@ class NET_EXPORT AsyncHostResolver
AddressList* addresses,
const BoundNetLog& source_net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle req_handle) OVERRIDE;
- virtual void AddObserver(HostResolver::Observer* observer) OVERRIDE;
- virtual void RemoveObserver(HostResolver::Observer* observer) OVERRIDE;
virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE;
virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE;
virtual HostCache* GetHostCache() OVERRIDE;
@@ -145,13 +142,6 @@ class NET_EXPORT AsyncHostResolver
// testing, outside of unit tests, its value is always NULL.
ClientSocketFactory* factory_;
- // The observers to notify when a request starts/ends.
- ObserverList<HostResolver::Observer> observers_;
-
- // Monotonically increasing ID number to assign to the next request.
- // Observers are the only consumers of this ID number.
- int next_request_id_;
-
NetLog* net_log_;
DISALLOW_COPY_AND_ASSIGN(AsyncHostResolver);
diff --git a/net/dns/async_host_resolver_unittest.cc b/net/dns/async_host_resolver_unittest.cc
index 7da3bc7..d0de625 100644
--- a/net/dns/async_host_resolver_unittest.cc
+++ b/net/dns/async_host_resolver_unittest.cc
@@ -10,7 +10,6 @@
#include "net/base/net_log.h"
#include "net/base/rand_callback.h"
#include "net/base/sys_addrinfo.h"
-#include "net/base/test_host_resolver_observer.h"
#include "net/dns/dns_test_util.h"
#include "net/socket/socket_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -487,100 +486,4 @@ TEST_F(AsyncHostResolverTest, OverflowQueueWithHighPriorityLookup) {
VerifyAddressList(ip_addresses2_, kPortNum, addrlist2_);
}
-// Test that registering, unregistering, and notifying of observers of
-// resolution start, completion and cancellation (both due to CancelRequest
-// and resolver destruction) work.
-TEST_F(AsyncHostResolverTest, Observers) {
- TestHostResolverObserver observer;
- resolver_->AddObserver(&observer);
-
- int rv0 = resolver_->Resolve(info0_, &addrlist0_, &callback0_, NULL,
- BoundNetLog());
- int rv1 = resolver_->Resolve(info1_, &addrlist1_, &callback1_, NULL,
- BoundNetLog());
- // We will cancel this one.
- HostResolver::RequestHandle req2 = NULL;
- int rv2 = resolver_->Resolve(info2_, &addrlist2_, &callback2_, &req2,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv0);
- EXPECT_EQ(ERR_IO_PENDING, rv1);
- EXPECT_EQ(ERR_IO_PENDING, rv2);
-
- // Cancel lookup 2.
- resolver_->CancelRequest(req2);
-
- // Lookup 0 and 1 should succeed.
- rv0 = callback0_.WaitForResult();
- EXPECT_EQ(OK, rv0);
- VerifyAddressList(ip_addresses0_, kPortNum, addrlist0_);
-
- rv1 = callback1_.WaitForResult();
- EXPECT_EQ(OK, rv1);
- VerifyAddressList(ip_addresses1_, kPortNum, addrlist1_);
-
- // Next lookup should not have finished.
- MessageLoop::current()->RunAllPending();
- EXPECT_FALSE(callback2_.have_result());
-
- // Verify observer calls.
- EXPECT_EQ(3u, observer.start_log.size());
- EXPECT_EQ(2u, observer.finish_log.size());
- EXPECT_EQ(1u, observer.cancel_log.size());
-
- // Lookup 0 started and finished.
- EXPECT_TRUE(observer.start_log[0] ==
- TestHostResolverObserver::StartOrCancelEntry(0, info0_));
- EXPECT_TRUE(observer.finish_log[0] ==
- TestHostResolverObserver::FinishEntry(0, true, info0_));
-
- // Ditto for lookup 1.
- EXPECT_TRUE(observer.start_log[1] ==
- TestHostResolverObserver::StartOrCancelEntry(1, info1_));
- EXPECT_TRUE(observer.finish_log[1] ==
- TestHostResolverObserver::FinishEntry(1, true, info1_));
-
- // Lookup 2 was cancelled, hence, failed to finish.
- EXPECT_TRUE(observer.start_log[2] ==
- TestHostResolverObserver::StartOrCancelEntry(2, info2_));
- EXPECT_TRUE(observer.cancel_log[0] ==
- TestHostResolverObserver::StartOrCancelEntry(2, info2_));
-
- // Unregister observer.
- resolver_->RemoveObserver(&observer);
-
- // We will do lookup 2 again but will not cancel it this time.
- rv2 = resolver_->Resolve(info2_, &addrlist2_, &callback2_, NULL,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv2);
-
- // Run lookup 2 to completion.
- rv2 = callback2_.WaitForResult();
- EXPECT_EQ(OK, rv2);
- VerifyAddressList(ip_addresses2_, kPortNum, addrlist2_);
-
- // Observer log should stay the same.
- EXPECT_EQ(3u, observer.start_log.size());
- EXPECT_EQ(2u, observer.finish_log.size());
- EXPECT_EQ(1u, observer.cancel_log.size());
-
- // Re-register observer.
- resolver_->AddObserver(&observer);
-
- // Start lookup 3.
- int rv3 = resolver_->Resolve(info3_, &addrlist3_, &callback3_, NULL,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv3);
-
- // Destroy the resolver and make sure that observer was notified of just
- // the resolution start.
- resolver_.reset();
-
- EXPECT_EQ(4u, observer.start_log.size()); // Was incremented by 1.
- EXPECT_EQ(2u, observer.finish_log.size());
- EXPECT_EQ(2u, observer.cancel_log.size());
-
- EXPECT_TRUE(observer.start_log[3] ==
- TestHostResolverObserver::StartOrCancelEntry(4, info3_));
-}
-
} // namespace net
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 7c02e83..e10383c 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -5794,85 +5794,6 @@ TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) {
EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv);
}
-// Host resolution observer used by
-// HttpNetworkTransactionTest.ResolveMadeWithReferrer to check that host
-// resovle requests are issued with a referrer of |expected_referrer|.
-class ResolutionReferrerObserver : public HostResolver::Observer {
- public:
- explicit ResolutionReferrerObserver(const GURL& expected_referrer)
- : expected_referrer_(expected_referrer),
- called_start_with_referrer_(false),
- called_finish_with_referrer_(false) {
- }
-
- virtual void OnStartResolution(int id,
- const HostResolver::RequestInfo& info) {
- if (info.referrer() == expected_referrer_)
- called_start_with_referrer_ = true;
- }
-
- virtual void OnFinishResolutionWithStatus(
- int id, bool was_resolved, const HostResolver::RequestInfo& info ) {
- if (info.referrer() == expected_referrer_)
- called_finish_with_referrer_ = true;
- }
-
- virtual void OnCancelResolution(int id,
- const HostResolver::RequestInfo& info ) {
- FAIL() << "Should not be cancelling any requests!";
- }
-
- bool did_complete_with_expected_referrer() const {
- return called_start_with_referrer_ && called_finish_with_referrer_;
- }
-
- private:
- GURL expected_referrer_;
- bool called_start_with_referrer_;
- bool called_finish_with_referrer_;
-
- DISALLOW_COPY_AND_ASSIGN(ResolutionReferrerObserver);
-};
-
-// Make sure that when HostResolver::Resolve() is invoked, it passes through
-// the "referrer". This is depended on by the DNS prefetch observer.
-TEST_F(HttpNetworkTransactionTest, ResolveMadeWithReferrer) {
- GURL referrer = GURL("http://expected-referrer/");
- EXPECT_TRUE(referrer.is_valid());
- ResolutionReferrerObserver resolution_observer(referrer);
-
- // Issue a request, containing an HTTP referrer.
- HttpRequestInfo request;
- request.method = "GET";
- request.url = GURL("http://www.google.com/");
- request.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
- referrer.spec());
-
- SessionDependencies session_deps;
- scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
- CreateSession(&session_deps)));
-
- // Attach an observer to watch the host resolutions being made.
- session_deps.host_resolver->AddObserver(&resolution_observer);
-
- // Connect up a mock socket which will fail when reading.
- MockRead data_reads[] = {
- MockRead(false, ERR_FAILED),
- };
- StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
- session_deps.socket_factory.AddSocketDataProvider(&data);
-
- // Run the request until it fails reading from the socket.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&request, &callback, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- EXPECT_EQ(ERR_FAILED, rv);
-
- // Check that the host resolution observer saw |referrer|.
- EXPECT_TRUE(resolution_observer.did_complete_with_expected_referrer());
-}
-
// Base test to make sure that when the load flags for a request specify to
// bypass the cache, the DNS cache is not used.
void BypassHostCacheOnRefreshHelper(int load_flags) {
@@ -9139,14 +9060,6 @@ class OneTimeCachingHostResolver : public net::HostResolver {
host_resolver_.CancelRequest(req);
}
- virtual void AddObserver(Observer* observer) OVERRIDE {
- return host_resolver_.AddObserver(observer);
- }
-
- virtual void RemoveObserver(Observer* observer) OVERRIDE {
- return host_resolver_.RemoveObserver(observer);
- }
-
MockCachingHostResolver* GetMockHostResolver() {
return &host_resolver_;
}
diff --git a/net/net.gyp b/net/net.gyp
index a8bc91d..7680570 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -1313,7 +1313,6 @@
'net',
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
- '../build/temp_gyp/googleurl.gyp:googleurl',
'../testing/gtest.gyp:gtest',
],
'sources': [
@@ -1331,8 +1330,6 @@
'base/net_test_suite.h',
'base/test_completion_callback.cc',
'base/test_completion_callback.h',
- 'base/test_host_resolver_observer.cc',
- 'base/test_host_resolver_observer.h',
'disk_cache/disk_cache_test_util.cc',
'disk_cache/disk_cache_test_util.h',
'dns/dns_test_util.cc',
diff --git a/net/proxy/sync_host_resolver_bridge_unittest.cc b/net/proxy/sync_host_resolver_bridge_unittest.cc
index 327c44d..36586d3 100644
--- a/net/proxy/sync_host_resolver_bridge_unittest.cc
+++ b/net/proxy/sync_host_resolver_bridge_unittest.cc
@@ -59,14 +59,6 @@ class BlockableHostResolver : public HostResolver {
was_request_cancelled_ = true;
}
- virtual void AddObserver(Observer* observer) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void RemoveObserver(Observer* observer) OVERRIDE {
- NOTREACHED();
- }
-
// Waits until Resolve() has been called.
void WaitUntilRequestIsReceived() {
event_.Wait();
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index 4dbb442..aa0373d 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -17,6 +17,7 @@
namespace net {
+// TODO(szym): remove unneeded referrer
SOCKSSocketParams::SOCKSSocketParams(
const scoped_refptr<TransportSocketParams>& proxy_server,
bool socks_v5,
@@ -30,10 +31,6 @@ SOCKSSocketParams::SOCKSSocketParams(
ignore_limits_ = transport_params_->ignore_limits();
else
ignore_limits_ = false;
- // The referrer is used by the DNS prefetch system to correlate resolutions
- // with the page that triggered them. It doesn't impact the actual addresses
- // that we resolve to.
- destination_.set_referrer(referrer);
destination_.set_priority(priority);
}
diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc
index 0ed1834..2f7645f 100644
--- a/net/socket/socks_client_socket_unittest.cc
+++ b/net/socket/socks_client_socket_unittest.cc
@@ -111,9 +111,6 @@ class HangingHostResolverWithCancel : public HostResolver {
outstanding_request_ = NULL;
}
- virtual void AddObserver(Observer* observer) OVERRIDE {}
- virtual void RemoveObserver(Observer* observer) OVERRIDE {}
-
bool HasOutstandingRequest() {
return outstanding_request_ != NULL;
}
diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc
index 7138bb9..43276dc 100644
--- a/net/socket/transport_client_socket_pool.cc
+++ b/net/socket/transport_client_socket_pool.cc
@@ -70,13 +70,10 @@ TransportSocketParams::TransportSocketParams(
TransportSocketParams::~TransportSocketParams() {}
+// TODO(szym): remove unneeded referrer
void TransportSocketParams::Initialize(RequestPriority priority,
const GURL& referrer,
bool disable_resolver_cache) {
- // The referrer is used by the DNS prefetch system to correlate resolutions
- // with the page that triggered them. It doesn't impact the actual addresses
- // that we resolve to.
- destination_.set_referrer(referrer);
destination_.set_priority(priority);
if (disable_resolver_cache)
destination_.set_allow_cached_response(false);