summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_pool_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket/client_socket_pool_base.h')
-rw-r--r--net/socket/client_socket_pool_base.h105
1 files changed, 67 insertions, 38 deletions
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index bd30a8b..ce759a0 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -1,4 +1,5 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011,2012 Code Aurora Forum. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -18,7 +19,6 @@
// implementing ConnectJob::ConnectInternal(). They can control the parameters
// passed to each new ConnectJob instance via their ConnectJobFactory subclass
// and templated SocketParams parameter.
-//
#ifndef NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
#define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
#pragma once
@@ -44,10 +44,15 @@
#include "net/base/request_priority.h"
#include "net/socket/client_socket.h"
#include "net/socket/client_socket_pool.h"
+#include "net/base/host_resolver.h"
+#include "tcp_fin_aggregation.h"
+#include "tcp_fin_aggregation_factory.h"
namespace net {
class ClientSocketHandle;
+class HttpNetworkSession;
+class ITCPFinAggregation;
// ConnectJob provides an abstract interface for "connecting" a socket.
// The connection may involve host resolution, tcp connection, ssl connection,
@@ -149,6 +154,29 @@ class ConnectJob {
namespace internal {
+ // Entry for a persistent socket which became idle at time |start_time|.
+ class IdleSocket {
+ public:
+ IdleSocket() : socket(NULL) {}
+ ClientSocket* socket;
+ base::Time start_time;
+
+ // An idle socket should be removed if it can't be reused, or has been idle
+ // for too long. |now| is the current time value (TimeTicks::Now()).
+ // |timeout| is the length of time to wait before timing out an idle socket.
+ //
+ // An idle socket can't be reused if it is disconnected or has received
+ // data unexpectedly (hence no longer idle). The unread data would be
+ // mistaken for the beginning of the next response if we were to reuse the
+ // socket for a new request.
+ bool ShouldCleanup(base::Time now, base::TimeDelta timeout) const;
+
+ base::Time StartTime() const
+ {
+ return start_time;
+ }
+ };
+
// ClientSocketPoolBaseHelper is an internal class that implements almost all
// the functionality from ClientSocketPoolBase without using templates.
// ClientSocketPoolBase adds templated definitions built on top of
@@ -224,7 +252,8 @@ class ClientSocketPoolBaseHelper
int max_sockets_per_group,
base::TimeDelta unused_idle_socket_timeout,
base::TimeDelta used_idle_socket_timeout,
- ConnectJobFactory* connect_job_factory);
+ ConnectJobFactory* connect_job_factory,
+ HttpNetworkSession *network_session);
~ClientSocketPoolBaseHelper();
@@ -258,6 +287,18 @@ class ClientSocketPoolBaseHelper
return idle_socket_count_;
}
+ // Called when the number of idle sockets changes.
+ void IncrementIdleCount();
+ void DecrementIdleCount();
+
+ class Group;
+ typedef std::map<std::string, Group*> GroupMap;
+
+ void RemoveGroup(const std::string& group_name);
+ void RemoveGroup(GroupMap::iterator it);
+
+ GroupMap group_map_;
+
// See ClientSocketPool::IdleSocketCountInGroup() for documentation on this
// function.
int IdleSocketCountInGroup(const std::string& group_name) const;
@@ -313,29 +354,9 @@ class ClientSocketPoolBaseHelper
// NetworkChangeNotifier::IPAddressObserver methods:
virtual void OnIPAddressChanged();
- private:
- friend class base::RefCounted<ClientSocketPoolBaseHelper>;
-
- // Entry for a persistent socket which became idle at time |start_time|.
- struct IdleSocket {
- IdleSocket() : socket(NULL) {}
-
- // An idle socket should be removed if it can't be reused, or has been idle
- // for too long. |now| is the current time value (TimeTicks::Now()).
- // |timeout| is the length of time to wait before timing out an idle socket.
- //
- // An idle socket can't be reused if it is disconnected or has received
- // data unexpectedly (hence no longer idle). The unread data would be
- // mistaken for the beginning of the next response if we were to reuse the
- // socket for a new request.
- bool ShouldCleanup(base::TimeTicks now, base::TimeDelta timeout) const;
-
- ClientSocket* socket;
- base::TimeTicks start_time;
- };
-
typedef std::deque<const Request* > RequestQueue;
- typedef std::map<const ClientSocketHandle*, const Request*> RequestMap;
+
+ HttpNetworkSession *network_session_;
// A Group is allocated per group_name when there are idle sockets or pending
// requests. Otherwise, the Group object is removed from the map.
@@ -410,7 +431,10 @@ class ClientSocketPoolBaseHelper
ScopedRunnableMethodFactory<Group> method_factory_;
};
- typedef std::map<std::string, Group*> GroupMap;
+ private:
+ friend class base::RefCounted<ClientSocketPoolBaseHelper>;
+
+ typedef std::map<const ClientSocketHandle*, const Request*> RequestMap;
typedef std::set<ConnectJob*> ConnectJobSet;
@@ -432,12 +456,6 @@ class ClientSocketPoolBaseHelper
Group* group);
Group* GetOrCreateGroup(const std::string& group_name);
- void RemoveGroup(const std::string& group_name);
- void RemoveGroup(GroupMap::iterator it);
-
- // Called when the number of idle sockets changes.
- void IncrementIdleCount();
- void DecrementIdleCount();
// Start cleanup timer for idle sockets.
void StartIdleSocketTimer();
@@ -450,9 +468,7 @@ class ClientSocketPoolBaseHelper
// Called when timer_ fires. This method scans the idle sockets removing
// sockets that timed out or can't be reused.
- void OnCleanupTimerFired() {
- CleanupIdleSockets(false);
- }
+ void OnCleanupTimerFired();
// Removes |job| from |connect_job_set_|. Also updates |group| if non-NULL.
void RemoveConnectJob(ConnectJob* job, Group* group);
@@ -526,8 +542,6 @@ class ClientSocketPoolBaseHelper
// in |pending_callback_map_|.
void InvokeUserCallback(ClientSocketHandle* handle);
- GroupMap group_map_;
-
// Map of the ClientSocketHandles for which we have a pending Task to invoke a
// callback. This is necessary since, before we invoke said callback, it's
// possible that the request is cancelled.
@@ -552,9 +566,22 @@ class ClientSocketPoolBaseHelper
// The maximum number of sockets kept per group.
const int max_sockets_per_group_;
+ // Pointer to ITCPFinAggregation interface that implements
+ // TCP Fin Aggregation feature.
+ ITCPFinAggregation* tcp_fin_aggregation;
+
+ // TCP Fin Aggregation feature
+ bool net_tcp_fin_aggr_feature_enabled_sys_property_;
+
// Whether to use timer to cleanup idle sockets.
bool use_cleanup_timer_;
+ // Whether statistics is enabled.
+ bool net_statistics_enabled;
+
+ // Whether unused sockets are closed after page load fnished
+ bool close_unused_sockets_enabled;
+
// The time to wait until closing idle sockets.
const base::TimeDelta unused_idle_socket_timeout_;
const base::TimeDelta used_idle_socket_timeout_;
@@ -638,11 +665,13 @@ class ClientSocketPoolBase {
ClientSocketPoolHistograms* histograms,
base::TimeDelta unused_idle_socket_timeout,
base::TimeDelta used_idle_socket_timeout,
- ConnectJobFactory* connect_job_factory)
+ ConnectJobFactory* connect_job_factory,
+ HttpNetworkSession *network_session)
: histograms_(histograms),
helper_(max_sockets, max_sockets_per_group,
unused_idle_socket_timeout, used_idle_socket_timeout,
- new ConnectJobFactoryAdaptor(connect_job_factory)) {}
+ new ConnectJobFactoryAdaptor(connect_job_factory),
+ network_session) {}
virtual ~ClientSocketPoolBase() {}