Index: net/http/http_network_transaction_unittest.cc |
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc |
index e94e4a326f1cab802c82513e57c6d858fc0a3aae..e9723e67b33d881cc5dfebea993f2415b1e2d51e 100644 |
--- a/net/http/http_network_transaction_unittest.cc |
+++ b/net/http/http_network_transaction_unittest.cc |
@@ -63,6 +63,7 @@ |
#include "net/test/cert_test_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "testing/platform_test.h" |
+#include "url/gurl.h" |
//----------------------------------------------------------------------------- |
@@ -8855,7 +8856,7 @@ TEST_P(HttpNetworkTransactionTest, |
HostPortPair host_port_pair("www.google.com", 443); |
SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
kPrivacyModeDisabled); |
- scoped_refptr<SpdySession> spdy_session = |
+ base::WeakPtr<SpdySession> spdy_session = |
CreateSecureSpdySession(session, key, BoundNetLog()); |
trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
@@ -9578,6 +9579,29 @@ TEST_P(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { |
EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
} |
+// A subclass of HttpAuthHandlerMock that records the request URL when |
+// it gets it. This is needed since the auth handler may get destroyed |
+// before we get a chance to query it. |
+class UrlRecordingHttpAuthHandlerMock : public HttpAuthHandlerMock { |
+ public: |
+ explicit UrlRecordingHttpAuthHandlerMock(GURL* url) : url_(url) {} |
+ |
+ virtual ~UrlRecordingHttpAuthHandlerMock() {} |
+ |
+ protected: |
+ virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
+ const HttpRequestInfo* request, |
+ const CompletionCallback& callback, |
+ std::string* auth_token) OVERRIDE { |
+ *url_ = request->url; |
+ return HttpAuthHandlerMock::GenerateAuthTokenImpl( |
+ credentials, request, callback, auth_token); |
+ } |
+ |
+ private: |
+ GURL* url_; |
+}; |
+ |
TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
// This test ensures that the URL passed into the proxy is upgraded |
// to https when doing an Alternate Protocol upgrade. |
@@ -9588,12 +9612,16 @@ TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); |
CapturingNetLog net_log; |
session_deps_.net_log = &net_log; |
- HttpAuthHandlerMock::Factory* auth_factory = |
- new HttpAuthHandlerMock::Factory(); |
- HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
- auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
- auth_factory->set_do_init_from_challenge(true); |
- session_deps_.http_auth_handler_factory.reset(auth_factory); |
+ GURL request_url; |
+ { |
+ HttpAuthHandlerMock::Factory* auth_factory = |
+ new HttpAuthHandlerMock::Factory(); |
+ UrlRecordingHttpAuthHandlerMock* auth_handler = |
+ new UrlRecordingHttpAuthHandlerMock(&request_url); |
+ auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
+ auth_factory->set_do_init_from_challenge(true); |
+ session_deps_.http_auth_handler_factory.reset(auth_factory); |
+ } |
HttpRequestInfo request; |
request.method = "GET"; |
@@ -9724,7 +9752,6 @@ TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
// After all that work, these two lines (or actually, just the scheme) are |
// what this test is all about. Make sure it happens correctly. |
- const GURL& request_url = auth_handler->request_url(); |
EXPECT_EQ("https", request_url.scheme()); |
EXPECT_EQ("www.google.com", request_url.host()); |
@@ -9987,7 +10014,7 @@ TEST_P(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { |
HostPortPair host_port_pair("www.google.com", 443); |
SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
kPrivacyModeDisabled); |
- scoped_refptr<SpdySession> spdy_session = |
+ base::WeakPtr<SpdySession> spdy_session = |
CreateInsecureSpdySession(session, key, BoundNetLog()); |
HttpRequestInfo request; |