Commit 762844b4 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Misc cleanup.

Random small stuff I came across while working on push validation.

Bug: 554220
Change-Id: I58d43860b2f347b5df2833868ad8f906513e8f40
Reviewed-on: https://chromium-review.googlesource.com/728361Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510253}
parent 9017bc0a
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "net/socket/ssl_client_socket_pool.h" #include "net/socket/ssl_client_socket_pool.h"
#include "net/socket/stream_socket.h" #include "net/socket/stream_socket.h"
#include "net/spdy/chromium/bidirectional_stream_spdy_impl.h" #include "net/spdy/chromium/bidirectional_stream_spdy_impl.h"
#include "net/spdy/chromium/http2_push_promise_index.h"
#include "net/spdy/chromium/spdy_http_stream.h" #include "net/spdy/chromium/spdy_http_stream.h"
#include "net/spdy/chromium/spdy_session.h" #include "net/spdy/chromium/spdy_session.h"
#include "net/spdy/chromium/spdy_session_pool.h" #include "net/spdy/chromium/spdy_session_pool.h"
...@@ -925,21 +926,21 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { ...@@ -925,21 +926,21 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() {
// connection this request can pool to. If so, then go straight to using // connection this request can pool to. If so, then go straight to using
// that. // that.
if (CanUseExistingSpdySession()) { if (CanUseExistingSpdySession()) {
base::WeakPtr<SpdySession> spdy_session = existing_spdy_session_ =
session_->spdy_session_pool()->push_promise_index()->Find( session_->spdy_session_pool()->push_promise_index()->Find(
spdy_session_key_, origin_url_); spdy_session_key_, origin_url_);
if (!spdy_session) { if (!existing_spdy_session_) {
spdy_session = session_->spdy_session_pool()->FindAvailableSession( existing_spdy_session_ =
spdy_session_key_, enable_ip_based_pooling_, net_log_); session_->spdy_session_pool()->FindAvailableSession(
spdy_session_key_, enable_ip_based_pooling_, net_log_);
} }
if (spdy_session) { if (existing_spdy_session_) {
// If we're preconnecting, but we already have a SpdySession, we don't // If we're preconnecting, but we already have a SpdySession, we don't
// actually need to preconnect any sockets, so we're done. // actually need to preconnect any sockets, so we're done.
if (job_type_ == PRECONNECT) if (job_type_ == PRECONNECT)
return OK; return OK;
using_spdy_ = true; using_spdy_ = true;
next_state_ = STATE_CREATE_STREAM; next_state_ = STATE_CREATE_STREAM;
existing_spdy_session_ = spdy_session;
return OK; return OK;
} }
} }
...@@ -1200,15 +1201,15 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() { ...@@ -1200,15 +1201,15 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() {
existing_spdy_session_ = existing_spdy_session_ =
session_->spdy_session_pool()->push_promise_index()->Find( session_->spdy_session_pool()->push_promise_index()->Find(
spdy_session_key_, origin_url_); spdy_session_key_, origin_url_);
// It is also possible that an HTTP/2 connection has been established since
// last time Job checked above.
if (!existing_spdy_session_) {
existing_spdy_session_ =
session_->spdy_session_pool()->FindAvailableSession(
spdy_session_key_, enable_ip_based_pooling_, net_log_);
}
} }
// It is also possible that an HTTP/2 connection has been established since if (existing_spdy_session_) {
// last time Job checked above.
if (!existing_spdy_session_) {
existing_spdy_session_ =
session_->spdy_session_pool()->FindAvailableSession(
spdy_session_key_, enable_ip_based_pooling_, net_log_);
}
if (existing_spdy_session_.get()) {
// We picked up an existing session, so we don't need our socket. // We picked up an existing session, so we don't need our socket.
if (connection_->socket()) if (connection_->socket())
connection_->socket()->Disconnect(); connection_->socket()->Disconnect();
......
...@@ -75,6 +75,8 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info, ...@@ -75,6 +75,8 @@ int SpdyHttpStream::InitializeStream(const HttpRequestInfo* request_info,
return ERR_CONNECTION_CLOSED; return ERR_CONNECTION_CLOSED;
request_info_ = request_info; request_info_ = request_info;
// TODO(bnc): Remove this condition once pushed headers are properly
// validated. https://crbug.com/554220.
if (request_info_->method == "GET") { if (request_info_->method == "GET") {
int error = spdy_session_->GetPushStream(request_info_->url, priority, int error = spdy_session_->GetPushStream(request_info_->url, priority,
&stream_, stream_net_log); &stream_, stream_net_log);
......
...@@ -288,6 +288,8 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface, ...@@ -288,6 +288,8 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// already started to be pushed by the server, but do not have // already started to be pushed by the server, but do not have
// consumers yet. Contains a subset of |active_streams_|. // consumers yet. Contains a subset of |active_streams_|.
PushedStreamMap streams_; PushedStreamMap streams_;
DISALLOW_COPY_AND_ASSIGN(UnclaimedPushedStreamContainer);
}; };
// Returns true if |new_hostname| can be pooled into an existing connection to // Returns true if |new_hostname| can be pooled into an existing connection to
...@@ -573,14 +575,12 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface, ...@@ -573,14 +575,12 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// Allow tests to access our innards for testing purposes. // Allow tests to access our innards for testing purposes.
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, MetricsCollectionOnPushStreams); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, MetricsCollectionOnPushStreams);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushBeforeClaimed); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushBeforeClaimed);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterSessionGoesAway); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterSessionGoesAway);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterExpired); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterExpired);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize);
FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream); FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment