diff options
Diffstat (limited to 'net/http/http_network_transaction.h')
-rw-r--r-- | net/http/http_network_transaction.h | 137 |
1 files changed, 26 insertions, 111 deletions
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 23eb44f..a010f1b 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -12,55 +12,35 @@ #include "base/gtest_prod_util.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" -#include "base/string16.h" #include "base/time.h" -#include "net/base/address_list.h" -#include "net/base/io_buffer.h" -#include "net/base/load_flags.h" -#include "net/base/load_states.h" #include "net/base/net_log.h" +#include "net/base/request_priority.h" #include "net/base/ssl_config_service.h" -#include "net/http/http_alternate_protocols.h" #include "net/http/http_auth.h" -#include "net/http/http_auth_controller.h" -#include "net/http/http_auth_handler.h" #include "net/http/http_response_info.h" #include "net/http/http_transaction.h" +#include "net/http/stream_factory.h" #include "net/proxy/proxy_service.h" -#include "net/socket/client_socket_pool.h" namespace net { class ClientSocketFactory; class ClientSocketHandle; +class HttpAuthController; class HttpNetworkSession; class HttpRequestHeaders; class HttpStream; +class HttpStreamHandle; +class HttpStreamRequest; +class IOBuffer; -class HttpNetworkTransaction : public HttpTransaction { +class HttpNetworkTransaction : public HttpTransaction, + public StreamFactory::StreamRequestDelegate { public: explicit HttpNetworkTransaction(HttpNetworkSession* session); virtual ~HttpNetworkTransaction(); - static void SetHostMappingRules(const std::string& rules); - - // Controls whether or not we use the Alternate-Protocol header. - static void SetUseAlternateProtocols(bool value); - - // Controls whether or not we use ssl when in spdy mode. - static void SetUseSSLOverSpdyWithoutNPN(bool value); - - // Controls whether or not we use spdy without npn. - static void SetUseSpdyWithoutNPN(bool value); - - // Sets the next protocol negotiation value used during the SSL handshake. - static void SetNextProtos(const std::string& next_protos); - - // Sets the HttpNetworkTransaction into a mode where it can ignore - // certificate errors. This is for testing. - static void IgnoreCertificateErrors(bool enabled); - // HttpTransaction methods: virtual int Start(const HttpRequestInfo* request_info, CompletionCallback* callback, @@ -71,10 +51,7 @@ class HttpNetworkTransaction : public HttpTransaction { virtual int RestartWithAuth(const string16& username, const string16& password, CompletionCallback* callback); - virtual bool IsReadyToRestartForAuth() { - return pending_auth_target_ != HttpAuth::AUTH_NONE && - HaveAuth(pending_auth_target_); - } + virtual bool IsReadyToRestartForAuth(); virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); virtual void StopCaching() {} @@ -82,6 +59,16 @@ class HttpNetworkTransaction : public HttpTransaction { virtual LoadState GetLoadState() const; virtual uint64 GetUploadProgress() const; + // StreamRequestDelegate methods: + virtual void OnStreamReady(HttpStreamHandle* stream); + virtual void OnStreamFailed(int status); + virtual void OnCertificateError(int status, const SSLInfo& ssl_info); + virtual void OnNeedsProxyAuth( + const scoped_refptr<HttpAuthController>& auth_controller, + const HttpResponseInfo& response_info); + virtual void OnNeedsClientAuth( + const scoped_refptr<SSLCertRequestInfo>& cert_info); + private: FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, ResetStateForRestart); FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, WindowUpdateReceived); @@ -89,14 +76,8 @@ class HttpNetworkTransaction : public HttpTransaction { FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, FlowControlStallResume); enum State { - STATE_RESOLVE_PROXY, - STATE_RESOLVE_PROXY_COMPLETE, - STATE_INIT_CONNECTION, - STATE_INIT_CONNECTION_COMPLETE, STATE_INIT_STREAM, STATE_INIT_STREAM_COMPLETE, - STATE_RESTART_TUNNEL_AUTH, - STATE_RESTART_TUNNEL_AUTH_COMPLETE, STATE_GENERATE_PROXY_AUTH_TOKEN, STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, STATE_GENERATE_SERVER_AUTH_TOKEN, @@ -112,11 +93,7 @@ class HttpNetworkTransaction : public HttpTransaction { STATE_NONE }; - enum AlternateProtocolMode { - kUnspecified, // Unspecified, check HttpAlternateProtocols - kUsingAlternateProtocol, // Using an alternate protocol - kDoNotUseAlternateProtocol, // Failed to connect once, do not try again. - }; + bool is_https_request() const; void DoCallback(int result); void OnIOComplete(int result); @@ -128,14 +105,8 @@ class HttpNetworkTransaction : public HttpTransaction { // argument receive the result from the previous state. If a method returns // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the // next state method as the result arg. - int DoResolveProxy(); - int DoResolveProxyComplete(int result); - int DoInitConnection(); - int DoInitConnectionComplete(int result); int DoInitStream(); int DoInitStreamComplete(int result); - int DoRestartTunnelAuth(); - int DoRestartTunnelAuthComplete(int result); int DoGenerateProxyAuthToken(); int DoGenerateProxyAuthTokenComplete(int result); int DoGenerateServerAuthToken(); @@ -149,9 +120,6 @@ class HttpNetworkTransaction : public HttpTransaction { int DoDrainBodyForAuthRestart(); int DoDrainBodyForAuthRestartComplete(int result); - // Record histograms of latency until Connect() completes. - static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); - // Record histogram of time until first byte of header is received. void LogTransactionConnectedMetrics(); @@ -162,24 +130,9 @@ class HttpNetworkTransaction : public HttpTransaction { // response to a CONNECT request. void LogBlockedTunnelResponse(int response_code) const; - static void LogIOErrorMetrics(const ClientSocketHandle& handle); - - // Called to handle an HTTP proxy tunnel request for auth. - int HandleTunnelAuthFailure(int error); - - // Called to handle a certificate error. Returns OK if the error should be - // ignored. Otherwise, stores the certificate in response_.ssl_info and - // returns the same error code. - int HandleCertificateError(int error); - // Called to handle a client certificate request. int HandleCertificateRequest(int error); - // Called to possibly recover from an SSL handshake error. Sets next_state_ - // and returns OK if recovering from the error. Otherwise, the same error - // code is returned. - int HandleSSLHandshakeError(int error); - // Called to possibly recover from the given error. Sets next_state_ and // returns OK if recovering from the error. Otherwise, the same error code // is returned. @@ -196,14 +149,6 @@ class HttpNetworkTransaction : public HttpTransaction { // ShouldResendRequest() is true. void ResetConnectionAndRequestForResend(); - // Called when we encounter a network error that could be resolved by trying - // a new proxy configuration. If there is another proxy configuration to try - // then this method sets next_state_ appropriately and returns either OK or - // ERR_IO_PENDING depending on whether or not the new proxy configuration is - // available synchronously or asynchronously. Otherwise, the given error - // code is simply returned. - int ReconsiderProxyAfterError(int error); - // Decides the policy when the connection is closed before the end of headers // has been read. This only applies to reading responses, and not writing // requests. @@ -231,21 +176,15 @@ class HttpNetworkTransaction : public HttpTransaction { // May update |pending_auth_target_| or |response_.auth_challenge|. int HandleAuthChallenge(); - bool HaveAuth(HttpAuth::Target target) const { - return auth_controllers_[target].get() && - auth_controllers_[target]->HaveAuth(); - } + // Returns true if we have auth credentials for the given target. + bool HaveAuth(HttpAuth::Target target) const; // Get the {scheme, host, path, port} for the authentication target GURL AuthURL(HttpAuth::Target target) const; - void MarkBrokenAlternateProtocolAndFallback(); - // Debug helper. static std::string DescribeState(State state); - static bool g_ignore_certificate_errors; - scoped_refptr<HttpAuthController> auth_controllers_[HttpAuth::AUTH_NUM_TARGETS]; @@ -263,11 +202,12 @@ class HttpNetworkTransaction : public HttpTransaction { const HttpRequestInfo* request_; HttpResponseInfo response_; - ProxyService::PacRequest* pac_request_; ProxyInfo proxy_info_; - scoped_ptr<ClientSocketHandle> connection_; - scoped_ptr<HttpStream> stream_; + scoped_refptr<StreamFactory::StreamRequestJob> stream_request_; + scoped_ptr<HttpStreamHandle> stream_; + + // True if this transaction was serviced on a reused socket. bool reused_socket_; // True if we've validated the headers that the stream parser has returned. @@ -278,27 +218,6 @@ class HttpNetworkTransaction : public HttpTransaction { // responses. bool logged_response_time_; - // True if handling a HTTPS request, or using SPDY with SSL - bool using_ssl_; - - // True if this network transaction is using SPDY instead of HTTP. - bool using_spdy_; - - // True if this network transaction wants to use SPDY (not over npn) - bool want_spdy_without_npn_; - - // True if this network transaction wants to use SSL with SPDY (not over npn) - bool want_ssl_over_spdy_without_npn_; - - - // The certificate error while using SPDY over SSL for insecure URLs. - int spdy_certificate_error_; - - AlternateProtocolMode alternate_protocol_mode_; - - // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol. - HttpAlternateProtocols::Protocol alternate_protocol_; - SSLConfig ssl_config_; std::string request_headers_; @@ -318,10 +237,6 @@ class HttpNetworkTransaction : public HttpTransaction { // The next state in the state machine. State next_state_; - // The hostname and port of the endpoint. This is not necessarily the one - // specified by the URL, due to Alternate-Protocol or fixed testing ports. - HostPortPair endpoint_; - // True when the tunnel is in the process of being established - we can't // read from the socket until the tunnel is done. bool establishing_tunnel_; |