Remove HttpStreamRequest interface.
Remove HttpStreamRequest interface, and rename
HttpStreamFactoryImpl::Request to HttpStreamRequest.
Bug: 829429
Change-Id: Iaff3b5e5ee73d85185914b6713d68243acb98a54
Reviewed-on: https://chromium-review.googlesource.com/998541
Reviewed-by: Varun Khaneja <[email protected]>
Reviewed-by: David Vallet <[email protected]>
Reviewed-by: Ryan Hamilton <[email protected]>
Commit-Queue: Bence Béky <[email protected]>
Cr-Commit-Position: refs/heads/master@{#549848}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a55ac54d..09c7dc9 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -234,6 +234,7 @@
#include "media/media_buildflags.h"
#include "media/mojo/buildflags.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
+#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_options.h"
diff --git a/chrome/browser/safe_browsing/download_protection/check_client_download_request.cc b/chrome/browser/safe_browsing/download_protection/check_client_download_request.cc
index d142a71..49cef0d 100644
--- a/chrome/browser/safe_browsing/download_protection/check_client_download_request.cc
+++ b/chrome/browser/safe_browsing/download_protection/check_client_download_request.cc
@@ -26,6 +26,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/common/service_manager_connection.h"
+#include "net/base/load_flags.h"
#include "net/http/http_cache.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
diff --git a/chrome/browser/safe_browsing/download_protection/ppapi_download_request.cc b/chrome/browser/safe_browsing/download_protection/ppapi_download_request.cc
index dab8f8b..fc3696b 100644
--- a/chrome/browser/safe_browsing/download_protection/ppapi_download_request.cc
+++ b/chrome/browser/safe_browsing/download_protection/ppapi_download_request.cc
@@ -17,6 +17,7 @@
#include "content/public/browser/web_contents.h"
#include "google_apis/google_api_keys.h"
#include "net/base/escape.h"
+#include "net/base/load_flags.h"
#include "net/http/http_cache.h"
#include "net/http/http_status_code.h"
#include "net/url_request/url_fetcher.h"
diff --git a/headless/public/util/generic_url_request_job.cc b/headless/public/util/generic_url_request_job.cc
index f13e8f6..11063427 100644
--- a/headless/public/util/generic_url_request_job.cc
+++ b/headless/public/util/generic_url_request_job.cc
@@ -17,6 +17,7 @@
#include "headless/public/headless_browser_context.h"
#include "headless/public/util/url_request_dispatcher.h"
#include "net/base/io_buffer.h"
+#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/upload_bytes_element_reader.h"
diff --git a/net/BUILD.gn b/net/BUILD.gn
index 2d8ffe8b..24946a35 100644
--- a/net/BUILD.gn
+++ b/net/BUILD.gn
@@ -870,10 +870,10 @@
"http/http_stream_factory_impl_job.h",
"http/http_stream_factory_impl_job_controller.cc",
"http/http_stream_factory_impl_job_controller.h",
- "http/http_stream_factory_impl_request.cc",
- "http/http_stream_factory_impl_request.h",
"http/http_stream_parser.cc",
"http/http_stream_parser.h",
+ "http/http_stream_request.cc",
+ "http/http_stream_request.h",
"http/http_transaction.h",
"http/http_transaction_factory.h",
"http/http_version.h",
@@ -4905,9 +4905,9 @@
"http/http_server_properties_manager_unittest.cc",
"http/http_status_code_unittest.cc",
"http/http_stream_factory_impl_job_controller_unittest.cc",
- "http/http_stream_factory_impl_request_unittest.cc",
"http/http_stream_factory_impl_unittest.cc",
"http/http_stream_parser_unittest.cc",
+ "http/http_stream_request_unittest.cc",
"http/http_util_unittest.cc",
"http/http_vary_data_unittest.cc",
"http/mock_allow_http_auth_preferences.cc",
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc
index dade773..ce1efa4 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -34,6 +34,7 @@
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
+#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/dns/dns_protocol.h"
diff --git a/net/http/bidirectional_stream.h b/net/http/bidirectional_stream.h
index 854bb29..69f26186 100644
--- a/net/http/bidirectional_stream.h
+++ b/net/http/bidirectional_stream.h
@@ -19,6 +19,7 @@
#include "net/base/net_export.h"
#include "net/http/bidirectional_stream_impl.h"
#include "net/http/http_stream_factory.h"
+#include "net/http/http_stream_request.h"
#include "net/log/net_log_with_source.h"
namespace net {
@@ -26,7 +27,6 @@
class HttpAuthController;
class HttpNetworkSession;
class HttpStream;
-class HttpStreamRequest;
class IOBuffer;
class ProxyInfo;
class SpdyHeaderBlock;
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h
index a2306c1..9f3e95e 100644
--- a/net/http/http_network_transaction.h
+++ b/net/http/http_network_transaction.h
@@ -22,6 +22,7 @@
#include "net/http/http_request_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_stream_factory.h"
+#include "net/http/http_stream_request.h"
#include "net/http/http_transaction.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
@@ -40,7 +41,6 @@
class HttpAuthController;
class HttpNetworkSession;
class HttpStream;
-class HttpStreamRequest;
class IOBuffer;
class ProxyInfo;
class SSLPrivateKey;
diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h
index 7b0795027..a70896c 100644
--- a/net/http/http_stream_factory.h
+++ b/net/http/http_stream_factory.h
@@ -16,8 +16,11 @@
#include "net/base/load_states.h"
#include "net/base/net_export.h"
#include "net/base/request_priority.h"
+#include "net/http/http_request_info.h"
#include "net/http/http_server_properties.h"
-#include "net/socket/connection_attempts.h"
+#include "net/http/http_stream_request.h"
+#include "net/log/net_log_with_source.h"
+#include "net/ssl/ssl_config.h"
// This file can be included from net/http even though
// it is in net/websockets because it doesn't
// introduce any link dependency to net/websockets.
@@ -31,169 +34,9 @@
namespace net {
-class BidirectionalStreamImpl;
class HostMappingRules;
-class HttpAuthController;
class HttpNetworkSession;
class HttpResponseHeaders;
-class HttpResponseInfo;
-class HttpStream;
-class NetLogWithSource;
-class ProxyInfo;
-class SSLCertRequestInfo;
-class SSLInfo;
-struct HttpRequestInfo;
-struct SSLConfig;
-
-// The HttpStreamRequest is the client's handle to the worker object which
-// handles the creation of an HttpStream. While the HttpStream is being
-// created, this object is the creator's handle for interacting with the
-// HttpStream creation process. The request is cancelled by deleting it, after
-// which no callbacks will be invoked.
-class NET_EXPORT_PRIVATE HttpStreamRequest {
- public:
- // Indicates which type of stream is requested.
- enum StreamType {
- BIDIRECTIONAL_STREAM,
- HTTP_STREAM,
- };
-
- // The HttpStreamRequest::Delegate is a set of callback methods for a
- // HttpStreamRequestJob. Generally, only one of these methods will be
- // called as a result of a stream request.
- class NET_EXPORT_PRIVATE Delegate {
- public:
- virtual ~Delegate() {}
-
- // This is the success case for RequestStream.
- // |stream| is now owned by the delegate.
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
- // since the HttpStreamRequest performs the proxy resolution.
- virtual void OnStreamReady(const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<HttpStream> stream) = 0;
-
- // This is the success case for RequestWebSocketHandshakeStream.
- // |stream| is now owned by the delegate.
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
- // since the HttpStreamRequest performs the proxy resolution.
- virtual void OnWebSocketHandshakeStreamReady(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<WebSocketHandshakeStreamBase> stream) = 0;
-
- virtual void OnBidirectionalStreamImplReady(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<BidirectionalStreamImpl> stream) = 0;
-
- // This is the failure to create a stream case.
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- virtual void OnStreamFailed(int status,
- const NetErrorDetails& net_error_details,
- const SSLConfig& used_ssl_config) = 0;
-
- // Called when we have a certificate error for the request.
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- virtual void OnCertificateError(int status,
- const SSLConfig& used_ssl_config,
- const SSLInfo& ssl_info) = 0;
-
- // This is the failure case where we need proxy authentication during
- // proxy tunnel establishment. For the tunnel case, we were unable to
- // create the HttpStream, so the caller provides the auth and then resumes
- // the HttpStreamRequest.
- //
- // For the non-tunnel case, the caller will discover the authentication
- // failure when reading response headers. At that point, it will handle the
- // authentication failure and restart the HttpStreamRequest entirely.
- //
- // Ownership of |auth_controller| and |proxy_response| are owned
- // by the HttpStreamRequest. |proxy_response| is not guaranteed to be usable
- // after the lifetime of this callback. The delegate may take a reference
- // to |auth_controller| if it is needed beyond the lifetime of this
- // callback.
- //
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- HttpAuthController* auth_controller) = 0;
-
- // This is the failure for SSL Client Auth
- // Ownership of |cert_info| is retained by the HttpStreamRequest. The
- // delegate may take a reference if it needs the cert_info beyond the
- // lifetime of this callback.
- virtual void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
- SSLCertRequestInfo* cert_info) = 0;
-
- // This is the failure of the CONNECT request through an HTTPS proxy.
- // Headers can be read from |response_info|, while the body can be read
- // from |stream|.
- //
- // |used_ssl_config| indicates the actual SSL configuration used for this
- // stream, since the HttpStreamRequest may have modified the configuration
- // during stream processing.
- //
- // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
- // since the HttpStreamRequest performs the proxy resolution.
- //
- // Ownership of |stream| is transferred to the delegate.
- virtual void OnHttpsProxyTunnelResponse(
- const HttpResponseInfo& response_info,
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<HttpStream> stream) = 0;
-
- // Called when finding all QUIC alternative services are marked broken for
- // the origin in this request which advertises supporting QUIC.
- virtual void OnQuicBroken() = 0;
- };
-
- virtual ~HttpStreamRequest() {}
-
- // When a HttpStream creation process is stalled due to necessity
- // of Proxy authentication credentials, the delegate OnNeedsProxyAuth
- // will have been called. It now becomes the delegate's responsibility
- // to collect the necessary credentials, and then call this method to
- // resume the HttpStream creation process.
- virtual int RestartTunnelWithProxyAuth() = 0;
-
- // Called when the priority of the parent transaction changes.
- virtual void SetPriority(RequestPriority priority) = 0;
-
- // Returns the LoadState for the request.
- virtual LoadState GetLoadState() const = 0;
-
- // Returns true if TLS/ALPN was negotiated for this stream.
- virtual bool was_alpn_negotiated() const = 0;
-
- // Protocol negotiated with the server.
- virtual NextProto negotiated_protocol() const = 0;
-
- // Returns true if this stream is being fetched over SPDY.
- virtual bool using_spdy() const = 0;
-
- // Returns socket-layer connection attempts made for this stream request.
- virtual const ConnectionAttempts& connection_attempts() const = 0;
-
- // Returns the WebSocketHandshakeStreamBase::CreateHelper for this stream
- // request.
- virtual WebSocketHandshakeStreamBase::CreateHelper*
- websocket_handshake_stream_create_helper() const = 0;
-};
// The HttpStreamFactory defines an interface for creating usable HttpStreams.
class NET_EXPORT HttpStreamFactory {
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc
index 05dc57b..3a4c197b 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -19,7 +19,6 @@
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory_impl_job.h"
#include "net/http/http_stream_factory_impl_job_controller.h"
-#include "net/http/http_stream_factory_impl_request.h"
#include "net/http/transport_security_state.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/quic/core/quic_server_id.h"
diff --git a/net/http/http_stream_factory_impl.h b/net/http/http_stream_factory_impl.h
index d34696ba..aa8c5d15 100644
--- a/net/http/http_stream_factory_impl.h
+++ b/net/http/http_stream_factory_impl.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <set>
+#include <string>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
@@ -20,6 +21,7 @@
#include "net/base/proxy_server.h"
#include "net/base/request_priority.h"
#include "net/http/http_stream_factory.h"
+#include "net/http/http_stream_request.h"
#include "net/log/net_log_source.h"
#include "net/socket/ssl_client_socket.h"
#include "net/spdy/chromium/spdy_session_key.h"
@@ -35,7 +37,6 @@
class NET_EXPORT_PRIVATE Job;
class NET_EXPORT_PRIVATE JobController;
class NET_EXPORT_PRIVATE JobFactory;
- class NET_EXPORT_PRIVATE Request;
HttpStreamFactoryImpl(HttpNetworkSession* session);
~HttpStreamFactoryImpl() override;
@@ -83,8 +84,7 @@
};
private:
- FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority);
- FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob);
+ FRIEND_TEST_ALL_PREFIXES(HttpStreamRequestTest, SetPriority);
friend class HttpStreamFactoryImplPeer;
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 3b419e9..a8357f0 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -34,7 +34,6 @@
#include "net/http/http_request_info.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory.h"
-#include "net/http/http_stream_factory_impl_request.h"
#include "net/http/proxy_fallback.h"
#include "net/log/net_log.h"
#include "net/log/net_log_capture_mode.h"
diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h
index 6ac0c616..3dd4f48 100644
--- a/net/http/http_stream_factory_impl_job.h
+++ b/net/http/http_stream_factory_impl_job.h
@@ -21,6 +21,7 @@
#include "net/http/http_auth_controller.h"
#include "net/http/http_request_info.h"
#include "net/http/http_stream_factory_impl.h"
+#include "net/http/http_stream_request.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/quic/chromium/quic_stream_factory.h"
@@ -47,8 +48,8 @@
class NetLog;
struct SSLConfig;
-// An HttpStreamRequestImpl exists for each stream which is in progress of being
-// created for the StreamFactory.
+// An HttpStreamRequest exists for each stream which is in progress of being
+// created for the HttpStreamFactory.
class HttpStreamFactoryImpl::Job {
public:
// For jobs issued simultaneously to an HTTP/2 supported server, a delay is
@@ -56,7 +57,7 @@
// crbug.com/718576
static const int kHTTP2ThrottleMs = 300;
- // Delegate to report Job's status to Request and HttpStreamFactory.
+ // Delegate to report Job's status to HttpStreamRequest and HttpStreamFactory.
class NET_EXPORT_PRIVATE Delegate {
public:
virtual ~Delegate() {}
@@ -82,7 +83,7 @@
int status,
const SSLConfig& used_ssl_config) = 0;
- // Invoked when |job| has a certificate error for the Request.
+ // Invoked when |job| has a certificate error for the HttpStreamRequest.
virtual void OnCertificateError(Job* job,
int status,
const SSLConfig& used_ssl_config,
@@ -113,8 +114,8 @@
// contained in |proxy_info| can be skipped.
virtual bool OnInitConnection(const ProxyInfo& proxy_info) = 0;
- // Invoked to notify the Request and Factory of the readiness of new
- // SPDY session.
+ // Invoked to notify the HttpStreamRequest and HttpStreamFactory of the
+ // readiness of new SPDY session.
virtual void OnNewSpdySessionReady(
Job* job,
const base::WeakPtr<SpdySession>& spdy_session) = 0;
@@ -123,7 +124,7 @@
virtual void OnPreconnectsComplete(Job* job) = 0;
// Invoked to record connection attempts made by the socket layer to
- // Request if |job| is associated with Request.
+ // HttpStreamRequest if |job| is associated with HttpStreamRequest.
virtual void AddConnectionAttemptsToRequest(
Job* job,
const ConnectionAttempts& attempts) = 0;
@@ -136,9 +137,9 @@
virtual bool ShouldWait(Job* job) = 0;
// Called when |job| determines the appropriate |spdy_session_key| for the
- // Request. Note that this does not mean that SPDY is necessarily supported
- // for this SpdySessionKey, since we may need to wait for NPN to complete
- // before knowing if SPDY is available.
+ // HttpStreamRequest. Note that this does not mean that HTTP/2 is
+ // necessarily supported for this SpdySessionKey, since we may need to wait
+ // for ALPN negotiation to complete before knowing if HTTP/2 is available.
virtual void SetSpdySessionKey(Job* job,
const SpdySessionKey& spdy_session_key) = 0;
diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc
index e05b3ee..33f6e0a 100644
--- a/net/http/http_stream_factory_impl_job_controller.cc
+++ b/net/http/http_stream_factory_impl_job_controller.cc
@@ -114,8 +114,7 @@
net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER);
}
-std::unique_ptr<HttpStreamFactoryImpl::Request>
-HttpStreamFactoryImpl::JobController::Start(
+std::unique_ptr<HttpStreamRequest> HttpStreamFactoryImpl::JobController::Start(
HttpStreamRequest::Delegate* delegate,
WebSocketHandshakeStreamBase::CreateHelper*
websocket_handshake_stream_create_helper,
@@ -128,10 +127,10 @@
stream_type_ = stream_type;
priority_ = priority;
- auto request = std::make_unique<Request>(
+ auto request = std::make_unique<HttpStreamRequest>(
request_info_.url, this, delegate,
websocket_handshake_stream_create_helper, source_net_log, stream_type);
- // Keep a raw pointer but release ownership of Request instance.
+ // Keep a raw pointer but release ownership of HttpStreamRequest instance.
request_ = request.get();
// Associates |net_log_| with |source_net_log|.
@@ -244,7 +243,8 @@
factory_->OnStreamReady(job->proxy_info(), request_info_.privacy_mode);
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -271,7 +271,8 @@
DCHECK(job);
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -330,7 +331,8 @@
MaybeResumeMainJob(job, base::TimeDelta());
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -375,7 +377,8 @@
MaybeResumeMainJob(job, base::TimeDelta());
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -398,7 +401,8 @@
MaybeResumeMainJob(job, base::TimeDelta());
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -418,7 +422,8 @@
MaybeResumeMainJob(job, base::TimeDelta());
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
@@ -439,7 +444,8 @@
MaybeResumeMainJob(job, base::TimeDelta());
if (IsJobOrphaned(job)) {
- // We have bound a job to the associated Request, |job| has been orphaned.
+ // We have bound a job to the associated HttpStreamRequest, |job| has been
+ // orphaned.
OnOrphanedJobComplete(job);
return;
}
diff --git a/net/http/http_stream_factory_impl_job_controller.h b/net/http/http_stream_factory_impl_job_controller.h
index 0026ec5..d378d23 100644
--- a/net/http/http_stream_factory_impl_job_controller.h
+++ b/net/http/http_stream_factory_impl_job_controller.h
@@ -6,12 +6,13 @@
#define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_
#include <memory>
+#include <string>
#include "base/cancelable_callback.h"
#include "net/base/host_port_pair.h"
#include "net/base/privacy_mode.h"
#include "net/http/http_stream_factory_impl_job.h"
-#include "net/http/http_stream_factory_impl_request.h"
+#include "net/http/http_stream_request.h"
#include "net/socket/next_proto.h"
namespace net {
@@ -27,7 +28,7 @@
// HttpStreamFactoryImpl::JobController manages Request and Job(s).
class HttpStreamFactoryImpl::JobController
: public HttpStreamFactoryImpl::Job::Delegate,
- public HttpStreamFactoryImpl::Request::Helper {
+ public HttpStreamRequest::Helper {
public:
JobController(HttpStreamFactoryImpl* factory,
HttpStreamRequest::Delegate* delegate,
@@ -52,16 +53,17 @@
// Methods below are called by HttpStreamFactoryImpl only.
// Creates request and hands out to HttpStreamFactoryImpl, this will also
// create Job(s) and start serving the created request.
- std::unique_ptr<Request> Start(HttpStreamRequest::Delegate* delegate,
- WebSocketHandshakeStreamBase::CreateHelper*
- websocket_handshake_stream_create_helper,
- const NetLogWithSource& source_net_log,
- HttpStreamRequest::StreamType stream_type,
- RequestPriority priority);
+ std::unique_ptr<HttpStreamRequest> Start(
+ HttpStreamRequest::Delegate* delegate,
+ WebSocketHandshakeStreamBase::CreateHelper*
+ websocket_handshake_stream_create_helper,
+ const NetLogWithSource& source_net_log,
+ HttpStreamRequest::StreamType stream_type,
+ RequestPriority priority);
void Preconnect(int num_streams);
- // From HttpStreamFactoryImpl::Request::Helper.
+ // From HttpStreamRequest::Helper.
// Returns the LoadState for Request.
LoadState GetLoadState() const override;
@@ -319,7 +321,7 @@
// reference and is safe as |request_| will notify |this| JobController
// when it's destructed by calling OnRequestComplete(), which nulls
// |request_|.
- Request* request_;
+ HttpStreamRequest* request_;
HttpStreamRequest::Delegate* const delegate_;
diff --git a/net/http/http_stream_factory_impl_job_controller_unittest.cc b/net/http/http_stream_factory_impl_job_controller_unittest.cc
index ba5644a..9b1d02f 100644
--- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
+++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
@@ -25,7 +25,6 @@
#include "net/http/http_network_session_peer.h"
#include "net/http/http_stream_factory_impl.h"
#include "net/http/http_stream_factory_impl_job.h"
-#include "net/http/http_stream_factory_impl_request.h"
#include "net/http/http_stream_factory_test_util.h"
#include "net/log/net_log_with_source.h"
#include "net/log/test_net_log.h"
@@ -312,7 +311,7 @@
std::unique_ptr<HttpNetworkSession> session_;
HttpStreamFactoryImpl* factory_ = nullptr;
HttpStreamFactoryImpl::JobController* job_controller_ = nullptr;
- std::unique_ptr<HttpStreamFactoryImpl::Request> request_;
+ std::unique_ptr<HttpStreamRequest> request_;
std::unique_ptr<SequencedSocketData> tcp_data_;
std::unique_ptr<MockQuicData> quic_data_;
MockCryptoClientStreamFactory crypto_client_stream_factory_;
diff --git a/net/http/http_stream_factory_impl_request.h b/net/http/http_stream_factory_impl_request.h
deleted file mode 100644
index f5e7363..0000000
--- a/net/http/http_stream_factory_impl_request.h
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
-#define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
-
-#include <memory>
-#include <set>
-
-#include "base/macros.h"
-#include "base/optional.h"
-#include "net/base/net_export.h"
-#include "net/http/http_stream_factory_impl.h"
-#include "net/log/net_log_with_source.h"
-#include "net/socket/connection_attempts.h"
-#include "net/socket/ssl_client_socket.h"
-#include "net/spdy/chromium/spdy_session_key.h"
-#include "url/gurl.h"
-
-namespace net {
-
-class BidirectionalStreamImpl;
-class HttpStream;
-
-class HttpStreamFactoryImpl::Request : public HttpStreamRequest {
- public:
- class NET_EXPORT_PRIVATE Helper {
- public:
- virtual ~Helper() {}
-
- // Returns the LoadState for Request.
- virtual LoadState GetLoadState() const = 0;
-
- // Called when Request is destructed.
- virtual void OnRequestComplete() = 0;
-
- // Called to resume the HttpStream creation process when necessary
- // Proxy authentication credentials are collected.
- virtual int RestartTunnelWithProxyAuth() = 0;
-
- // Called when the priority of transaction changes.
- virtual void SetPriority(RequestPriority priority) = 0;
-
- // Called when SpdySessionPool notifies the Request
- // that it can be served on a SpdySession created by another Request,
- // therefore the Jobs can be destroyed.
- virtual void OnStreamReadyOnPooledConnection(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& proxy_info,
- std::unique_ptr<HttpStream> stream) = 0;
- virtual void OnBidirectionalStreamImplReadyOnPooledConnection(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<BidirectionalStreamImpl> stream) = 0;
- };
-
- // Request will notify |job_controller| when it's destructed.
- // Thus |job_controller| is valid for the lifetime of the |this| Request.
- Request(const GURL& url,
- Helper* helper,
- HttpStreamRequest::Delegate* delegate,
- WebSocketHandshakeStreamBase::CreateHelper*
- websocket_handshake_stream_create_helper,
- const NetLogWithSource& net_log,
- StreamType stream_type);
-
- ~Request() override;
-
- // The GURL from the HttpRequestInfo the started the Request.
- const GURL& url() const { return url_; }
-
- const NetLogWithSource& net_log() const { return net_log_; }
-
- // Called when the |helper_| determines the appropriate |spdy_session_key|
- // for the Request. Note that this does not mean that SPDY is necessarily
- // supported for this SpdySessionKey, since we may need to wait for NPN to
- // complete before knowing if SPDY is available.
- void SetSpdySessionKey(const SpdySessionKey& spdy_session_key) {
- spdy_session_key_ = spdy_session_key;
- }
- bool HasSpdySessionKey() const { return spdy_session_key_.has_value(); }
- const SpdySessionKey& GetSpdySessionKey() const {
- DCHECK(HasSpdySessionKey());
- return spdy_session_key_.value();
- }
- void ResetSpdySessionKey() { spdy_session_key_.reset(); }
-
- HttpStreamRequest::StreamType stream_type() const { return stream_type_; }
-
- // Marks completion of the request. Must be called before OnStreamReady().
- void Complete(bool was_alpn_negotiated,
- NextProto negotiated_protocol,
- bool using_spdy);
-
- // Called by |helper_| to record connection attempts made by the socket
- // layer in an attached Job for this stream request.
- void AddConnectionAttempts(const ConnectionAttempts& attempts);
-
- WebSocketHandshakeStreamBase::CreateHelper*
- websocket_handshake_stream_create_helper() const override;
-
- void OnStreamReadyOnPooledConnection(const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<HttpStream> stream);
- void OnBidirectionalStreamImplReadyOnPooledConnection(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<BidirectionalStreamImpl> stream);
-
- // HttpStreamRequest methods.
- int RestartTunnelWithProxyAuth() override;
- void SetPriority(RequestPriority priority) override;
- LoadState GetLoadState() const override;
- bool was_alpn_negotiated() const override;
- NextProto negotiated_protocol() const override;
- bool using_spdy() const override;
- const ConnectionAttempts& connection_attempts() const override;
-
- bool completed() const { return completed_; }
-
- private:
- const GURL url_;
-
- // Unowned. The helper must outlive this request.
- Helper* helper_;
-
- WebSocketHandshakeStreamBase::CreateHelper* const
- websocket_handshake_stream_create_helper_;
- const NetLogWithSource net_log_;
-
- base::Optional<SpdySessionKey> spdy_session_key_;
-
- bool completed_;
- bool was_alpn_negotiated_;
- // Protocol negotiated with the server.
- NextProto negotiated_protocol_;
- bool using_spdy_;
- ConnectionAttempts connection_attempts_;
-
- const HttpStreamRequest::StreamType stream_type_;
- DISALLOW_COPY_AND_ASSIGN(Request);
-};
-
-} // namespace net
-
-#endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_REQUEST_H_
diff --git a/net/http/http_stream_factory_test_util.h b/net/http/http_stream_factory_test_util.h
index 91b2e09..d2c2fd5 100644
--- a/net/http/http_stream_factory_test_util.h
+++ b/net/http/http_stream_factory_test_util.h
@@ -14,6 +14,7 @@
#include "net/http/http_stream_factory_impl.h"
#include "net/http/http_stream_factory_impl_job.h"
#include "net/http/http_stream_factory_impl_job_controller.h"
+#include "net/http/http_stream_request.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/socket/next_proto.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_request.cc
similarity index 63%
rename from net/http/http_stream_factory_impl_request.cc
rename to net/http/http_stream_request.cc
index 35d8767..deb3902 100644
--- a/net/http/http_stream_factory_impl_request.cc
+++ b/net/http/http_stream_request.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/http/http_stream_factory_impl_request.h"
+#include "net/http/http_stream_request.h"
#include <utility>
@@ -10,14 +10,13 @@
#include "base/logging.h"
#include "base/stl_util.h"
#include "net/http/bidirectional_stream_impl.h"
-#include "net/http/http_stream_factory_impl_job.h"
#include "net/log/net_log_event_type.h"
#include "net/spdy/chromium/spdy_http_stream.h"
#include "net/spdy/chromium/spdy_session.h"
namespace net {
-HttpStreamFactoryImpl::Request::Request(
+HttpStreamRequest::HttpStreamRequest(
const GURL& url,
Helper* helper,
HttpStreamRequest::Delegate* delegate,
@@ -38,14 +37,14 @@
net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_REQUEST);
}
-HttpStreamFactoryImpl::Request::~Request() {
+HttpStreamRequest::~HttpStreamRequest() {
net_log_.EndEvent(NetLogEventType::HTTP_STREAM_REQUEST);
helper_->OnRequestComplete();
}
-void HttpStreamFactoryImpl::Request::Complete(bool was_alpn_negotiated,
- NextProto negotiated_protocol,
- bool using_spdy) {
+void HttpStreamRequest::Complete(bool was_alpn_negotiated,
+ NextProto negotiated_protocol,
+ bool using_spdy) {
DCHECK(!completed_);
completed_ = true;
was_alpn_negotiated_ = was_alpn_negotiated;
@@ -53,7 +52,7 @@
using_spdy_ = using_spdy;
}
-void HttpStreamFactoryImpl::Request::OnStreamReadyOnPooledConnection(
+void HttpStreamRequest::OnStreamReadyOnPooledConnection(
const SSLConfig& used_ssl_config,
const ProxyInfo& used_proxy_info,
std::unique_ptr<HttpStream> stream) {
@@ -62,57 +61,54 @@
std::move(stream));
}
-void HttpStreamFactoryImpl::Request::
- OnBidirectionalStreamImplReadyOnPooledConnection(
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- std::unique_ptr<BidirectionalStreamImpl> stream) {
+void HttpStreamRequest::OnBidirectionalStreamImplReadyOnPooledConnection(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<BidirectionalStreamImpl> stream) {
DCHECK(completed_);
helper_->OnBidirectionalStreamImplReadyOnPooledConnection(
used_ssl_config, used_proxy_info, std::move(stream));
}
-int HttpStreamFactoryImpl::Request::RestartTunnelWithProxyAuth() {
+int HttpStreamRequest::RestartTunnelWithProxyAuth() {
return helper_->RestartTunnelWithProxyAuth();
}
-void HttpStreamFactoryImpl::Request::SetPriority(RequestPriority priority) {
+void HttpStreamRequest::SetPriority(RequestPriority priority) {
helper_->SetPriority(priority);
}
-LoadState HttpStreamFactoryImpl::Request::GetLoadState() const {
+LoadState HttpStreamRequest::GetLoadState() const {
return helper_->GetLoadState();
}
-bool HttpStreamFactoryImpl::Request::was_alpn_negotiated() const {
+bool HttpStreamRequest::was_alpn_negotiated() const {
DCHECK(completed_);
return was_alpn_negotiated_;
}
-NextProto HttpStreamFactoryImpl::Request::negotiated_protocol() const {
+NextProto HttpStreamRequest::negotiated_protocol() const {
DCHECK(completed_);
return negotiated_protocol_;
}
-bool HttpStreamFactoryImpl::Request::using_spdy() const {
+bool HttpStreamRequest::using_spdy() const {
DCHECK(completed_);
return using_spdy_;
}
-const ConnectionAttempts& HttpStreamFactoryImpl::Request::connection_attempts()
- const {
+const ConnectionAttempts& HttpStreamRequest::connection_attempts() const {
return connection_attempts_;
}
-void HttpStreamFactoryImpl::Request::AddConnectionAttempts(
+void HttpStreamRequest::AddConnectionAttempts(
const ConnectionAttempts& attempts) {
for (const auto& attempt : attempts)
connection_attempts_.push_back(attempt);
}
WebSocketHandshakeStreamBase::CreateHelper*
-HttpStreamFactoryImpl::Request::websocket_handshake_stream_create_helper()
- const {
+HttpStreamRequest::websocket_handshake_stream_create_helper() const {
return websocket_handshake_stream_create_helper_;
}
diff --git a/net/http/http_stream_request.h b/net/http/http_stream_request.h
new file mode 100644
index 0000000..2cce5741
--- /dev/null
+++ b/net/http/http_stream_request.h
@@ -0,0 +1,290 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_HTTP_HTTP_STREAM_REQUEST_H_
+#define NET_HTTP_HTTP_STREAM_REQUEST_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/optional.h"
+#include "net/base/load_states.h"
+#include "net/base/net_error_details.h"
+#include "net/base/net_export.h"
+#include "net/base/request_priority.h"
+#include "net/http/http_response_info.h"
+#include "net/log/net_log_with_source.h"
+#include "net/proxy_resolution/proxy_info.h"
+#include "net/socket/connection_attempts.h"
+#include "net/socket/next_proto.h"
+#include "net/spdy/chromium/spdy_session_key.h"
+#include "net/ssl/ssl_config.h"
+#include "net/ssl/ssl_info.h"
+#include "net/websockets/websocket_handshake_stream_base.h"
+#include "url/gurl.h"
+
+namespace net {
+
+class BidirectionalStreamImpl;
+class HttpAuthController;
+class HttpStream;
+class SSLCertRequestInfo;
+
+// The HttpStreamRequest is the client's handle to the worker object which
+// handles the creation of an HttpStream. While the HttpStream is being
+// created, this object is the creator's handle for interacting with the
+// HttpStream creation process. The request is cancelled by deleting it, after
+// which no callbacks will be invoked.
+class NET_EXPORT_PRIVATE HttpStreamRequest {
+ public:
+ // Indicates which type of stream is requested.
+ enum StreamType {
+ BIDIRECTIONAL_STREAM,
+ HTTP_STREAM,
+ };
+
+ // The HttpStreamRequest::Delegate is a set of callback methods for a
+ // HttpStreamRequestJob. Generally, only one of these methods will be
+ // called as a result of a stream request.
+ class NET_EXPORT_PRIVATE Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // This is the success case for RequestStream.
+ // |stream| is now owned by the delegate.
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
+ // since the HttpStreamRequest performs the proxy resolution.
+ virtual void OnStreamReady(const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<HttpStream> stream) = 0;
+
+ // This is the success case for RequestWebSocketHandshakeStream.
+ // |stream| is now owned by the delegate.
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
+ // since the HttpStreamRequest performs the proxy resolution.
+ virtual void OnWebSocketHandshakeStreamReady(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<WebSocketHandshakeStreamBase> stream) = 0;
+
+ virtual void OnBidirectionalStreamImplReady(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<BidirectionalStreamImpl> stream) = 0;
+
+ // This is the failure to create a stream case.
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ virtual void OnStreamFailed(int status,
+ const NetErrorDetails& net_error_details,
+ const SSLConfig& used_ssl_config) = 0;
+
+ // Called when we have a certificate error for the request.
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ virtual void OnCertificateError(int status,
+ const SSLConfig& used_ssl_config,
+ const SSLInfo& ssl_info) = 0;
+
+ // This is the failure case where we need proxy authentication during
+ // proxy tunnel establishment. For the tunnel case, we were unable to
+ // create the HttpStream, so the caller provides the auth and then resumes
+ // the HttpStreamRequest.
+ //
+ // For the non-tunnel case, the caller will discover the authentication
+ // failure when reading response headers. At that point, it will handle the
+ // authentication failure and restart the HttpStreamRequest entirely.
+ //
+ // Ownership of |auth_controller| and |proxy_response| are owned
+ // by the HttpStreamRequest. |proxy_response| is not guaranteed to be usable
+ // after the lifetime of this callback. The delegate may take a reference
+ // to |auth_controller| if it is needed beyond the lifetime of this
+ // callback.
+ //
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ HttpAuthController* auth_controller) = 0;
+
+ // This is the failure for SSL Client Auth
+ // Ownership of |cert_info| is retained by the HttpStreamRequest. The
+ // delegate may take a reference if it needs the cert_info beyond the
+ // lifetime of this callback.
+ virtual void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
+ SSLCertRequestInfo* cert_info) = 0;
+
+ // This is the failure of the CONNECT request through an HTTPS proxy.
+ // Headers can be read from |response_info|, while the body can be read
+ // from |stream|.
+ //
+ // |used_ssl_config| indicates the actual SSL configuration used for this
+ // stream, since the HttpStreamRequest may have modified the configuration
+ // during stream processing.
+ //
+ // |used_proxy_info| indicates the actual ProxyInfo used for this stream,
+ // since the HttpStreamRequest performs the proxy resolution.
+ //
+ // Ownership of |stream| is transferred to the delegate.
+ virtual void OnHttpsProxyTunnelResponse(
+ const HttpResponseInfo& response_info,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<HttpStream> stream) = 0;
+
+ // Called when finding all QUIC alternative services are marked broken for
+ // the origin in this request which advertises supporting QUIC.
+ virtual void OnQuicBroken() = 0;
+ };
+
+ class NET_EXPORT_PRIVATE Helper {
+ public:
+ virtual ~Helper() {}
+
+ // Returns the LoadState for Request.
+ virtual LoadState GetLoadState() const = 0;
+
+ // Called when Request is destructed.
+ virtual void OnRequestComplete() = 0;
+
+ // Called to resume the HttpStream creation process when necessary
+ // Proxy authentication credentials are collected.
+ virtual int RestartTunnelWithProxyAuth() = 0;
+
+ // Called when the priority of transaction changes.
+ virtual void SetPriority(RequestPriority priority) = 0;
+
+ // Called when SpdySessionPool notifies the Request
+ // that it can be served on a SpdySession created by another Request,
+ // therefore the Jobs can be destroyed.
+ virtual void OnStreamReadyOnPooledConnection(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& proxy_info,
+ std::unique_ptr<HttpStream> stream) = 0;
+ virtual void OnBidirectionalStreamImplReadyOnPooledConnection(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<BidirectionalStreamImpl> stream) = 0;
+ };
+
+ // Request will notify |job_controller| when it's destructed.
+ // Thus |job_controller| is valid for the lifetime of the |this| Request.
+ HttpStreamRequest(const GURL& url,
+ Helper* helper,
+ HttpStreamRequest::Delegate* delegate,
+ WebSocketHandshakeStreamBase::CreateHelper*
+ websocket_handshake_stream_create_helper,
+ const NetLogWithSource& net_log,
+ StreamType stream_type);
+
+ ~HttpStreamRequest();
+
+ // When a HttpStream creation process is stalled due to necessity
+ // of Proxy authentication credentials, the delegate OnNeedsProxyAuth
+ // will have been called. It now becomes the delegate's responsibility
+ // to collect the necessary credentials, and then call this method to
+ // resume the HttpStream creation process.
+ int RestartTunnelWithProxyAuth();
+
+ // Called when the priority of the parent transaction changes.
+ void SetPriority(RequestPriority priority);
+
+ // Marks completion of the request. Must be called before OnStreamReady().
+ void Complete(bool was_alpn_negotiated,
+ NextProto negotiated_protocol,
+ bool using_spdy);
+
+ // Called by |helper_| to record connection attempts made by the socket
+ // layer in an attached Job for this stream request.
+ void AddConnectionAttempts(const ConnectionAttempts& attempts);
+
+ // Called when a stream becomes available on a connection that was not created
+ // by this request.
+ void OnStreamReadyOnPooledConnection(const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<HttpStream> stream);
+ void OnBidirectionalStreamImplReadyOnPooledConnection(
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ std::unique_ptr<BidirectionalStreamImpl> stream);
+
+ // Returns the LoadState for the request.
+ LoadState GetLoadState() const;
+
+ // Returns true if TLS/ALPN was negotiated for this stream.
+ bool was_alpn_negotiated() const;
+
+ // Protocol negotiated with the server.
+ NextProto negotiated_protocol() const;
+
+ // Returns true if this stream is being fetched over SPDY.
+ bool using_spdy() const;
+
+ // Returns socket-layer connection attempts made for this stream request.
+ const ConnectionAttempts& connection_attempts() const;
+
+ // Returns the WebSocketHandshakeStreamBase::CreateHelper for this stream
+ // request.
+ WebSocketHandshakeStreamBase::CreateHelper*
+ websocket_handshake_stream_create_helper() const;
+
+ // The GURL from the HttpRequestInfo the started the Request.
+ const GURL& url() const { return url_; }
+
+ const NetLogWithSource& net_log() const { return net_log_; }
+
+ // Called when the |helper_| determines the appropriate |spdy_session_key|
+ // for the Request. Note that this does not mean that SPDY is necessarily
+ // supported for this SpdySessionKey, since we may need to wait for NPN to
+ // complete before knowing if SPDY is available.
+ void SetSpdySessionKey(const SpdySessionKey& spdy_session_key) {
+ spdy_session_key_ = spdy_session_key;
+ }
+ bool HasSpdySessionKey() const { return spdy_session_key_.has_value(); }
+ const SpdySessionKey& GetSpdySessionKey() const {
+ DCHECK(HasSpdySessionKey());
+ return spdy_session_key_.value();
+ }
+ void ResetSpdySessionKey() { spdy_session_key_.reset(); }
+
+ StreamType stream_type() const { return stream_type_; }
+
+ bool completed() const { return completed_; }
+
+ private:
+ const GURL url_;
+
+ // Unowned. The helper must outlive this request.
+ Helper* helper_;
+
+ WebSocketHandshakeStreamBase::CreateHelper* const
+ websocket_handshake_stream_create_helper_;
+ const NetLogWithSource net_log_;
+
+ base::Optional<SpdySessionKey> spdy_session_key_;
+
+ bool completed_;
+ bool was_alpn_negotiated_;
+ // Protocol negotiated with the server.
+ NextProto negotiated_protocol_;
+ bool using_spdy_;
+ ConnectionAttempts connection_attempts_;
+ const StreamType stream_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(HttpStreamRequest);
+};
+
+} // namespace net
+
+#endif // NET_HTTP_HTTP_STREAM_REQUEST_H_
diff --git a/net/http/http_stream_factory_impl_request_unittest.cc b/net/http/http_stream_request_unittest.cc
similarity index 85%
rename from net/http/http_stream_factory_impl_request_unittest.cc
rename to net/http/http_stream_request_unittest.cc
index 6861019c..3291661 100644
--- a/net/http/http_stream_factory_impl_request_unittest.cc
+++ b/net/http/http_stream_request_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/http/http_stream_factory_impl_request.h"
+#include "net/http/http_stream_request.h"
#include <utility>
@@ -11,7 +11,6 @@
#include "net/http/http_stream_factory_impl_job.h"
#include "net/http/http_stream_factory_impl_job_controller.h"
#include "net/http/http_stream_factory_test_util.h"
-#include "net/proxy_resolution/proxy_info.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/spdy/chromium/spdy_test_util_common.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,10 +19,8 @@
namespace net {
-class HttpStreamFactoryImplRequestTest : public ::testing::Test {};
-
// Make sure that Request passes on its priority updates to its jobs.
-TEST_F(HttpStreamFactoryImplRequestTest, SetPriority) {
+TEST(HttpStreamRequestTest, SetPriority) {
SequencedSocketData data(nullptr, 0, nullptr, 0);
data.set_connect_data(MockConnect(ASYNC, OK));
auto ssl_data = std::make_unique<SSLSocketDataProvider>(ASYNC, OK);
@@ -49,10 +46,9 @@
job_controller.get();
factory->job_controller_set_.insert(std::move(job_controller));
- std::unique_ptr<HttpStreamFactoryImpl::Request> request(
- job_controller_raw_ptr->Start(
- &request_delegate, nullptr, NetLogWithSource(),
- HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY));
+ std::unique_ptr<HttpStreamRequest> request(job_controller_raw_ptr->Start(
+ &request_delegate, nullptr, NetLogWithSource(),
+ HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY));
EXPECT_TRUE(job_controller_raw_ptr->main_job());
EXPECT_EQ(DEFAULT_PRIORITY, job_controller_raw_ptr->main_job()->priority());
diff --git a/net/quic/chromium/quic_network_transaction_unittest.cc b/net/quic/chromium/quic_network_transaction_unittest.cc
index 3244038..e270c0d 100644
--- a/net/quic/chromium/quic_network_transaction_unittest.cc
+++ b/net/quic/chromium/quic_network_transaction_unittest.cc
@@ -3394,10 +3394,10 @@
SendRequestAndExpectHttpResponse("hello world");
}
-// When multiple alternative services are advertised,
-// HttpStreamFactoryImpl::RequestStreamInternal() should select the alternative
-// service which uses existing QUIC session if available. If no existing QUIC
-// session can be used, use the first alternative service from the list.
+// When multiple alternative services are advertised, HttpStreamFactoryImpl
+// should select the alternative service which uses existing QUIC session if
+// available. If no existing QUIC session can be used, use the first alternative
+// service from the list.
TEST_P(QuicNetworkTransactionTest, UseExistingAlternativeServiceForQuic) {
session_params_.quic_allow_remote_alt_svc = true;
MockRead http_reads[] = {
diff --git a/net/spdy/chromium/spdy_session_pool.cc b/net/spdy/chromium/spdy_session_pool.cc
index b786ecfa..5089438 100644
--- a/net/spdy/chromium/spdy_session_pool.cc
+++ b/net/spdy/chromium/spdy_session_pool.cc
@@ -19,6 +19,7 @@
#include "net/base/trace_constants.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
+#include "net/http/http_stream_request.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_with_source.h"
@@ -404,7 +405,7 @@
auto iter = spdy_session_request_map_.find(spdy_session_key);
if (iter == spdy_session_request_map_.end())
return;
- HttpStreamFactoryImpl::Request* request = *iter->second.begin();
+ HttpStreamRequest* request = *iter->second.begin();
request->Complete(was_alpn_negotiated, negotiated_protocol, using_spdy);
RemoveRequestFromSpdySessionRequestMap(request);
if (request->stream_type() == HttpStreamRequest::BIDIRECTIONAL_STREAM) {
@@ -447,7 +448,7 @@
void SpdySessionPool::AddRequestToSpdySessionRequestMap(
const SpdySessionKey& spdy_session_key,
- HttpStreamFactoryImpl::Request* request) {
+ HttpStreamRequest* request) {
if (request->HasSpdySessionKey())
return;
RequestSet& request_set = spdy_session_request_map_[spdy_session_key];
@@ -457,7 +458,7 @@
}
void SpdySessionPool::RemoveRequestFromSpdySessionRequestMap(
- HttpStreamFactoryImpl::Request* request) {
+ HttpStreamRequest* request) {
if (!request->HasSpdySessionKey())
return;
const SpdySessionKey& spdy_session_key = request->GetSpdySessionKey();
diff --git a/net/spdy/chromium/spdy_session_pool.h b/net/spdy/chromium/spdy_session_pool.h
index 8de7365..84c185c7 100644
--- a/net/spdy/chromium/spdy_session_pool.h
+++ b/net/spdy/chromium/spdy_session_pool.h
@@ -23,8 +23,8 @@
#include "net/base/network_change_notifier.h"
#include "net/base/proxy_server.h"
#include "net/cert/cert_database.h"
-#include "net/http/http_stream_factory_impl_request.h"
#include "net/proxy_resolution/proxy_config.h"
+#include "net/quic/core/quic_versions.h"
#include "net/spdy/chromium/http2_push_promise_index.h"
#include "net/spdy/chromium/server_push_delegate.h"
#include "net/spdy/chromium/spdy_session_key.h"
@@ -43,6 +43,7 @@
class ClientSocketHandle;
class HostResolver;
class HttpServerProperties;
+class HttpStreamRequest;
class NetLogWithSource;
class SpdySession;
class TransportSecurityState;
@@ -185,19 +186,17 @@
// Adds |request| to |spdy_session_request_map_| under |spdy_session_key| Key.
// Sets |spdy_session_key| as |request|'s SpdySessionKey.
- void AddRequestToSpdySessionRequestMap(
- const SpdySessionKey& spdy_session_key,
- HttpStreamFactoryImpl::Request* request);
+ void AddRequestToSpdySessionRequestMap(const SpdySessionKey& spdy_session_key,
+ HttpStreamRequest* request);
// Removes |request| from |spdy_session_request_map_|. No-op if |request| does
// not have a SpdySessionKey.
- void RemoveRequestFromSpdySessionRequestMap(
- HttpStreamFactoryImpl::Request* request);
+ void RemoveRequestFromSpdySessionRequestMap(HttpStreamRequest* request);
private:
friend class SpdySessionPoolPeer; // For testing.
- typedef std::set<HttpStreamFactoryImpl::Request*> RequestSet;
+ typedef std::set<HttpStreamRequest*> RequestSet;
typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap;
typedef std::set<SpdySession*> SessionSet;
typedef std::vector<base::WeakPtr<SpdySession> > WeakSessionList;