diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-28 18:44:58 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-28 18:44:58 +0000 |
commit | f3cf980ca36d5b557b626d1bba4db6ded3ab2b77 (patch) | |
tree | 74028618ccef405480ff6da6a9d0d8c80a8fda7f /net/socket_stream | |
parent | 7f5969dda833a858bc946ca59ba0a9afbee2bc89 (diff) | |
download | chromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.zip chromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.tar.gz chromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.tar.bz2 |
Use AuthCredentials throughout the network stack instead of username/password.
This is a refactor only - no behavior change should happen.
Review URL: http://codereview.chromium.org/8340026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket_stream')
-rw-r--r-- | net/socket_stream/socket_stream.cc | 23 | ||||
-rw-r--r-- | net/socket_stream/socket_stream.h | 5 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_job.cc | 5 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_job.h | 4 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_unittest.cc | 19 |
5 files changed, 20 insertions, 36 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc index cb8f097..9af48f4 100644 --- a/net/socket_stream/socket_stream.cc +++ b/net/socket_stream/socket_stream.cc @@ -206,8 +206,7 @@ void SocketStream::Close() { NewRunnableMethod(this, &SocketStream::DoClose)); } -void SocketStream::RestartWithAuth( - const string16& username, const string16& password) { +void SocketStream::RestartWithAuth(const AuthCredentials& credentials) { DCHECK(MessageLoop::current()) << "The current MessageLoop must exist"; DCHECK_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()) << @@ -219,11 +218,10 @@ void SocketStream::RestartWithAuth( } if (auth_identity_.invalid) { - // Update the username/password. + // Update the credentials. auth_identity_.source = HttpAuth::IDENT_SRC_EXTERNAL; auth_identity_.invalid = false; - auth_identity_.username = username; - auth_identity_.password = password; + auth_identity_.credentials = credentials; } MessageLoop::current()->PostTask( @@ -713,8 +711,7 @@ int SocketStream::DoWriteTunnelHeaders() { if (rv_create == OK) { auth_identity_.source = HttpAuth::IDENT_SRC_PATH_LOOKUP; auth_identity_.invalid = false; - auth_identity_.username = entry->username(); - auth_identity_.password = entry->password(); + auth_identity_.credentials = AuthCredentials(); auth_handler_.swap(handler_preemptive); } } @@ -728,8 +725,7 @@ int SocketStream::DoWriteTunnelHeaders() { HttpRequestInfo request_info; std::string auth_token; int rv = auth_handler_->GenerateAuthToken( - &auth_identity_.username, - &auth_identity_.password, + &auth_identity_.credentials, &request_info, NULL, &auth_token); @@ -1061,8 +1057,7 @@ int SocketStream::HandleAuthChallenge(const HttpResponseHeaders* headers) { auth_cache_.Remove(auth_origin, auth_handler_->realm(), auth_handler_->auth_scheme(), - auth_identity_.username, - auth_identity_.password); + auth_identity_.credentials); auth_handler_.reset(); auth_identity_ = HttpAuth::Identity(); } @@ -1085,8 +1080,7 @@ int SocketStream::HandleAuthChallenge(const HttpResponseHeaders* headers) { if (entry) { auth_identity_.source = HttpAuth::IDENT_SRC_REALM_LOOKUP; auth_identity_.invalid = false; - auth_identity_.username = entry->username(); - auth_identity_.password = entry->password(); + auth_identity_.credentials = AuthCredentials(); // Restart with auth info. } return ERR_PROXY_AUTH_UNSUPPORTED; @@ -1156,8 +1150,7 @@ void SocketStream::DoRestartWithAuth() { auth_handler_->realm(), auth_handler_->auth_scheme(), auth_handler_->challenge(), - auth_identity_.username, - auth_identity_.password, + auth_identity_.credentials, std::string()); tunnel_request_headers_ = NULL; diff --git a/net/socket_stream/socket_stream.h b/net/socket_stream/socket_stream.h index 2a4f0d7..9539ca6 100644 --- a/net/socket_stream/socket_stream.h +++ b/net/socket_stream/socket_stream.h @@ -13,7 +13,6 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/string16.h" #include "base/task.h" #include "net/base/address_list.h" #include "net/base/completion_callback.h" @@ -151,9 +150,7 @@ class NET_EXPORT SocketStream // Restarts with authentication info. // Should be used for response of OnAuthRequired. - virtual void RestartWithAuth( - const string16& username, - const string16& password); + virtual void RestartWithAuth(const AuthCredentials& credentials); // Detach delegate. Call before delegate is deleted. // Once delegate is detached, close the socket stream and never call delegate diff --git a/net/socket_stream/socket_stream_job.cc b/net/socket_stream/socket_stream_job.cc index cfbea3e..64386eb 100644 --- a/net/socket_stream/socket_stream_job.cc +++ b/net/socket_stream/socket_stream_job.cc @@ -62,9 +62,8 @@ void SocketStreamJob::Close() { socket_->Close(); } -void SocketStreamJob::RestartWithAuth(const string16& username, - const string16& password) { - socket_->RestartWithAuth(username, password); +void SocketStreamJob::RestartWithAuth(const AuthCredentials& credentials) { + socket_->RestartWithAuth(credentials); } void SocketStreamJob::DetachDelegate() { diff --git a/net/socket_stream/socket_stream_job.h b/net/socket_stream/socket_stream_job.h index 0b87c1a..039b933 100644 --- a/net/socket_stream/socket_stream_job.h +++ b/net/socket_stream/socket_stream_job.h @@ -9,7 +9,6 @@ #include <string> #include "base/memory/ref_counted.h" -#include "base/string16.h" #include "net/base/net_export.h" #include "net/socket_stream/socket_stream.h" @@ -63,8 +62,7 @@ class NET_EXPORT SocketStreamJob virtual void Close(); - virtual void RestartWithAuth(const string16& username, - const string16& password); + virtual void RestartWithAuth(const AuthCredentials& credentials); virtual void DetachDelegate(); diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc index cbdd6ed..3732498 100644 --- a/net/socket_stream/socket_stream_unittest.cc +++ b/net/socket_stream/socket_stream_unittest.cc @@ -144,14 +144,12 @@ class SocketStreamEventRecorder : public net::SocketStream::Delegate { event->socket->Close(); } void DoRestartWithAuth(SocketStreamEvent* event) { - VLOG(1) << "RestartWithAuth username=" << username_ - << " password=" << password_; - event->socket->RestartWithAuth(username_, password_); + VLOG(1) << "RestartWithAuth username=" << credentials_.username() + << " password=" << credentials_.password(); + event->socket->RestartWithAuth(credentials_); } - void SetAuthInfo(const string16& username, - const string16& password) { - username_ = username; - password_ = password; + void SetAuthInfo(const net::AuthCredentials& credentials) { + credentials_ = credentials; } void CompleteConnection(int result) { connection_callback_->Run(result); @@ -172,9 +170,7 @@ class SocketStreamEventRecorder : public net::SocketStream::Delegate { base::Callback<void(SocketStreamEvent*)> on_error_; net::OldCompletionCallback* callback_; net::OldCompletionCallback* connection_callback_; - - string16 username_; - string16 password_; + net::AuthCredentials credentials_; DISALLOW_COPY_AND_ASSIGN(SocketStreamEventRecorder); }; @@ -374,7 +370,8 @@ TEST_F(SocketStreamTest, BasicAuthProxy) { new SocketStreamEventRecorder(&callback)); delegate->SetOnConnected(base::Bind(&SocketStreamEventRecorder::DoClose, base::Unretained(delegate.get()))); - delegate->SetAuthInfo(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); + delegate->SetAuthInfo(net::AuthCredentials(ASCIIToUTF16("foo"), + ASCIIToUTF16("bar"))); delegate->SetOnAuthRequired(base::Bind( &SocketStreamEventRecorder::DoRestartWithAuth, base::Unretained(delegate.get()))); |