diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-13 20:45:31 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-13 20:45:31 +0000 |
commit | 560c0431ae36b3c115aad89a014a5fcbb296f420 (patch) | |
tree | cc0ca213d15e01e8278988e9ace989624c8babdb | |
parent | 64bff312f36572a45a331aab9d6e82e7c03a5d6d (diff) | |
download | chromium_src-560c0431ae36b3c115aad89a014a5fcbb296f420.zip chromium_src-560c0431ae36b3c115aad89a014a5fcbb296f420.tar.gz chromium_src-560c0431ae36b3c115aad89a014a5fcbb296f420.tar.bz2 |
Remove |net_log_| as a class member and pass it in where needed and a little cleanup.
BUG=42795
TEST=existing unit tests
Review URL: http://codereview.chromium.org/2806052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52214 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/http/http_auth_controller.cc | 20 | ||||
-rw-r--r-- | net/http/http_auth_controller.h | 18 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 9 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket.cc | 10 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket.h | 23 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket_pool_unittest.cc | 9 |
6 files changed, 42 insertions, 47 deletions
diff --git a/net/http/http_auth_controller.cc b/net/http/http_auth_controller.cc index 22b4f20..0392741 100644 --- a/net/http/http_auth_controller.cc +++ b/net/http/http_auth_controller.cc @@ -50,23 +50,22 @@ std::string AuthChallengeLogMessage(HttpResponseHeaders* headers) { HttpAuthController::HttpAuthController( HttpAuth::Target target, const GURL& auth_url, - scoped_refptr<HttpNetworkSession> session, - const BoundNetLog& net_log) + scoped_refptr<HttpNetworkSession> session) : target_(target), auth_url_(auth_url), auth_origin_(auth_url.GetOrigin()), auth_path_(HttpAuth::AUTH_PROXY ? std::string() : auth_url.path()), embedded_identity_used_(false), default_credentials_used_(false), - session_(session), - net_log_(net_log) { + session_(session) { } HttpAuthController::~HttpAuthController() {} int HttpAuthController::MaybeGenerateAuthToken(const HttpRequestInfo* request, - CompletionCallback* callback) { - bool needs_auth = HaveAuth() || SelectPreemptiveAuth(); + CompletionCallback* callback, + const BoundNetLog& net_log) { + bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); if (!needs_auth) return OK; const std::wstring* username = NULL; @@ -80,7 +79,7 @@ int HttpAuthController::MaybeGenerateAuthToken(const HttpRequestInfo* request, &auth_token_); } -bool HttpAuthController::SelectPreemptiveAuth() { +bool HttpAuthController::SelectPreemptiveAuth(const BoundNetLog& net_log) { DCHECK(!HaveAuth()); DCHECK(identity_.invalid); @@ -104,7 +103,7 @@ bool HttpAuthController::SelectPreemptiveAuth() { CreatePreemptiveAuthHandlerFromString(entry->auth_challenge(), target_, auth_origin_, entry->IncrementNonceCount(), - net_log_, &handler_preemptive); + net_log, &handler_preemptive); if (rv_create != OK) return false; @@ -129,7 +128,8 @@ void HttpAuthController::AddAuthorizationHeader( int HttpAuthController::HandleAuthChallenge( scoped_refptr<HttpResponseHeaders> headers, bool do_not_send_server_auth, - bool establishing_tunnel) { + bool establishing_tunnel, + const BoundNetLog& net_log) { DCHECK(headers); DCHECK(auth_origin_.is_valid()); @@ -155,7 +155,7 @@ int HttpAuthController::HandleAuthChallenge( if (target_ != HttpAuth::AUTH_SERVER || !do_not_send_server_auth) { // Find the best authentication challenge that we support. HttpAuth::ChooseBestChallenge(session_->http_auth_handler_factory(), - headers, target_, auth_origin_, net_log_, + headers, target_, auth_origin_, net_log, &handler_); } diff --git a/net/http/http_auth_controller.h b/net/http/http_auth_controller.h index 655e46d..b4467bd 100644 --- a/net/http/http_auth_controller.h +++ b/net/http/http_auth_controller.h @@ -19,6 +19,7 @@ namespace net { class AuthChallengeInfo; class HostResolver; +class HttpAuthHandler; class HttpNetworkSession; class HttpRequestHeaders; struct HttpRequestInfo; @@ -28,15 +29,15 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { // The arguments are self explanatory except possibly for |auth_url|, which // should be both the auth target and auth path in a single url argument. HttpAuthController(HttpAuth::Target target, const GURL& auth_url, - scoped_refptr<HttpNetworkSession> session, - const BoundNetLog& net_log); + scoped_refptr<HttpNetworkSession> session); // Generate an authentication token for |target| if necessary. The return // value is a net error code. |OK| will be returned both in the case that // a token is correctly generated synchronously, as well as when no tokens // were necessary. virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, - CompletionCallback* callback); + CompletionCallback* callback, + const BoundNetLog& net_log); // Adds either the proxy auth header, or the origin server auth header, // as specified by |target_|. @@ -48,7 +49,8 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { // otherwise. It may also populate |auth_info_|. virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, bool do_not_send_server_auth, - bool establishing_tunnel); + bool establishing_tunnel, + const BoundNetLog& net_log); // Store the supplied credentials and prepare to restart the auth. virtual void ResetAuth(const std::wstring& username, @@ -66,10 +68,6 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { return auth_info_; } - void set_net_log(const BoundNetLog& net_log) { - net_log_ = net_log; - } - protected: // So that we can mock this object. friend class base::RefCounted<HttpAuthController>; virtual ~HttpAuthController(); @@ -78,7 +76,7 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { // Searches the auth cache for an entry that encompasses the request's path. // If such an entry is found, updates |identity_| and |handler_| with the // cache entry's data and returns true. - bool SelectPreemptiveAuth(); + bool SelectPreemptiveAuth(const BoundNetLog& net_log); // Invalidates any auth cache entries after authentication has failed. // The identity that was rejected is |identity_|. @@ -133,8 +131,6 @@ class HttpAuthController : public base::RefCounted<HttpAuthController> { bool default_credentials_used_; scoped_refptr<HttpNetworkSession> session_; - - BoundNetLog net_log_; }; } // namespace net diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index a029795..32f8530 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -709,7 +709,7 @@ int HttpNetworkTransaction::DoInitConnection() { if (!auth_controllers_[target].get()) auth_controllers_[target] = new HttpAuthController(target, AuthURL(target), - session_, net_log_); + session_); } next_state_ = STATE_INIT_CONNECTION_COMPLETE; @@ -1006,7 +1006,7 @@ int HttpNetworkTransaction::DoGenerateProxyAuthToken() { if (!ShouldApplyProxyAuth()) return OK; return auth_controllers_[HttpAuth::AUTH_PROXY]->MaybeGenerateAuthToken( - request_, &io_callback_); + request_, &io_callback_, net_log_); } int HttpNetworkTransaction::DoGenerateProxyAuthTokenComplete(int rv) { @@ -1021,7 +1021,7 @@ int HttpNetworkTransaction::DoGenerateServerAuthToken() { if (!ShouldApplyServerAuth()) return OK; return auth_controllers_[HttpAuth::AUTH_SERVER]->MaybeGenerateAuthToken( - request_, &io_callback_); + request_, &io_callback_, net_log_); } int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) { @@ -1786,7 +1786,8 @@ int HttpNetworkTransaction::HandleAuthChallenge() { return ERR_UNEXPECTED_PROXY_AUTH; int rv = auth_controllers_[target]->HandleAuthChallenge( - headers, (request_->load_flags & LOAD_DO_NOT_SEND_AUTH_DATA) != 0, false); + headers, (request_->load_flags & LOAD_DO_NOT_SEND_AUTH_DATA) != 0, false, + net_log_); if (auth_controllers_[target]->HaveAuthHandler()) pending_auth_target_ = target; diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc index 321b5ea..df64589 100644 --- a/net/http/http_proxy_client_socket.cc +++ b/net/http/http_proxy_client_socket.cc @@ -57,13 +57,11 @@ HttpProxyClientSocket::HttpProxyClientSocket( next_state_(STATE_NONE), user_callback_(NULL), transport_(transport_socket), - tunnel_(tunnel), - auth_(auth), endpoint_(endpoint), + auth_(auth), + tunnel_(tunnel), net_log_(transport_socket->socket()->NetLog()) { DCHECK_EQ(tunnel, auth != NULL); - if (tunnel) - auth->set_net_log(net_log_); // Synthesize the bits of a request that we actually use. request_.url = request_url; request_.method = "GET"; @@ -286,7 +284,7 @@ int HttpProxyClientSocket::DoLoop(int last_io_result) { int HttpProxyClientSocket::DoGenerateAuthToken() { next_state_ = STATE_GENERATE_AUTH_TOKEN_COMPLETE; - return auth_->MaybeGenerateAuthToken(&request_, &io_callback_); + return auth_->MaybeGenerateAuthToken(&request_, &io_callback_, net_log_); } int HttpProxyClientSocket::DoGenerateAuthTokenComplete(int result) { @@ -411,7 +409,7 @@ int HttpProxyClientSocket::DoDrainBodyComplete(int result) { int HttpProxyClientSocket::HandleAuthChallenge() { DCHECK(response_.headers); - int rv = auth_->HandleAuthChallenge(response_.headers, false, true); + int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); response_.auth_challenge = auth_->auth_info(); if (rv == OK) return ERR_PROXY_AUTH_REQUESTED; diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h index 4870f0c..692cc19e 100644 --- a/net/http/http_proxy_client_socket.h +++ b/net/http/http_proxy_client_socket.h @@ -114,25 +114,24 @@ class HttpProxyClientSocket : public ClientSocket { // Stores the callback to the layer above, called on completing Connect(). CompletionCallback* user_callback_; - // Stores the underlying socket. - scoped_ptr<ClientSocketHandle> transport_; - - bool tunnel_; - - std::string request_headers_; - - scoped_ptr<HttpStream> http_stream_; HttpRequestInfo request_; HttpResponseInfo response_; - const scoped_refptr<HttpAuthController> auth_; + + scoped_ptr<HttpStream> http_stream_; + scoped_refptr<IOBuffer> drain_buf_; + + // Stores the underlying socket. + const scoped_ptr<ClientSocketHandle> transport_; // 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_; + const HostPortPair endpoint_; + scoped_refptr<HttpAuthController> auth_; + const bool tunnel_; - scoped_refptr<IOBuffer> drain_buf_; + std::string request_headers_; - BoundNetLog net_log_; + const BoundNetLog net_log_; DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); }; diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc index fbd999e..228b6a8 100644 --- a/net/http/http_proxy_client_socket_pool_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_unittest.cc @@ -38,8 +38,7 @@ class MockHttpAuthController : public HttpAuthController { public: MockHttpAuthController() : HttpAuthController(HttpAuth::AUTH_PROXY, GURL(), - scoped_refptr<HttpNetworkSession>(NULL), - BoundNetLog()), + scoped_refptr<HttpNetworkSession>(NULL)), data_(NULL), data_index_(0), data_count_(0) { @@ -53,7 +52,8 @@ class MockHttpAuthController : public HttpAuthController { // HttpAuthController methods. virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, - CompletionCallback* callback) { + CompletionCallback* callback, + const BoundNetLog& net_log) { return OK; } virtual void AddAuthorizationHeader( @@ -62,7 +62,8 @@ class MockHttpAuthController : public HttpAuthController { } virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, bool do_not_send_server_auth, - bool establishing_tunnel) { + bool establishing_tunnel, + const BoundNetLog& net_log) { return OK; } virtual bool HaveAuthHandler() const { return HaveAuth(); } |