[SPDY] Refactor SpdySession state machine (take 2)

Represent a SpdySession's state by three variables of type:
AvailabilityState, ReadState (the old State type), and WriteState.

Make some important functions, including the BufferedSpdyWriter
callbacks, do nothing if availability_state_ == STATE_CLOSED.

Rename the current state machine from DoLoop etc. to DoReadLoop.
Refactor the write state machine to be parallel to the read state machine.

Keep track of the number of bytes read without yielding in DoReadLoop
itself. This fixes a slight bug where the counter isn't reset if the loop
yields due to ERR_IO_PENDING being returned.

The new write state machine (DoWriteLoop, etc.) has almost the same
behavior as the old one, except if a write completes asynchronously
the write loop is immediately re-entered instead of via a posted task.

Fix tests to match new write loop behavior.

Use time_func_ consistently.

Add regression test for http://crbug.com/261043 .

BUG=255701,261043
[email protected], [email protected]

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=211852

Review URL: https://codereview.chromium.org/18143005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212242 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed