summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 14:54:21 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 14:54:21 +0000
commit464513520a7792134dd0fa5a939f99128d4890ba (patch)
tree6c8db80f83be5329b2d5c0db962d824a410e517d /net/socket
parentc6d884ac6059305e721c2eedbf6ce95e5459bf86 (diff)
downloadchromium_src-464513520a7792134dd0fa5a939f99128d4890ba.zip
chromium_src-464513520a7792134dd0fa5a939f99128d4890ba.tar.gz
chromium_src-464513520a7792134dd0fa5a939f99128d4890ba.tar.bz2
Make GetLoadState virtual in ConnectJob().
This will be necessary for SSLClientSocketPool since the SSLConnectJob will contain a ClientSocketHandle for the TCPClientSocketPool. SSLConnectJob::GetLoadState() will forward to ClientSocketHandle::GetLoadState() if the SSLConnectJob is waiting on requesting a TCP socket. BUG=http://crbug.com/13289. Review URL: http://codereview.chromium.org/176024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_pool_base.cc5
-rw-r--r--net/socket/client_socket_pool_base.h6
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc10
-rw-r--r--net/socket/tcp_client_socket_pool.cc18
-rw-r--r--net/socket/tcp_client_socket_pool.h1
5 files changed, 27 insertions, 13 deletions
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 18a084b..1dc1180 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -37,7 +37,6 @@ ConnectJob::ConnectJob(const std::string& group_name,
key_handle_(key_handle),
timeout_duration_(timeout_duration),
delegate_(delegate),
- load_state_(LOAD_STATE_IDLE),
load_log_(load_log) {
DCHECK(!group_name.empty());
DCHECK(key_handle);
@@ -314,7 +313,7 @@ LoadState ClientSocketPoolBaseHelper::GetLoadState(
NOTREACHED();
return LOAD_STATE_IDLE;
}
- return job_it->second->load_state();
+ return job_it->second->GetLoadState();
}
// Search pending_requests for matching handle.
@@ -325,7 +324,7 @@ LoadState ClientSocketPoolBaseHelper::GetLoadState(
LoadState max_state = LOAD_STATE_IDLE;
for (ConnectJobSet::const_iterator job_it = group.jobs.begin();
job_it != group.jobs.end(); ++job_it) {
- max_state = std::max(max_state, (*job_it)->load_state());
+ max_state = std::max(max_state, (*job_it)->GetLoadState());
}
return max_state;
} else {
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 4b5a3b1..23c194c 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -70,8 +70,8 @@ class ConnectJob {
// Accessors
const std::string& group_name() const { return group_name_; }
- LoadState load_state() const { return load_state_; }
const ClientSocketHandle* key_handle() const { return key_handle_; }
+ LoadLog* load_log() { return load_log_; }
// Releases |socket_| to the client. On connection error, this should return
// NULL.
@@ -85,10 +85,9 @@ class ConnectJob {
// if it succeeded.
int Connect();
- LoadLog* load_log() { return load_log_; }
+ virtual LoadState GetLoadState() const = 0;
protected:
- void set_load_state(LoadState load_state) { load_state_ = load_state; }
void set_socket(ClientSocket* socket) { socket_.reset(socket); }
ClientSocket* socket() { return socket_.get(); }
void NotifyDelegateOfCompletion(int rv);
@@ -106,7 +105,6 @@ class ConnectJob {
// Timer to abort jobs that take too long.
base::OneShotTimer<ConnectJob> timer_;
Delegate* delegate_;
- LoadState load_state_;
scoped_ptr<ClientSocket> socket_;
scoped_refptr<LoadLog> load_log_;
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 020bc98..970b0ba 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -118,12 +118,15 @@ class TestConnectJob : public ConnectJob {
delegate, load_log),
job_type_(job_type),
client_socket_factory_(client_socket_factory),
- method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
+ method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ load_state_(LOAD_STATE_IDLE) {}
void Signal() {
DoConnect(waiting_success_, true /* async */);
}
+ virtual LoadState GetLoadState() const { return load_state_; }
+
private:
// ConnectJob methods:
@@ -162,7 +165,7 @@ class TestConnectJob : public ConnectJob {
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
- &TestConnectJob::AdvanceLoadState, load_state()));
+ &TestConnectJob::AdvanceLoadState, load_state_));
return ERR_IO_PENDING;
default:
NOTREACHED();
@@ -171,6 +174,8 @@ class TestConnectJob : public ConnectJob {
}
}
+ void set_load_state(LoadState load_state) { load_state_ = load_state; }
+
int DoConnect(bool succeed, bool was_async) {
int result = ERR_CONNECTION_FAILED;
if (succeed) {
@@ -202,6 +207,7 @@ class TestConnectJob : public ConnectJob {
const JobType job_type_;
MockClientSocketFactory* const client_socket_factory_;
ScopedRunnableMethodFactory<TestConnectJob> method_factory_;
+ LoadState load_state_;
DISALLOW_COPY_AND_ASSIGN(TestConnectJob);
};
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index 8a5c4d3..d73221a 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -44,6 +44,20 @@ TCPConnectJob::~TCPConnectJob() {
// ~SingleRequestHostResolver and ~ClientSocket will take care of it.
}
+LoadState TCPConnectJob::GetLoadState() const {
+ switch (next_state_) {
+ case kStateResolveHost:
+ case kStateResolveHostComplete:
+ return LOAD_STATE_RESOLVING_HOST;
+ case kStateTCPConnect:
+ case kStateTCPConnectComplete:
+ return LOAD_STATE_CONNECTING;
+ default:
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+}
+
int TCPConnectJob::ConnectInternal() {
next_state_ = kStateResolveHost;
return DoLoop(OK);
@@ -88,13 +102,11 @@ int TCPConnectJob::DoLoop(int result) {
}
int TCPConnectJob::DoResolveHost() {
- set_load_state(LOAD_STATE_RESOLVING_HOST);
next_state_ = kStateResolveHostComplete;
return resolver_.Resolve(resolve_info_, &addresses_, &callback_, load_log());
}
int TCPConnectJob::DoResolveHostComplete(int result) {
- DCHECK_EQ(LOAD_STATE_RESOLVING_HOST, load_state());
if (result == OK)
next_state_ = kStateTCPConnect;
return result;
@@ -102,7 +114,6 @@ int TCPConnectJob::DoResolveHostComplete(int result) {
int TCPConnectJob::DoTCPConnect() {
next_state_ = kStateTCPConnectComplete;
- set_load_state(LOAD_STATE_CONNECTING);
set_socket(client_socket_factory_->CreateTCPClientSocket(addresses_));
connect_start_time_ = base::TimeTicks::Now();
// TODO(eroman): Socket::Connect() should take a LoadLog.
@@ -110,7 +121,6 @@ int TCPConnectJob::DoTCPConnect() {
}
int TCPConnectJob::DoTCPConnectComplete(int result) {
- DCHECK_EQ(load_state(), LOAD_STATE_CONNECTING);
if (result == OK) {
DCHECK(connect_start_time_ != base::TimeTicks());
base::TimeDelta connect_duration =
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 03d9178..8a3d1f7 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -35,6 +35,7 @@ class TCPConnectJob : public ConnectJob {
virtual ~TCPConnectJob();
// ConnectJob methods.
+ virtual LoadState GetLoadState() const;
private:
enum State {