OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
20 #include "net/base/load_states.h" | 20 #include "net/base/load_states.h" |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
23 #include "net/base/request_priority.h" | 23 #include "net/base/request_priority.h" |
24 #include "net/socket/client_socket_handle.h" | 24 #include "net/socket/client_socket_handle.h" |
25 #include "net/socket/next_proto.h" | 25 #include "net/socket/next_proto.h" |
26 #include "net/socket/ssl_client_socket.h" | 26 #include "net/socket/ssl_client_socket.h" |
27 #include "net/socket/stream_socket.h" | 27 #include "net/socket/stream_socket.h" |
28 #include "net/spdy/buffered_spdy_framer.h" | 28 #include "net/spdy/buffered_spdy_framer.h" |
| 29 #include "net/spdy/spdy_buffer.h" |
29 #include "net/spdy/spdy_credential_state.h" | 30 #include "net/spdy/spdy_credential_state.h" |
30 #include "net/spdy/spdy_header_block.h" | 31 #include "net/spdy/spdy_header_block.h" |
31 #include "net/spdy/spdy_io_buffer.h" | |
32 #include "net/spdy/spdy_protocol.h" | 32 #include "net/spdy/spdy_protocol.h" |
33 #include "net/spdy/spdy_session_pool.h" | 33 #include "net/spdy/spdy_session_pool.h" |
34 #include "net/spdy/spdy_write_queue.h" | 34 #include "net/spdy/spdy_write_queue.h" |
35 #include "net/ssl/ssl_client_cert_type.h" | 35 #include "net/ssl/ssl_client_cert_type.h" |
36 #include "net/ssl/ssl_config_service.h" | 36 #include "net/ssl/ssl_config_service.h" |
37 | 37 |
38 namespace net { | 38 namespace net { |
39 | 39 |
40 // This is somewhat arbitrary and not really fixed, but it will always work | 40 // This is somewhat arbitrary and not really fixed, but it will always work |
41 // reasonably with ethernet. Chop the world into 2-packet chunks. This is | 41 // reasonably with ethernet. Chop the world into 2-packet chunks. This is |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch | 235 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch |
236 // histogram because this function does more than verifying domain | 236 // histogram because this function does more than verifying domain |
237 // authentication now. | 237 // authentication now. |
238 bool VerifyDomainAuthentication(const std::string& domain); | 238 bool VerifyDomainAuthentication(const std::string& domain); |
239 | 239 |
240 // Pushes the given producer into the write queue for | 240 // Pushes the given producer into the write queue for |
241 // |stream|. |stream| is guaranteed to be activated before the | 241 // |stream|. |stream| is guaranteed to be activated before the |
242 // producer is used to produce its frame. | 242 // producer is used to produce its frame. |
243 void EnqueueStreamWrite(SpdyStream* stream, | 243 void EnqueueStreamWrite(SpdyStream* stream, |
244 SpdyFrameType frame_type, | 244 SpdyFrameType frame_type, |
245 scoped_ptr<SpdyFrameProducer> producer); | 245 scoped_ptr<SpdyBufferProducer> producer); |
246 | 246 |
247 // Creates and returns a SYN frame for |stream_id|. | 247 // Creates and returns a SYN frame for |stream_id|. |
248 scoped_ptr<SpdyFrame> CreateSynStream( | 248 scoped_ptr<SpdyFrame> CreateSynStream( |
249 SpdyStreamId stream_id, | 249 SpdyStreamId stream_id, |
250 RequestPriority priority, | 250 RequestPriority priority, |
251 uint8 credential_slot, | 251 uint8 credential_slot, |
252 SpdyControlFlags flags, | 252 SpdyControlFlags flags, |
253 const SpdyHeaderBlock& headers); | 253 const SpdyHeaderBlock& headers); |
254 | 254 |
255 // Tries to create a CREDENTIAL frame. If successful, fills in | 255 // Tries to create a CREDENTIAL frame. If successful, fills in |
256 // |credential_frame| and returns OK. Returns the error (guaranteed | 256 // |credential_frame| and returns OK. Returns the error (guaranteed |
257 // to not be ERR_IO_PENDING) otherwise. | 257 // to not be ERR_IO_PENDING) otherwise. |
258 int CreateCredentialFrame(const std::string& origin, | 258 int CreateCredentialFrame(const std::string& origin, |
259 SSLClientCertType type, | 259 SSLClientCertType type, |
260 const std::string& key, | 260 const std::string& key, |
261 const std::string& cert, | 261 const std::string& cert, |
262 RequestPriority priority, | 262 RequestPriority priority, |
263 scoped_ptr<SpdyFrame>* credential_frame); | 263 scoped_ptr<SpdyFrame>* credential_frame); |
264 | 264 |
265 // Creates and returns a HEADERS frame. | 265 // Creates and returns a HEADERS frame. |
266 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id, | 266 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id, |
267 const SpdyHeaderBlock& headers, | 267 const SpdyHeaderBlock& headers, |
268 SpdyControlFlags flags); | 268 SpdyControlFlags flags); |
269 | 269 |
270 // Creates and returns a data frame. May return NULL if stalled by | 270 // Creates and returns a SpdyBuffer holding a data frame with the |
271 // flow control. | 271 // given data. May return NULL if stalled by flow control. |
272 scoped_ptr<SpdyFrame> CreateDataFrame(SpdyStreamId stream_id, | 272 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id, |
273 net::IOBuffer* data, | 273 net::IOBuffer* data, |
274 int len, | 274 int len, |
275 SpdyDataFlags flags); | 275 SpdyDataFlags flags); |
276 | 276 |
277 // Close a stream. | 277 // Close a stream. |
278 void CloseStream(SpdyStreamId stream_id, int status); | 278 void CloseStream(SpdyStreamId stream_id, int status); |
279 | 279 |
280 // Close a stream that has been created but is not yet active. | 280 // Close a stream that has been created but is not yet active. |
281 void CloseCreatedStream(SpdyStream* stream, int status); | 281 void CloseCreatedStream(SpdyStream* stream, int status); |
282 | 282 |
283 // Reset a stream by sending a RST_STREAM frame with given status code. | 283 // Reset a stream by sending a RST_STREAM frame with given status code. |
284 // Also closes the stream. Was not piggybacked to CloseStream since not | 284 // Also closes the stream. Was not piggybacked to CloseStream since not |
285 // all of the calls to CloseStream necessitate sending a RST_STREAM. | 285 // all of the calls to CloseStream necessitate sending a RST_STREAM. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // Pushes the given frame with the given priority into the write | 561 // Pushes the given frame with the given priority into the write |
562 // queue for the session. | 562 // queue for the session. |
563 void EnqueueSessionWrite(RequestPriority priority, | 563 void EnqueueSessionWrite(RequestPriority priority, |
564 SpdyFrameType frame_type, | 564 SpdyFrameType frame_type, |
565 scoped_ptr<SpdyFrame> frame); | 565 scoped_ptr<SpdyFrame> frame); |
566 | 566 |
567 // Puts |producer| associated with |stream| onto the write queue | 567 // Puts |producer| associated with |stream| onto the write queue |
568 // with the given priority. | 568 // with the given priority. |
569 void EnqueueWrite(RequestPriority priority, | 569 void EnqueueWrite(RequestPriority priority, |
570 SpdyFrameType frame_type, | 570 SpdyFrameType frame_type, |
571 scoped_ptr<SpdyFrameProducer> producer, | 571 scoped_ptr<SpdyBufferProducer> producer, |
572 const scoped_refptr<SpdyStream>& stream); | 572 const scoped_refptr<SpdyStream>& stream); |
573 | 573 |
574 // Track active streams in the active stream list. | 574 // Track active streams in the active stream list. |
575 void ActivateStream(SpdyStream* stream); | 575 void ActivateStream(SpdyStream* stream); |
576 void DeleteStream(SpdyStreamId id, int status); | 576 void DeleteStream(SpdyStreamId id, int status); |
577 | 577 |
578 // Removes this session from the session pool. | 578 // Removes this session from the session pool. |
579 void RemoveFromPool(); | 579 void RemoveFromPool(); |
580 | 580 |
581 // Check if we have a pending pushed-stream for this url | 581 // Check if we have a pending pushed-stream for this url |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 // Map of all the streams that have already started to be pushed by the | 749 // Map of all the streams that have already started to be pushed by the |
750 // server, but do not have consumers yet. | 750 // server, but do not have consumers yet. |
751 PushedStreamMap unclaimed_pushed_streams_; | 751 PushedStreamMap unclaimed_pushed_streams_; |
752 | 752 |
753 // Set of all created streams but that have not yet sent any frames. | 753 // Set of all created streams but that have not yet sent any frames. |
754 CreatedStreamSet created_streams_; | 754 CreatedStreamSet created_streams_; |
755 | 755 |
756 // The write queue. | 756 // The write queue. |
757 SpdyWriteQueue write_queue_; | 757 SpdyWriteQueue write_queue_; |
758 | 758 |
759 // The packet we are currently sending. | 759 // Data for the frame we are currently sending. |
760 bool write_pending_; // Will be true when a write is in progress. | 760 // Whether we have a socket write pending completion. |
761 SpdyIOBuffer in_flight_write_; // This is the write buffer in progress. | 761 bool write_pending_; |
| 762 // The buffer we're currently writing. |
| 763 scoped_ptr<SpdyBuffer> in_flight_write_; |
| 764 // The type of the frame in |in_flight_write_|. |
762 SpdyFrameType in_flight_write_frame_type_; | 765 SpdyFrameType in_flight_write_frame_type_; |
| 766 // The size of the frame in |in_flight_write_|. |
| 767 size_t in_flight_write_frame_size_; |
| 768 // The stream to notify when |in_flight_write_| has been written to |
| 769 // the socket completely. |
| 770 scoped_refptr<SpdyStream> in_flight_write_stream_; |
763 | 771 |
764 // Flag if we have a pending message scheduled for WriteSocket. | 772 // Flag if we have a pending message scheduled for WriteSocket. |
765 bool delayed_write_pending_; | 773 bool delayed_write_pending_; |
766 | 774 |
767 // Flag if we're using an SSL connection for this SpdySession. | 775 // Flag if we're using an SSL connection for this SpdySession. |
768 bool is_secure_; | 776 bool is_secure_; |
769 | 777 |
770 // Certificate error code when using a secure connection. | 778 // Certificate error code when using a secure connection. |
771 int certificate_error_code_; | 779 int certificate_error_code_; |
772 | 780 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 // This SPDY proxy is allowed to push resources from origins that are | 884 // This SPDY proxy is allowed to push resources from origins that are |
877 // different from those of their associated streams. | 885 // different from those of their associated streams. |
878 HostPortPair trusted_spdy_proxy_; | 886 HostPortPair trusted_spdy_proxy_; |
879 | 887 |
880 TimeFunc time_func_; | 888 TimeFunc time_func_; |
881 }; | 889 }; |
882 | 890 |
883 } // namespace net | 891 } // namespace net |
884 | 892 |
885 #endif // NET_SPDY_SPDY_SESSION_H_ | 893 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |