summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_handle.cc
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:17:26 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:17:26 +0000
commita796bcec176ca3875a55346800b3a60a83e2dd89 (patch)
tree2533c17673ff50f4f101e803c2dff3bf8f5cbf7b /net/socket/client_socket_handle.cc
parent35818452760c23c570b7947e00a3b38e733ce58e (diff)
downloadchromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.zip
chromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.tar.gz
chromium_src-a796bcec176ca3875a55346800b3a60a83e2dd89.tar.bz2
Implement SOCKSClientSocketPool
This is the first layered pool, so there are several infrastructure changes in this change as well. Add a ConnectionTimeout method to pools so that layered pools can timeout each phase. Add a name method to pools to support per pool UMA histograms. Change SOCKS sockets to take a ClientSocketHandle instead of a ClientSocket BUG=30357 (blocks an SSL Pool) TEST=existing unit tests Review URL: http://codereview.chromium.org/668097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_handle.cc')
-rw-r--r--net/socket/client_socket_handle.cc50
1 files changed, 45 insertions, 5 deletions
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc
index d8b0f8f..d99c7ad 100644
--- a/net/socket/client_socket_handle.cc
+++ b/net/socket/client_socket_handle.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/socket/client_socket_handle.h"
#include "base/compiler_specific.h"
+#include "base/histogram.h"
#include "base/logging.h"
#include "net/base/net_errors.h"
#include "net/socket/client_socket_pool.h"
@@ -29,9 +30,12 @@ void ClientSocketHandle::ResetInternal(bool cancel) {
if (group_name_.empty()) // Was Init called?
return;
if (socket_.get()) {
- // If we've still got a socket, release it back to the ClientSocketPool so
- // it can be deleted or reused.
- pool_->ReleaseSocket(group_name_, release_socket());
+ // Because of http://crbug.com/37810 we may not have a pool, but have
+ // just a raw socket.
+ if (pool_)
+ // If we've still got a socket, release it back to the ClientSocketPool so
+ // it can be deleted or reused.
+ pool_->ReleaseSocket(group_name_, release_socket());
} else if (cancel) {
// If we did not get initialized yet, so we've got a socket request pending.
// Cancel it.
@@ -43,11 +47,16 @@ void ClientSocketHandle::ResetInternal(bool cancel) {
pool_ = NULL;
idle_time_ = base::TimeDelta();
init_time_ = base::TimeTicks();
+ setup_time_ = base::TimeDelta();
}
LoadState ClientSocketHandle::GetLoadState() const {
CHECK(!is_initialized());
CHECK(!group_name_.empty());
+ // Because of http://crbug.com/37810 we may not have a pool, but have
+ // just a raw socket.
+ if (!pool_)
+ return LOAD_STATE_IDLE;
return pool_->GetLoadState(group_name_, this);
}
@@ -62,8 +71,39 @@ void ClientSocketHandle::HandleInitCompletion(int result) {
CHECK_NE(ERR_IO_PENDING, result);
// TODO(vandebo) remove when bug 31096 is resolved
CHECK(socket_.get() || result != OK);
- if (result != OK)
+ if (result != OK) {
ResetInternal(false); // The request failed, so there's nothing to cancel.
+ return;
+ }
+ setup_time_ = base::TimeTicks::Now() - init_time_;
+
+ std::string metric = "Net." + pool_->name() + "SocketType";
+ UMA_HISTOGRAM_ENUMERATION(metric, reuse_type(), NUM_TYPES);
+ switch (reuse_type()) {
+ case ClientSocketHandle::UNUSED:
+ metric = "Net." + pool_->name() + "SocketRequestTime";
+ UMA_HISTOGRAM_CLIPPED_TIMES(metric, setup_time(),
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(10), 100);
+ break;
+ case ClientSocketHandle::UNUSED_IDLE:
+ metric = "Net." + pool_->name() +
+ "SocketIdleTimeBeforeNextUse_UnusedSocket";
+ UMA_HISTOGRAM_CUSTOM_TIMES(metric, idle_time(),
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(6), 100);
+ break;
+ case ClientSocketHandle::REUSED_IDLE:
+ metric = "Net." + pool_->name() +
+ "SocketIdleTimeBeforeNextUse_ReusedSocket";
+ UMA_HISTOGRAM_CUSTOM_TIMES(metric, idle_time(),
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(6), 100);
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
}
} // namespace net