| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return spdy_session_key_; | 319 return spdy_session_key_; |
| 320 } | 320 } |
| 321 // Get a pushed stream for a given |url|. If the server initiates a | 321 // Get a pushed stream for a given |url|. If the server initiates a |
| 322 // stream, it might already exist for a given path. The server | 322 // stream, it might already exist for a given path. The server |
| 323 // might also not have initiated the stream yet, but indicated it | 323 // might also not have initiated the stream yet, but indicated it |
| 324 // will via X-Associated-Content. Returns OK if a stream was found | 324 // will via X-Associated-Content. Returns OK if a stream was found |
| 325 // and put into |spdy_stream|, or if one was not found but it is | 325 // and put into |spdy_stream|, or if one was not found but it is |
| 326 // okay to create a new stream (in which case |spdy_stream| is | 326 // okay to create a new stream (in which case |spdy_stream| is |
| 327 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and | 327 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and |
| 328 // resets |spdy_stream|. | 328 // resets |spdy_stream|. |
| 329 // |
| 330 // If a stream was found and the stream is still open, the priority |
| 331 // of that stream is updated to match |priority|. |
| 329 int GetPushStream(const GURL& url, | 332 int GetPushStream(const GURL& url, |
| 333 RequestPriority priority, |
| 330 base::WeakPtr<SpdyStream>* spdy_stream, | 334 base::WeakPtr<SpdyStream>* spdy_stream, |
| 331 const NetLogWithSource& stream_net_log); | 335 const NetLogWithSource& stream_net_log); |
| 332 | 336 |
| 333 // Called when the pushed stream should be cancelled. If the pushed stream is | 337 // Called when the pushed stream should be cancelled. If the pushed stream is |
| 334 // not claimed and active, sends RST to the server to cancel the stream. | 338 // not claimed and active, sends RST to the server to cancel the stream. |
| 335 void CancelPush(const GURL& url); | 339 void CancelPush(const GURL& url); |
| 336 | 340 |
| 337 // Initialize the session with the given connection. |is_secure| | 341 // Initialize the session with the given connection. |is_secure| |
| 338 // must indicate whether |connection| uses an SSL socket or not; it | 342 // must indicate whether |connection| uses an SSL socket or not; it |
| 339 // is usually true, but it can be false for testing or when SPDY is | 343 // is usually true, but it can be false for testing or when SPDY is |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 // there is none. | 671 // there is none. |
| 668 base::WeakPtr<SpdyStreamRequest> GetNextPendingStreamRequest(); | 672 base::WeakPtr<SpdyStreamRequest> GetNextPendingStreamRequest(); |
| 669 | 673 |
| 670 // Called when there is room to create more streams (e.g., a stream | 674 // Called when there is room to create more streams (e.g., a stream |
| 671 // was closed). Processes as many pending stream requests as | 675 // was closed). Processes as many pending stream requests as |
| 672 // possible. | 676 // possible. |
| 673 void ProcessPendingStreamRequests(); | 677 void ProcessPendingStreamRequests(); |
| 674 | 678 |
| 675 void TryCreatePushStream(SpdyStreamId stream_id, | 679 void TryCreatePushStream(SpdyStreamId stream_id, |
| 676 SpdyStreamId associated_stream_id, | 680 SpdyStreamId associated_stream_id, |
| 677 SpdyPriority priority, | |
| 678 SpdyHeaderBlock headers); | 681 SpdyHeaderBlock headers); |
| 679 | 682 |
| 680 // Close the stream pointed to by the given iterator. Note that that | 683 // Close the stream pointed to by the given iterator. Note that that |
| 681 // stream may hold the last reference to the session. | 684 // stream may hold the last reference to the session. |
| 682 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); | 685 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); |
| 683 | 686 |
| 684 // Close the stream pointed to by the given iterator. Note that that | 687 // Close the stream pointed to by the given iterator. Note that that |
| 685 // stream may hold the last reference to the session. | 688 // stream may hold the last reference to the session. |
| 686 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status); | 689 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status); |
| 687 | 690 |
| 688 // Calls EnqueueResetStreamFrame() and then | 691 // Calls EnqueueResetStreamFrame() and then |
| 689 // CloseActiveStreamIterator(). | 692 // CloseActiveStreamIterator(). |
| 690 void ResetStreamIterator(ActiveStreamMap::iterator it, | 693 void ResetStreamIterator(ActiveStreamMap::iterator it, |
| 691 SpdyRstStreamStatus status, | 694 SpdyRstStreamStatus status, |
| 692 const std::string& description); | 695 const std::string& description); |
| 693 | 696 |
| 694 // Send a RST_STREAM frame with the given parameters. There should | 697 // Send a RST_STREAM frame with the given parameters. There should |
| 695 // either be no active stream with the given ID, or that active | 698 // either be no active stream with the given ID, or that active |
| 696 // stream should be closed shortly after this function is called. | 699 // stream should be closed shortly after this function is called. |
| 697 // | |
| 698 // TODO(akalin): Rename this to EnqueueResetStreamFrame(). | |
| 699 void EnqueueResetStreamFrame(SpdyStreamId stream_id, | 700 void EnqueueResetStreamFrame(SpdyStreamId stream_id, |
| 700 RequestPriority priority, | 701 RequestPriority priority, |
| 701 SpdyRstStreamStatus status, | 702 SpdyRstStreamStatus status, |
| 702 const std::string& description); | 703 const std::string& description); |
| 703 | 704 |
| 705 // Send a PRIORITY frame with the given parameters. |
| 706 void EnqueuePriorityFrame(SpdyStreamId stream_id, |
| 707 SpdyStreamId dependency_id, |
| 708 int weight, |
| 709 bool exclusive); |
| 710 |
| 704 // Calls DoReadLoop. Use this function instead of DoReadLoop when | 711 // Calls DoReadLoop. Use this function instead of DoReadLoop when |
| 705 // posting a task to pump the read loop. | 712 // posting a task to pump the read loop. |
| 706 void PumpReadLoop(ReadState expected_read_state, int result); | 713 void PumpReadLoop(ReadState expected_read_state, int result); |
| 707 | 714 |
| 708 // Advance the ReadState state machine. |expected_read_state| is the | 715 // Advance the ReadState state machine. |expected_read_state| is the |
| 709 // expected starting read state. | 716 // expected starting read state. |
| 710 // | 717 // |
| 711 // This function must always be called via PumpReadLoop(). | 718 // This function must always be called via PumpReadLoop(). |
| 712 int DoReadLoop(ReadState expected_read_state, int result); | 719 int DoReadLoop(ReadState expected_read_state, int result); |
| 713 // The implementations of the states of the ReadState state machine. | 720 // The implementations of the states of the ReadState state machine. |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 // Used for posting asynchronous IO tasks. We use this even though | 1212 // Used for posting asynchronous IO tasks. We use this even though |
| 1206 // SpdySession is refcounted because we don't need to keep the SpdySession | 1213 // SpdySession is refcounted because we don't need to keep the SpdySession |
| 1207 // alive if the last reference is within a RunnableMethod. Just revoke the | 1214 // alive if the last reference is within a RunnableMethod. Just revoke the |
| 1208 // method. | 1215 // method. |
| 1209 base::WeakPtrFactory<SpdySession> weak_factory_; | 1216 base::WeakPtrFactory<SpdySession> weak_factory_; |
| 1210 }; | 1217 }; |
| 1211 | 1218 |
| 1212 } // namespace net | 1219 } // namespace net |
| 1213 | 1220 |
| 1214 #endif // NET_SPDY_SPDY_SESSION_H_ | 1221 #endif // NET_SPDY_SPDY_SESSION_H_ |
| OLD | NEW |