Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 18546008: [SPDY] Use WeakPtr<SpdySession> everywhere but SpdySessionPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test, other minor formatting/comment changes Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_proxy_client_socket_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | net/http/http_proxy_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698