summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 06:09:41 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 06:09:41 +0000
commit291a8adf16a35fdf4ecddbd802bc4cc1f4575096 (patch)
tree84e38cb99c9b2339a527d389ba4878396a89db59 /net
parent2884a4619edeac1787e2b1d1b57e913f7e442cae (diff)
downloadchromium_src-291a8adf16a35fdf4ecddbd802bc4cc1f4575096.zip
chromium_src-291a8adf16a35fdf4ecddbd802bc4cc1f4575096.tar.gz
chromium_src-291a8adf16a35fdf4ecddbd802bc4cc1f4575096.tar.bz2
[Refactor] Rename DnsResolutionObserver --> HostResolver::Observer.
TEST=this is striclty a refactoring; just needs to compile and pass existing tests. BUG=14056 Review URL: http://codereview.chromium.org/126110 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/dns_resolution_observer.h45
-rw-r--r--net/base/host_resolver.cc5
-rw-r--r--net/base/host_resolver.h23
-rw-r--r--net/base/host_resolver_unittest.cc3
-rw-r--r--net/base/tcp_client_socket_pool.cc1
-rw-r--r--net/ftp/ftp_network_transaction.cc1
-rw-r--r--net/http/http_network_transaction.cc1
-rw-r--r--net/net.gyp1
8 files changed, 22 insertions, 58 deletions
diff --git a/net/base/dns_resolution_observer.h b/net/base/dns_resolution_observer.h
deleted file mode 100644
index 1651308..0000000
--- a/net/base/dns_resolution_observer.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2006-2008 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.
-
-// This file supports network stack independent notification of progress
-// towards resolving a hostname.
-
-// The observer class supports exactly one active (Add'ed) instance, and in
-// typical usage, that observer will be Add'ed during process startup, and
-// Remove'd during process termination.
-
-
-#ifndef NET_BASE_DNS_RESOLUTION_OBSERVER_H_
-#define NET_BASE_DNS_RESOLUTION_OBSERVER_H_
-
-#include <string>
-
-#include "net/base/host_resolver.h"
-
-class GURL;
-
-namespace net {
-
-// TODO(eroman): Move this interface to HostResolver::Observer.
-class DnsResolutionObserver {
- public:
- virtual ~DnsResolutionObserver() {}
-
- // For each OnStartResolution() notification, there should be a later
- // OnFinishResolutionWithStatus() indicating completion of the resolution
- // activity.
- // Related pairs of notification will arrive with matching id values.
- // A caller may use the id values to match up these asynchronous calls
- // from among a larger call stream.
- virtual void OnStartResolution(int id,
- const HostResolver::RequestInfo& info) = 0;
- virtual void OnFinishResolutionWithStatus(
- int id,
- bool was_resolved,
- const HostResolver::RequestInfo& info) = 0;
-};
-
-} // namspace net
-
-#endif // NET_BASE_DNS_RESOLUTION_OBSERVER_H_
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index 6dcef85..5a357eb 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -22,7 +22,6 @@
#include "base/time.h"
#include "base/worker_pool.h"
#include "net/base/address_list.h"
-#include "net/base/dns_resolution_observer.h"
#include "net/base/net_errors.h"
#if defined(OS_LINUX)
@@ -482,11 +481,11 @@ void HostResolver::CancelRequest(Request* req) {
req->Cancel();
}
-void HostResolver::AddObserver(DnsResolutionObserver* observer) {
+void HostResolver::AddObserver(Observer* observer) {
observers_.push_back(observer);
}
-void HostResolver::RemoveObserver(DnsResolutionObserver* observer) {
+void HostResolver::RemoveObserver(Observer* observer) {
ObserversList::iterator it =
std::find(observers_.begin(), observers_.end(), observer);
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index 9a7b7b9..34c803f 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -20,7 +20,6 @@ class MessageLoop;
namespace net {
class AddressList;
-class DnsResolutionObserver;
class HostMapper;
// This class represents the task of resolving hostnames (or IP address
@@ -100,6 +99,22 @@ class HostResolver {
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().
+ virtual void OnStartResolution(int id, const RequestInfo& info) = 0;
+
+ // Called on completion of request |id|. Note that if the request was
+ // cancelled, OnFinishResolutionWithStatus() will not be called.
+ virtual void OnFinishResolutionWithStatus(int id, bool was_resolved,
+ const RequestInfo& info) = 0;
+ };
+
// Creates a HostResolver that caches up to |max_cache_entries| for
// |cache_duration_ms| milliseconds.
//
@@ -137,16 +152,16 @@ class HostResolver {
// 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.
- void AddObserver(DnsResolutionObserver* observer);
+ void AddObserver(Observer* observer);
// Unregisters an observer previously added by AddObserver().
- void RemoveObserver(DnsResolutionObserver* observer);
+ void RemoveObserver(Observer* observer);
private:
class Job;
typedef std::vector<Request*> RequestsList;
typedef base::hash_map<std::string, scoped_refptr<Job> > JobMap;
- typedef std::vector<DnsResolutionObserver*> ObserversList;
+ typedef std::vector<Observer*> ObserversList;
// Adds a job to outstanding jobs list.
void AddOutstandingJob(Job* job);
diff --git a/net/base/host_resolver_unittest.cc b/net/base/host_resolver_unittest.cc
index 393385af..9c07c29 100644
--- a/net/base/host_resolver_unittest.cc
+++ b/net/base/host_resolver_unittest.cc
@@ -18,7 +18,6 @@
#include "base/ref_counted.h"
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
-#include "net/base/dns_resolution_observer.h"
#include "net/base/host_resolver_unittest.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -697,7 +696,7 @@ bool operator==(const net::HostResolver::RequestInfo& a,
// 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.
-class CapturingObserver : public net::DnsResolutionObserver {
+class CapturingObserver : public net::HostResolver::Observer {
public:
// DnsResolutionObserver methods:
virtual void OnStartResolution(int id,
diff --git a/net/base/tcp_client_socket_pool.cc b/net/base/tcp_client_socket_pool.cc
index c5e961e..7dadd4c 100644
--- a/net/base/tcp_client_socket_pool.cc
+++ b/net/base/tcp_client_socket_pool.cc
@@ -11,7 +11,6 @@
#include "base/stl_util-inl.h"
#include "net/base/client_socket_factory.h"
#include "net/base/client_socket_handle.h"
-#include "net/base/dns_resolution_observer.h"
#include "net/base/net_errors.h"
#include "net/base/tcp_client_socket.h"
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index 18bd808..6c71582 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -9,7 +9,6 @@
#include "net/base/client_socket.h"
#include "net/base/client_socket_factory.h"
#include "net/base/connection_type_histograms.h"
-#include "net/base/dns_resolution_observer.h"
#include "net/base/net_errors.h"
#include "net/ftp/ftp_network_session.h"
#include "net/ftp/ftp_request_info.h"
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index d5cd81f..f4a7879 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -12,7 +12,6 @@
#include "build/build_config.h"
#include "net/base/client_socket_factory.h"
#include "net/base/connection_type_histograms.h"
-#include "net/base/dns_resolution_observer.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
diff --git a/net/net.gyp b/net/net.gyp
index d187781..536f1de 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -61,7 +61,6 @@
'base/data_url.h',
'base/directory_lister.cc',
'base/directory_lister.h',
- 'base/dns_resolution_observer.h',
'base/effective_tld_names.cc',
'base/effective_tld_names.dat',
'base/escape.cc',