Reland 'Fix SPDY error-handling if the connection gets closed just after use.'

Include a fix for a test to appease ASan.

Original description:

> - Make SpdySession::IsReused() return true if the underlying socket was
> UNUSED_IDLE. This makes the HttpNetworkTransaction-level retry try a fresh
> socket in case a preconnected socket was stale.
>
> - If the SpdySession closes in an event loop iteration between
> HttpStreamFactoryImplJob::DoCreateStream and OnNewSpdySessionReadyCallback,
> propogate the error to the request to prevent it from hanging. Do so by
> creating the originating request's SpdyHttpStream as soon as the SpdySession
> is created so it can sample SpdySession::IsReused() and advise
> HttpNetworkTransaction on error.
>
> - Delay pumping the SpdySession read loop by an event loop iteration. This
> simplifies some logic and ensures that HttpNetworkTransaction receives a
> SpdyHttpStream to advise retry logic. This does mean we lose the error code;
> it now follows the asynchronous case and turns into ERR_CONNECTION_CLOSED in
> SpdyHttpStream::InitializeStream.
>
> BUG=352156
>
> Review URL: https://codereview.chromium.org/200723004

BUG=352156

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259208 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc
index 5a58703..2142d58 100644
--- a/net/spdy/spdy_http_stream_unittest.cc
+++ b/net/spdy/spdy_http_stream_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/memory/scoped_ptr.h"
 #include "base/message_loop/message_loop_proxy.h"
+#include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "crypto/ec_private_key.h"
 #include "crypto/ec_signature_creator.h"
@@ -149,6 +150,9 @@
   UploadProgress progress = stream.GetUploadProgress();
   EXPECT_EQ(0u, progress.size());
   EXPECT_EQ(0u, progress.position());
+
+  // Pump the event loop so |reads| is consumed before the function returns.
+  base::RunLoop().RunUntilIdle();
 }
 
 TEST_P(SpdyHttpStreamTest, SendRequest) {