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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // reasonably with ethernet. Chop the world into 2-packet chunks. This is | 42 // reasonably with ethernet. Chop the world into 2-packet chunks. This is |
43 // somewhat arbitrary, but is reasonably small and ensures that we elicit | 43 // somewhat arbitrary, but is reasonably small and ensures that we elicit |
44 // ACKs quickly from TCP (because TCP tries to only ACK every other packet). | 44 // ACKs quickly from TCP (because TCP tries to only ACK every other packet). |
45 const int kMss = 1430; | 45 const int kMss = 1430; |
46 const int kMaxSpdyFrameChunkSize = (2 * kMss) - SpdyFrame::kHeaderSize; | 46 const int kMaxSpdyFrameChunkSize = (2 * kMss) - SpdyFrame::kHeaderSize; |
47 | 47 |
48 class BoundNetLog; | 48 class BoundNetLog; |
49 class SpdyStream; | 49 class SpdyStream; |
50 class SSLInfo; | 50 class SSLInfo; |
51 | 51 |
| 52 enum SpdyProtocolErrorDetails { |
| 53 // SpdyFramer::SpdyErrors |
| 54 SPDY_ERROR_NO_ERROR, |
| 55 SPDY_ERROR_INVALID_CONTROL_FRAME, |
| 56 SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE, |
| 57 SPDY_ERROR_ZLIB_INIT_FAILURE, |
| 58 SPDY_ERROR_UNSUPPORTED_VERSION, |
| 59 SPDY_ERROR_DECOMPRESS_FAILURE, |
| 60 SPDY_ERROR_COMPRESS_FAILURE, |
| 61 SPDY_ERROR_CREDENTIAL_FRAME_CORRUPT, |
| 62 SPDY_ERROR_INVALID_DATA_FRAME_FLAGS, |
| 63 |
| 64 // SpdyStatusCodes |
| 65 STATUS_CODE_INVALID, |
| 66 STATUS_CODE_PROTOCOL_ERROR, |
| 67 STATUS_CODE_INVALID_STREAM, |
| 68 STATUS_CODE_REFUSED_STREAM, |
| 69 STATUS_CODE_UNSUPPORTED_VERSION, |
| 70 STATUS_CODE_CANCEL, |
| 71 STATUS_CODE_INTERNAL_ERROR, |
| 72 STATUS_CODE_FLOW_CONTROL_ERROR, |
| 73 STATUS_CODE_STREAM_IN_USE, |
| 74 STATUS_CODE_STREAM_ALREADY_CLOSED, |
| 75 STATUS_CODE_INVALID_CREDENTIALS, |
| 76 STATUS_CODE_FRAME_TOO_LARGE, |
| 77 |
| 78 // SpdySession errors |
| 79 PROTOCOL_ERROR_UNEXPECTED_PING, |
| 80 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM, |
| 81 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE, |
| 82 PROTOCOL_ERROR_REQUST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION, |
| 83 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED, |
| 84 NUM_SPDY_PROTOCOL_ERROR_DETAILS |
| 85 }; |
| 86 |
| 87 COMPILE_ASSERT(STATUS_CODE_INVALID == |
| 88 static_cast<SpdyProtocolErrorDetails>(SpdyFramer::LAST_ERROR), |
| 89 SpdyProtocolErrorDetails_SpdyErrors_mismatch); |
| 90 |
| 91 COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING == |
| 92 static_cast<SpdyProtocolErrorDetails>(NUM_STATUS_CODES + |
| 93 STATUS_CODE_INVALID), |
| 94 SpdyProtocolErrorDetails_SpdyErrors_mismatch); |
| 95 |
52 class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, | 96 class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, |
53 public BufferedSpdyFramerVisitorInterface { | 97 public BufferedSpdyFramerVisitorInterface { |
54 public: | 98 public: |
55 // Create a new SpdySession. | 99 // Create a new SpdySession. |
56 // |host_port_proxy_pair| is the host/port that this session connects to, and | 100 // |host_port_proxy_pair| is the host/port that this session connects to, and |
57 // the proxy configuration settings that it's using. | 101 // the proxy configuration settings that it's using. |
58 // |spdy_session_pool| is the SpdySessionPool that owns us. Its lifetime must | 102 // |spdy_session_pool| is the SpdySessionPool that owns us. Its lifetime must |
59 // strictly be greater than |this|. | 103 // strictly be greater than |this|. |
60 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log | 104 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log |
61 // network events to. | 105 // network events to. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 scoped_refptr<SpdyStream> GetActivePushStream(const std::string& url); | 454 scoped_refptr<SpdyStream> GetActivePushStream(const std::string& url); |
411 | 455 |
412 // Calls OnResponseReceived(). | 456 // Calls OnResponseReceived(). |
413 // Returns true if successful. | 457 // Returns true if successful. |
414 bool Respond(const SpdyHeaderBlock& headers, | 458 bool Respond(const SpdyHeaderBlock& headers, |
415 const scoped_refptr<SpdyStream> stream); | 459 const scoped_refptr<SpdyStream> stream); |
416 | 460 |
417 | 461 |
418 void RecordPingRTTHistogram(base::TimeDelta duration); | 462 void RecordPingRTTHistogram(base::TimeDelta duration); |
419 void RecordHistograms(); | 463 void RecordHistograms(); |
| 464 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); |
420 | 465 |
421 // Closes all streams. Used as part of shutdown. | 466 // Closes all streams. Used as part of shutdown. |
422 void CloseAllStreams(net::Error status); | 467 void CloseAllStreams(net::Error status); |
423 | 468 |
424 // Invokes a user callback for stream creation. We provide this method so it | 469 // Invokes a user callback for stream creation. We provide this method so it |
425 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. | 470 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. |
426 void InvokeUserStreamCreationCallback(scoped_refptr<SpdyStream>* stream); | 471 void InvokeUserStreamCreationCallback(scoped_refptr<SpdyStream>* stream); |
427 | 472 |
428 // BufferedSpdyFramerVisitorInterface: | 473 // BufferedSpdyFramerVisitorInterface: |
429 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE; | 474 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 743 |
699 const int status_; | 744 const int status_; |
700 const std::string description_; | 745 const std::string description_; |
701 | 746 |
702 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySessionCloseParameter); | 747 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySessionCloseParameter); |
703 }; | 748 }; |
704 | 749 |
705 } // namespace net | 750 } // namespace net |
706 | 751 |
707 #endif // NET_SPDY_SPDY_SESSION_H_ | 752 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |