Make HttpStreamFactoryImpl::Job claim pushed streams.

Motivation:

Suppose the server pushes a stream and then cancels it.  Consider the
following three events:
(A) HttpStreamFactoryImpl::Job calls Http2PushPromiseIndex::Find() to
    look for the SpdySession that has an unclaimed pushed stream for the
    request URL.
(B) SpdyHttpStream calls GetPushStream() on that SpdySession instance.
(C) SpdySession deletes the pushed stream when it receives the
    RST_STREAM frame from the server, before the response is pushed.

(B) always happens after (A), and it involves a PostTask (see bug for
details).  If (C) happens after (B), then the request fails with a
user-visible error (that upper layers like HttpNetworkTransaction might
intercept and do a retry).

If (C) happens after (A) but before (B), then currently, the request is
sent out on the SpdySession which might not be used if there was not a
pushed stream on it.  That is, the server is allowed to hijack the
request, and see the request headers, by pushing a stream and then
closing it at the right time.  After this CL, the request will fail in
this case as well, with a new error code.

Details:

Rename Http2PushPromiseIndex::FindSession() to ClaimPushedStream() and
make it unregister the pushed stream if found.  Record pushed stream ID
in HttpStreamFactoryImpl::Job, pass it on to SpdyHttpStream, then back
to SpdySession::GetPushStream().  Fail request with new error code
ERR_SPDY_PUSHED_STREAM_NOT_AVAILABLE if pushed stream was cancelled in
the meanwhile.

Add new SpdySessionTest for modified GetPushStream() behavior.

Add SpdyNetworkTransactionTest to cover the case that the server cancels
the pushed stream after it is claimed but before SpdyHttpStream calls
SpdySession->GetPushStream().

Bug: 776415
Change-Id: I14150b933b09ee5c96722aa0fb2392afbcbb65b1
Reviewed-on: https://chromium-review.googlesource.com/829993
Reviewed-by: Helen Li <xunjieli@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526717}
15 files changed