summaryrefslogtreecommitdiffstats
path: root/net/socket_stream
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket_stream')
-rw-r--r--net/socket_stream/socket_stream.cc23
-rw-r--r--net/socket_stream/socket_stream.h5
-rw-r--r--net/socket_stream/socket_stream_job.cc5
-rw-r--r--net/socket_stream/socket_stream_job.h4
-rw-r--r--net/socket_stream/socket_stream_unittest.cc19
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())));