summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_session.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 01:20:19 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 01:20:19 +0000
commit82c4d3b8fd037c0ee2c7b391a6f97f0992ecb4a5 (patch)
tree914c5e62150e784065ec4235cf774f59ca19bdf7 /net/spdy/spdy_session.h
parent507b7e211b7018b2a257df8e5ccd6ef5226f4add (diff)
downloadchromium_src-82c4d3b8fd037c0ee2c7b391a6f97f0992ecb4a5.zip
chromium_src-82c4d3b8fd037c0ee2c7b391a6f97f0992ecb4a5.tar.gz
chromium_src-82c4d3b8fd037c0ee2c7b391a6f97f0992ecb4a5.tar.bz2
fix loop
fix remove rename fix yielding add another expected add expected rem another remove dcheck rewrite state machine rem unused rem startread loop read loop fix test use read fix test fix test fix another staet fix test rem bool initial write loop fix var bail out if closed rem dcheck fix onreadcomplete fix loop check state remove availability state clean up states remove unused states git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_session.h')
-rw-r--r--net/spdy/spdy_session.h82
1 files changed, 42 insertions, 40 deletions
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index ed81c6c..f2ab6de 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -50,9 +50,9 @@ const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8;
// Specifies the maxiumum concurrent streams server could send (via push).
const int kMaxConcurrentPushedStreams = 1000;
-// Specifies the number of bytes read synchronously (without yielding) if the
-// data is available.
-const int kMaxReadBytes = 32 * 1024;
+// Specifies the maximum number of bytes to read synchronously before
+// yielding.
+const int kMaxReadBytesWithoutYielding = 32 * 1024;
// The initial receive window size for both streams and sessions.
const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB
@@ -335,7 +335,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
uint32 delta_window_size);
// If session is closed, no new streams/transactions should be created.
- bool IsClosed() const { return state_ == STATE_CLOSED; }
+ bool IsClosed() const { return availability_state_ == STATE_CLOSED; }
// Closes this session. This will close all active streams and mark
// the session as permanently closed.
@@ -499,14 +499,30 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
typedef std::set<SpdyStream*> CreatedStreamSet;
- enum State {
- STATE_IDLE,
- STATE_CONNECTING,
- STATE_DO_READ,
- STATE_DO_READ_COMPLETE,
+ enum AvailabilityState {
+ // The session is available in its socket pool and can be used
+ // freely.
+ STATE_AVAILABLE,
+ // The session can process data on existing streams but will
+ // refuse to create new ones.
+ STATE_GOING_AWAY,
+ // The session has been closed, is waiting to be deleted, and will
+ // refuse to process any more data.
STATE_CLOSED
};
+ enum ReadState {
+ READ_STATE_DO_READ,
+ READ_STATE_DO_READ_COMPLETE,
+ };
+
+ enum WriteState {
+ // This state means the session's write queue is empty.
+ WRITE_STATE_IDLE,
+ WRITE_STATE_DO_WRITE,
+ WRITE_STATE_DO_WRITE_COMPLETE,
+ };
+
virtual ~SpdySession();
// Called by SpdyStreamRequest to start a request to create a
@@ -552,24 +568,17 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
SpdyRstStreamStatus status,
const std::string& description);
- // Start the DoLoop to read data from socket.
- void StartRead();
-
- // Try to make progress by reading and processing data.
- int DoLoop(int result);
- // The implementations of STATE_DO_READ/STATE_DO_READ_COMPLETE state changes
- // of the state machine.
+ // Advance the ReadState state machine.
+ int DoReadLoop(ReadState expected_read_state, int result);
+ // The implementations of the states of the ReadState state machine.
int DoRead();
- int DoReadComplete(int bytes_read);
-
- // Check if session is connected or not.
- bool IsConnected() const {
- return state_ == STATE_DO_READ || state_ == STATE_DO_READ_COMPLETE;
- }
+ int DoReadComplete(int result);
- // IO Callbacks
- void OnReadComplete(int result);
- void OnWriteComplete(int result);
+ // Advance the WriteState state machine.
+ int DoWriteLoop(WriteState expected_write_state, int result);
+ // The implementations of the states of the WriteState state machine.
+ int DoWrite();
+ int DoWriteComplete(int result);
// Send relevant SETTINGS. This is generally called on connection setup.
void SendInitialSettings();
@@ -605,10 +614,6 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// haven't received any data in |kHungInterval| time period.
void CheckPingStatus(base::TimeTicks last_check_time);
- // Write current data to the socket.
- void WriteSocketLater();
- void WriteSocket();
-
// Get a new stream id.
int GetNewStreamId();
@@ -872,8 +877,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
SpdyWriteQueue write_queue_;
// Data for the frame we are currently sending.
- // Whether we have a socket write pending completion.
- bool write_pending_;
+
// The buffer we're currently writing.
scoped_ptr<SpdyBuffer> in_flight_write_;
// The type of the frame in |in_flight_write_|.
@@ -884,9 +888,6 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// the socket completely.
base::WeakPtr<SpdyStream> in_flight_write_stream_;
- // Flag if we have a pending message scheduled for WriteSocket.
- bool delayed_write_pending_;
-
// Flag if we're using an SSL connection for this SpdySession.
bool is_secure_;
@@ -896,11 +897,16 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// Spdy Frame state.
scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_;
+ AvailabilityState availability_state_;
+
+ ReadState read_state_;
+
+ WriteState write_state_;
+
// If an error has occurred on the session, the session is effectively
// dead. Record this error here. When no error has occurred, |error_| will
// be OK.
- Error error_;
- State state_;
+ Error error_on_close_;
// Limits
size_t max_concurrent_streams_; // 0 if no limit
@@ -916,10 +922,6 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms.
int total_bytes_received_;
- // |bytes_read_| keeps track of number of bytes read continously in the
- // DoLoop() without yielding.
- int bytes_read_;
-
bool sent_settings_; // Did this session send settings when it started.
bool received_settings_; // Did this session receive at least one settings
// frame.