OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_SPDY_SPDY_SESSION_H_ | 5 #ifndef NET_SPDY_SPDY_SESSION_H_ |
6 #define NET_SPDY_SPDY_SESSION_H_ | 6 #define NET_SPDY_SPDY_SESSION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <list> | 10 #include <list> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 : url(&url), priority(priority), spdy_stream(spdy_stream), | 211 : url(&url), priority(priority), spdy_stream(spdy_stream), |
212 stream_net_log(&stream_net_log), callback(callback) { } | 212 stream_net_log(&stream_net_log), callback(callback) { } |
213 }; | 213 }; |
214 typedef std::queue<PendingCreateStream, std::list< PendingCreateStream> > | 214 typedef std::queue<PendingCreateStream, std::list< PendingCreateStream> > |
215 PendingCreateStreamQueue; | 215 PendingCreateStreamQueue; |
216 typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap; | 216 typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap; |
217 // Only HTTP push a stream. | 217 // Only HTTP push a stream. |
218 typedef std::map<std::string, scoped_refptr<SpdyStream> > PushedStreamMap; | 218 typedef std::map<std::string, scoped_refptr<SpdyStream> > PushedStreamMap; |
219 typedef std::priority_queue<SpdyIOBuffer> OutputQueue; | 219 typedef std::priority_queue<SpdyIOBuffer> OutputQueue; |
220 | 220 |
| 221 struct CallbackResultPair { |
| 222 CallbackResultPair() : callback(NULL), result(OK) {} |
| 223 CallbackResultPair(CompletionCallback* callback_in, int result_in) |
| 224 : callback(callback_in), result(result_in) {} |
| 225 |
| 226 CompletionCallback* callback; |
| 227 int result; |
| 228 }; |
| 229 |
| 230 typedef std::map<const scoped_refptr<SpdyStream>*, CallbackResultPair> |
| 231 PendingCallbackMap; |
| 232 |
221 virtual ~SpdySession(); | 233 virtual ~SpdySession(); |
222 | 234 |
223 void ProcessPendingCreateStreams(); | 235 void ProcessPendingCreateStreams(); |
224 int CreateStreamImpl( | 236 int CreateStreamImpl( |
225 const GURL& url, | 237 const GURL& url, |
226 RequestPriority priority, | 238 RequestPriority priority, |
227 scoped_refptr<SpdyStream>* spdy_stream, | 239 scoped_refptr<SpdyStream>* spdy_stream, |
228 const BoundNetLog& stream_net_log); | 240 const BoundNetLog& stream_net_log); |
229 | 241 |
230 // SpdyFramerVisitorInterface | 242 // SpdyFramerVisitorInterface |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 bool Respond(const spdy::SpdyHeaderBlock& headers, | 302 bool Respond(const spdy::SpdyHeaderBlock& headers, |
291 const scoped_refptr<SpdyStream> stream); | 303 const scoped_refptr<SpdyStream> stream); |
292 | 304 |
293 void RecordHistograms(); | 305 void RecordHistograms(); |
294 | 306 |
295 // Closes all streams. Used as part of shutdown. | 307 // Closes all streams. Used as part of shutdown. |
296 void CloseAllStreams(net::Error status); | 308 void CloseAllStreams(net::Error status); |
297 | 309 |
298 // Invokes a user callback for stream creation. We provide this method so it | 310 // Invokes a user callback for stream creation. We provide this method so it |
299 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. | 311 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. |
300 void InvokeUserStreamCreationCallback(CompletionCallback* callback, int rv); | 312 void InvokeUserStreamCreationCallback(scoped_refptr<SpdyStream>* stream); |
301 | 313 |
302 // Callbacks for the Spdy session. | 314 // Callbacks for the Spdy session. |
303 CompletionCallbackImpl<SpdySession> read_callback_; | 315 CompletionCallbackImpl<SpdySession> read_callback_; |
304 CompletionCallbackImpl<SpdySession> write_callback_; | 316 CompletionCallbackImpl<SpdySession> write_callback_; |
305 | 317 |
306 // Used for posting asynchronous IO tasks. We use this even though | 318 // Used for posting asynchronous IO tasks. We use this even though |
307 // SpdySession is refcounted because we don't need to keep the SpdySession | 319 // SpdySession is refcounted because we don't need to keep the SpdySession |
308 // alive if the last reference is within a RunnableMethod. Just revoke the | 320 // alive if the last reference is within a RunnableMethod. Just revoke the |
309 // method. | 321 // method. |
310 ScopedRunnableMethodFactory<SpdySession> method_factory_; | 322 ScopedRunnableMethodFactory<SpdySession> method_factory_; |
311 | 323 |
| 324 // Map of the SpdyStreams for which we have a pending Task to invoke a |
| 325 // callback. This is necessary since, before we invoke said callback, it's |
| 326 // possible that the request is cancelled. |
| 327 PendingCallbackMap pending_callback_map_; |
| 328 |
312 // The domain this session is connected to. | 329 // The domain this session is connected to. |
313 const HostPortProxyPair host_port_proxy_pair_; | 330 const HostPortProxyPair host_port_proxy_pair_; |
314 | 331 |
315 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We | 332 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We |
316 // set this to NULL after we are removed from the pool. | 333 // set this to NULL after we are removed from the pool. |
317 SpdySessionPool* spdy_session_pool_; | 334 SpdySessionPool* spdy_session_pool_; |
318 SpdySettingsStorage* const spdy_settings_; | 335 SpdySettingsStorage* const spdy_settings_; |
319 | 336 |
320 // The socket handle for this session. | 337 // The socket handle for this session. |
321 scoped_ptr<ClientSocketHandle> connection_; | 338 scoped_ptr<ClientSocketHandle> connection_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 411 |
395 BoundNetLog net_log_; | 412 BoundNetLog net_log_; |
396 | 413 |
397 static bool use_ssl_; | 414 static bool use_ssl_; |
398 static bool use_flow_control_; | 415 static bool use_flow_control_; |
399 }; | 416 }; |
400 | 417 |
401 } // namespace net | 418 } // namespace net |
402 | 419 |
403 #endif // NET_SPDY_SPDY_SESSION_H_ | 420 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |