Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: net/socket/sctp_client_socket_pool.h

Issue 6800009: Attn: Mike Belshe Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_SOCKET_SCTP_CLIENT_SOCKET_POOL_H_
6 #define NET_SOCKET_SCTP_CLIENT_SOCKET_POOL_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h"
15 #include "base/timer.h"
16 #include "net/base/host_port_pair.h"
17 #include "net/base/host_resolver.h"
Mike Belshe 2011/04/06 18:32:53 Nix this clone.
18 #include "net/socket/client_socket_pool_base.h"
19 #include "net/socket/client_socket_pool_histograms.h"
20 #include "net/socket/client_socket_pool.h"
21
22 namespace net {
23
24 class ClientSocketFactory;
25
26 class SCTPSocketParams : public base::RefCounted<SCTPSocketParams> {
27 public:
28 SCTPSocketParams(const HostPortPair& host_port_pair, RequestPriority priority,
29 const GURL& referrer, bool disable_resolver_cache,
30 bool ignore_limits);
31
32 const HostResolver::RequestInfo& destination() const { return destination_; }
33 bool ignore_limits() const { return ignore_limits_; }
34
35 private:
36 friend class base::RefCounted<SCTPSocketParams>;
37 ~SCTPSocketParams();
38
39 void Initialize(RequestPriority priority, const GURL& referrer,
40 bool disable_resolver_cache);
41
42 HostResolver::RequestInfo destination_;
43 bool ignore_limits_;
44
45 DISALLOW_COPY_AND_ASSIGN(SCTPSocketParams);
46 };
47
48 // SCTPConnectJob handles the host resolution necessary for socket creation
49 // and the sctp connect.
50 class SCTPConnectJob : public ConnectJob {
51 public:
52 SCTPConnectJob(const std::string& group_name,
53 const scoped_refptr<SCTPSocketParams>& params,
54 base::TimeDelta timeout_duration,
55 ClientSocketFactory* client_socket_factory,
56 HostResolver* host_resolver,
57 Delegate* delegate,
58 NetLog* net_log);
59 virtual ~SCTPConnectJob();
60
61 // ConnectJob methods.
62 virtual LoadState GetLoadState() const;
63
64 private:
65 enum State {
66 STATE_RESOLVE_HOST,
67 STATE_RESOLVE_HOST_COMPLETE,
68 STATE_SCTP_CONNECT,
69 STATE_SCTP_CONNECT_COMPLETE,
70 STATE_NONE,
71 };
72
73 void OnIOComplete(int result);
74
75 // Runs the state transition loop.
76 int DoLoop(int result);
77
78 int DoResolveHost();
79 int DoResolveHostComplete(int result);
80 int DoSCTPConnect();
81 int DoSCTPConnectComplete(int result);
82
83 // Begins the host resolution and the SCTP connect. Returns OK on success
84 // and ERR_IO_PENDING if it cannot immediately service the request.
85 // Otherwise, it returns a net error code.
86 virtual int ConnectInternal();
87
88 scoped_refptr<SCTPSocketParams> params_;
89 ClientSocketFactory* const client_socket_factory_;
90 CompletionCallbackImpl<SCTPConnectJob> callback_;
91 SingleRequestHostResolver resolver_;
92 AddressList addresses_;
93 State next_state_;
94
95 // The time Connect() was called.
96 base::TimeTicks start_time_;
97
98 // The time the connect was started (after DNS finished).
99 base::TimeTicks connect_start_time_;
100
101 DISALLOW_COPY_AND_ASSIGN(SCTPConnectJob);
102 };
103
104 class SCTPClientSocketPool : public ClientSocketPool {
105 public:
106 SCTPClientSocketPool(
107 int max_sockets,
108 int max_sockets_per_group,
109 ClientSocketPoolHistograms* histograms,
110 HostResolver* host_resolver,
111 ClientSocketFactory* client_socket_factory,
112 NetLog* net_log);
113
114 virtual ~SCTPClientSocketPool();
115
116 // ClientSocketPool methods:
117
118 virtual int RequestSocket(const std::string& group_name,
119 const void* resolve_info,
120 RequestPriority priority,
121 ClientSocketHandle* handle,
122 CompletionCallback* callback,
123 const BoundNetLog& net_log);
124
125 virtual void RequestSockets(const std::string& group_name,
126 const void* params,
127 int num_sockets,
128 const BoundNetLog& net_log);
129
130 virtual void CancelRequest(const std::string& group_name,
131 ClientSocketHandle* handle);
132
133 virtual void ReleaseSocket(const std::string& group_name,
134 ClientSocket* socket,
135 int id);
136
137 virtual void Flush();
138
139 virtual void CloseIdleSockets();
140
141 virtual int IdleSocketCount() const;
142
143 virtual int IdleSocketCountInGroup(const std::string& group_name) const;
144
145 virtual LoadState GetLoadState(const std::string& group_name,
146 const ClientSocketHandle* handle) const;
147
148 virtual DictionaryValue* GetInfoAsValue(const std::string& name,
149 const std::string& type,
150 bool include_nested_pools) const;
151
152 virtual base::TimeDelta ConnectionTimeout() const;
153
154 virtual ClientSocketPoolHistograms* histograms() const;
155
156 private:
157 typedef ClientSocketPoolBase<SCTPSocketParams> PoolBase;
158
159 class SCTPConnectJobFactory
160 : public PoolBase::ConnectJobFactory {
161 public:
162 SCTPConnectJobFactory(ClientSocketFactory* client_socket_factory,
163 HostResolver* host_resolver,
164 NetLog* net_log)
165 : client_socket_factory_(client_socket_factory),
166 host_resolver_(host_resolver),
167 net_log_(net_log) {}
168
169 virtual ~SCTPConnectJobFactory() {}
170
171 // ClientSocketPoolBase::ConnectJobFactory methods.
172
173 virtual ConnectJob* NewConnectJob(
174 const std::string& group_name,
175 const PoolBase::Request& request,
176 ConnectJob::Delegate* delegate) const;
177
178 virtual base::TimeDelta ConnectionTimeout() const;
179
180 private:
181 ClientSocketFactory* const client_socket_factory_;
182 HostResolver* const host_resolver_;
183 NetLog* net_log_;
184
185 DISALLOW_COPY_AND_ASSIGN(SCTPConnectJobFactory);
186 };
187
188 PoolBase base_;
189
190 DISALLOW_COPY_AND_ASSIGN(SCTPClientSocketPool);
191 };
192
193 REGISTER_SOCKET_PARAMS_FOR_POOL(SCTPClientSocketPool, SCTPSocketParams);
194
195 } // namespace net
196
197 #endif // NET_SOCKET_SCTP_CLIENT_SOCKET_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698