Index: net/url_request/url_request_unittest.cc |
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc |
index 25b2b0cc80175cf0af812c832436a4361f0b04f7..fc0645a3b07141b7277336b46c6ff9fbd3185c81 100644 |
--- a/net/url_request/url_request_unittest.cc |
+++ b/net/url_request/url_request_unittest.cc |
@@ -406,23 +406,23 @@ class TestJobInterceptor : public URLRequestJobFactory::Interceptor { |
// Inherit PlatformTest since we require the autorelease pool on Mac OS X.f |
class URLRequestTest : public PlatformTest { |
public: |
- URLRequestTest() : default_context_(new TestURLRequestContext(true)) { |
- default_context_->set_network_delegate(&default_network_delegate_); |
- default_context_->Init(); |
+ URLRequestTest() : default_context_(true) { |
+ default_context_.set_network_delegate(&default_network_delegate_); |
+ default_context_.Init(); |
} |
// Adds the TestJobInterceptor to the default context. |
TestJobInterceptor* AddTestInterceptor() { |
TestJobInterceptor* interceptor = new TestJobInterceptor(); |
- default_context_->set_job_factory(&job_factory_); |
+ default_context_.set_job_factory(&job_factory_); |
job_factory_.AddInterceptor(interceptor); |
return interceptor; |
} |
protected: |
TestNetworkDelegate default_network_delegate_; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> default_context_; |
URLRequestJobFactory job_factory_; |
+ TestURLRequestContext default_context_; |
}; |
class URLRequestTestHTTP : public URLRequestTest { |
@@ -446,8 +446,8 @@ class URLRequestTestHTTP : public URLRequestTest { |
bool include_data) { |
static const char kData[] = "hello world"; |
TestDelegate d; |
- TestURLRequest req(redirect_url, &d); |
- req.set_context(default_context_); |
+ URLRequest req(redirect_url, &d); |
+ req.set_context(&default_context_); |
req.set_method(request_method); |
if (include_data) { |
req.set_upload(CreateSimpleUploadData(kData).get()); |
@@ -493,7 +493,7 @@ class URLRequestTestHTTP : public URLRequestTest { |
for (int i = 0; i < kIterations; ++i) { |
TestDelegate d; |
URLRequest r(test_server_.GetURL("echo"), &d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.set_method(method.c_str()); |
r.AppendBytesToUpload(uploadBytes, kMsgSize); |
@@ -514,7 +514,7 @@ class URLRequestTestHTTP : public URLRequestTest { |
delete[] uploadBytes; |
} |
- void AddChunksToUpload(TestURLRequest* r) { |
+ void AddChunksToUpload(URLRequest* r) { |
r->AppendChunkToUpload("a", 1, false); |
r->AppendChunkToUpload("bcd", 3, false); |
r->AppendChunkToUpload("this is a longer chunk than before.", 35, false); |
@@ -523,7 +523,7 @@ class URLRequestTestHTTP : public URLRequestTest { |
r->AppendChunkToUpload("2323", 4, true); |
} |
- void VerifyReceivedDataMatchesChunks(TestURLRequest* r, TestDelegate* d) { |
+ void VerifyReceivedDataMatchesChunks(URLRequest* r, TestDelegate* d) { |
// This should match the chunks sent by AddChunksToUpload(). |
const char* expected_data = |
"abcdthis is a longer chunk than before.\r\n\r\n02323"; |
@@ -550,15 +550,15 @@ TEST_F(URLRequestTestHTTP, FLAKY_ProxyTunnelRedirectTest) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
TestDelegate d; |
{ |
URLRequest r(GURL("https://www.redirect.com/"), &d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -580,15 +580,15 @@ TEST_F(URLRequestTestHTTP, DISABLED_NetworkDelegateTunnelConnectionFailed) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
TestDelegate d; |
{ |
URLRequest r(GURL("https://www.redirect.com/"), &d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -613,14 +613,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequest) { |
BlockingNetworkDelegate network_delegate; |
network_delegate.set_callback_retval(ERR_EMPTY_RESPONSE); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -641,14 +641,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestSynchronously) { |
BlockingNetworkDelegate network_delegate; |
network_delegate.set_retval(ERR_EMPTY_RESPONSE); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -671,15 +671,15 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) { |
GURL redirect_url(test_server_.GetURL("simple.html")); |
network_delegate.set_redirect_url(redirect_url); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL original_url(test_server_.GetURL("empty.html")); |
- TestURLRequest r(original_url, &d); |
- r.set_context(context); |
+ URLRequest r(original_url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -706,15 +706,15 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestSynchronously) { |
network_delegate.set_redirect_url(redirect_url); |
network_delegate.set_retval(OK); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL original_url(test_server_.GetURL("empty.html")); |
- TestURLRequest r(original_url, &d); |
- r.set_context(context); |
+ URLRequest r(original_url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -741,14 +741,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestPost) { |
GURL redirect_url(test_server_.GetURL("echo")); |
network_delegate.set_redirect_url(redirect_url); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL original_url(test_server_.GetURL("empty.html")); |
- TestURLRequest r(original_url, &d); |
- r.set_context(context); |
+ URLRequest r(original_url, &d); |
+ r.set_context(&context); |
r.set_method("POST"); |
r.set_upload(CreateSimpleUploadData(kData).get()); |
HttpRequestHeaders headers; |
@@ -783,16 +783,16 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncNoAction) { |
network_delegate.set_auth_retval( |
NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
d.set_credentials(AuthCredentials(kUser, kSecret)); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -818,14 +818,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncSetAuth) { |
network_delegate.set_auth_credentials(AuthCredentials(kUser, kSecret)); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -849,14 +849,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncCancel) { |
network_delegate.set_auth_retval( |
NetworkDelegate::AUTH_REQUIRED_RESPONSE_CANCEL_AUTH); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -884,16 +884,16 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncNoAction) { |
network_delegate.set_auth_callback_retval( |
NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
d.set_credentials(AuthCredentials(kUser, kSecret)); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -922,14 +922,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncSetAuth) { |
AuthCredentials auth_credentials(kUser, kSecret); |
network_delegate.set_auth_credentials(auth_credentials); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -956,14 +956,14 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncCancel) { |
network_delegate.set_auth_callback_retval( |
NetworkDelegate::AUTH_REQUIRED_RESPONSE_CANCEL_AUTH); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
GURL url(test_server_.GetURL("auth-basic")); |
- TestURLRequest r(url, &d); |
- r.set_context(context); |
+ URLRequest r(url, &d); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -988,13 +988,13 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting1) { |
network_delegate.BlockOn( |
BlockingNetworkDelegateWithManualCallback::ON_BEFORE_URL_REQUEST); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&context); |
r.Start(); |
network_delegate.WaitForState( |
@@ -1023,13 +1023,13 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting2) { |
network_delegate.BlockOn( |
BlockingNetworkDelegateWithManualCallback::ON_BEFORE_SEND_HEADERS); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&context); |
r.Start(); |
network_delegate.WaitForState( |
@@ -1058,13 +1058,13 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting3) { |
network_delegate.BlockOn( |
BlockingNetworkDelegateWithManualCallback::ON_HEADERS_RECEIVED); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&context); |
r.Start(); |
network_delegate.WaitForState( |
@@ -1093,13 +1093,13 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting4) { |
network_delegate.BlockOn( |
BlockingNetworkDelegateWithManualCallback::ON_AUTH_REQUIRED); |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
{ |
- TestURLRequest r(test_server_.GetURL("auth-basic"), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL("auth-basic"), &d); |
+ r.set_context(&context); |
r.Start(); |
network_delegate.WaitForState( |
@@ -1124,15 +1124,15 @@ TEST_F(URLRequestTestHTTP, UnexpectedServerAuthTest) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->SetProxyFromString(test_server_.host_port_pair().ToString()); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.SetProxyFromString(test_server_.host_port_pair().ToString()); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
TestDelegate d; |
{ |
URLRequest r(GURL("https://www.server-auth.com/"), &d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1149,8 +1149,8 @@ TEST_F(URLRequestTestHTTP, GetTest_NoCache) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1174,8 +1174,8 @@ TEST_F(URLRequestTestHTTP, GetTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1217,13 +1217,12 @@ TEST_F(URLRequestTestHTTP, GetZippedTest) { |
test_parameters[i]); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context( |
- new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
- TestURLRequest r(test_server_.GetURL(test_file), &d); |
- r.set_context(context); |
+ URLRequest r(test_server_.GetURL(test_file), &d); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1261,9 +1260,9 @@ TEST_F(URLRequestTestHTTP, DISABLED_HTTPSToHTTPRedirectNoRefererTest) { |
// server should not be sent the referer. |
GURL http_destination = test_server_.GetURL(""); |
TestDelegate d; |
- TestURLRequest req(https_test_server.GetURL( |
+ URLRequest req(https_test_server.GetURL( |
"server-redirect?" + http_destination.spec()), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.set_referrer("https://www.referrer.com/"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -1283,8 +1282,8 @@ TEST_F(URLRequestTestHTTP, MultipleRedirectTest) { |
GURL original_url = test_server_.GetURL( |
"server-redirect?" + middle_redirect_url.spec()); |
TestDelegate d; |
- TestURLRequest req(original_url, &d); |
- req.set_context(default_context_); |
+ URLRequest req(original_url, &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -1300,15 +1299,15 @@ TEST_F(URLRequestTestHTTP, MultipleRedirectTest) { |
class HTTPSRequestTest : public testing::Test { |
public: |
- HTTPSRequestTest() : default_context_(new TestURLRequestContext(true)) { |
- default_context_->set_network_delegate(&default_network_delegate_); |
- default_context_->Init(); |
+ HTTPSRequestTest() : default_context_(true) { |
+ default_context_.set_network_delegate(&default_network_delegate_); |
+ default_context_.Init(); |
} |
virtual ~HTTPSRequestTest() {} |
protected: |
TestNetworkDelegate default_network_delegate_; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> default_context_; |
+ TestURLRequestContext default_context_; |
}; |
// This test was disabled because it made chrome_frame_net_tests hang |
@@ -1321,8 +1320,8 @@ TEST_F(HTTPSRequestTest, DISABLED_HTTPSGetTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1351,8 +1350,8 @@ TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) { |
TestDelegate d; |
{ |
d.set_allow_certificate_errors(err_allowed); |
- TestURLRequest r(test_server.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1386,8 +1385,8 @@ TEST_F(HTTPSRequestTest, HTTPSExpiredTest) { |
TestDelegate d; |
{ |
d.set_allow_certificate_errors(err_allowed); |
- TestURLRequest r(test_server.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1442,15 +1441,15 @@ static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1"; |
class HTTPSOCSPTest : public HTTPSRequestTest { |
public: |
HTTPSOCSPTest() |
- : context_(new TestURLRequestContext(true)), |
+ : context_(true), |
ev_test_policy_(EVRootCAMetadata::GetInstance(), |
kOCSPTestCertFingerprint, |
kOCSPTestCertPolicy) { |
} |
virtual void SetUp() OVERRIDE { |
- SetupContext(context_); |
- context_->Init(); |
+ SetupContext(&context_); |
+ context_.Init(); |
scoped_refptr<net::X509Certificate> root_cert = |
ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
@@ -1458,7 +1457,7 @@ class HTTPSOCSPTest : public HTTPSRequestTest { |
test_root_.reset(new ScopedTestRoot(root_cert)); |
#if defined(USE_NSS) |
- SetURLRequestContextForNSSHttpIO(context_.get()); |
+ SetURLRequestContextForNSSHttpIO(&context_); |
EnsureNSSHttpIOInit(); |
#endif |
} |
@@ -1472,7 +1471,7 @@ class HTTPSOCSPTest : public HTTPSRequestTest { |
TestDelegate d; |
d.set_allow_certificate_errors(true); |
URLRequest r(test_server.GetURL(""), &d); |
- r.set_context(context_.get()); |
+ r.set_context(&context_); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -1498,7 +1497,7 @@ class HTTPSOCSPTest : public HTTPSRequestTest { |
} |
scoped_ptr<ScopedTestRoot> test_root_; |
- scoped_refptr<TestURLRequestContext> context_; |
+ TestURLRequestContext context_; |
ScopedTestEVPolicy ev_test_policy_; |
}; |
@@ -1735,11 +1734,11 @@ TEST_F(HTTPSRequestTest, SSLv3Fallback) { |
ASSERT_TRUE(test_server.Start()); |
TestDelegate d; |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.Init(); |
d.set_allow_certificate_errors(true); |
URLRequest r(test_server.GetURL(""), &d); |
- r.set_context(context.get()); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -1767,18 +1766,18 @@ TEST_F(HTTPSRequestTest, HTTPSPreloadedHSTSTest) { |
MockHostResolver host_resolver; |
host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->set_host_resolver(&host_resolver); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.set_host_resolver(&host_resolver); |
TransportSecurityState transport_security_state; |
- context->set_transport_security_state(&transport_security_state); |
- context->Init(); |
+ context.set_transport_security_state(&transport_security_state); |
+ context.Init(); |
TestDelegate d; |
- TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
+ URLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
test_server.host_port_pair().port())), |
&d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1810,21 +1809,21 @@ TEST_F(HTTPSRequestTest, HTTPSErrorsNoClobberTSSTest) { |
MockHostResolver host_resolver; |
host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->set_host_resolver(&host_resolver); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.set_host_resolver(&host_resolver); |
TransportSecurityState transport_security_state; |
TransportSecurityState::DomainState domain_state; |
EXPECT_TRUE(transport_security_state.GetDomainState("www.google.com", true, |
&domain_state)); |
- context->set_transport_security_state(&transport_security_state); |
- context->Init(); |
+ context.set_transport_security_state(&transport_security_state); |
+ context.Init(); |
TestDelegate d; |
- TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
+ URLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
test_server.host_port_pair().port())), |
&d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1886,8 +1885,8 @@ TEST_F(HTTPSRequestTest, ClientAuthTest) { |
SSLClientAuthTestDelegate d; |
{ |
- TestURLRequest r(test_server.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1924,8 +1923,8 @@ TEST_F(HTTPSRequestTest, ResumeTest) { |
{ |
TestDelegate d; |
- TestURLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1935,13 +1934,13 @@ TEST_F(HTTPSRequestTest, ResumeTest) { |
EXPECT_EQ(1, d.response_started_count()); |
} |
- reinterpret_cast<HttpCache*>(default_context_->http_transaction_factory())-> |
+ reinterpret_cast<HttpCache*>(default_context_.http_transaction_factory())-> |
CloseAllConnections(); |
{ |
TestDelegate d; |
- TestURLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -1991,8 +1990,8 @@ TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { |
{ |
TestDelegate d; |
- TestURLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2004,26 +2003,26 @@ TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { |
// Now create a new HttpCache with a different ssl_session_cache_shard value. |
HttpNetworkSession::Params params; |
- params.host_resolver = default_context_->host_resolver(); |
- params.cert_verifier = default_context_->cert_verifier(); |
- params.proxy_service = default_context_->proxy_service(); |
- params.ssl_config_service = default_context_->ssl_config_service(); |
+ params.host_resolver = default_context_.host_resolver(); |
+ params.cert_verifier = default_context_.cert_verifier(); |
+ params.proxy_service = default_context_.proxy_service(); |
+ params.ssl_config_service = default_context_.ssl_config_service(); |
params.http_auth_handler_factory = |
- default_context_->http_auth_handler_factory(); |
- params.network_delegate = default_context_->network_delegate(); |
- params.http_server_properties = default_context_->http_server_properties(); |
+ default_context_.http_auth_handler_factory(); |
+ params.network_delegate = default_context_.network_delegate(); |
+ params.http_server_properties = default_context_.http_server_properties(); |
params.ssl_session_cache_shard = "alternate"; |
scoped_ptr<net::HttpCache> cache(new net::HttpCache( |
new net::HttpNetworkSession(params), |
net::HttpCache::DefaultBackend::InMemory(0))); |
- default_context_->set_http_transaction_factory(cache.get()); |
+ default_context_.set_http_transaction_factory(cache.get()); |
{ |
TestDelegate d; |
- TestURLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server.GetURL("ssl-session-cache"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2060,8 +2059,8 @@ TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { |
TEST_F(URLRequestTestHTTP, CancelTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(GURL("http://www.google.com/"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(GURL("http://www.google.com/"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2083,8 +2082,8 @@ TEST_F(URLRequestTestHTTP, CancelTest2) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&default_context_); |
d.set_cancel_in_response_started(true); |
@@ -2105,8 +2104,8 @@ TEST_F(URLRequestTestHTTP, CancelTest3) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&default_context_); |
d.set_cancel_in_received_data(true); |
@@ -2130,8 +2129,8 @@ TEST_F(URLRequestTestHTTP, CancelTest4) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL(""), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL(""), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2158,7 +2157,7 @@ TEST_F(URLRequestTestHTTP, CancelTest5) { |
{ |
TestDelegate d; |
URLRequest r(test_server_.GetURL("cachetime"), &d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
@@ -2168,7 +2167,7 @@ TEST_F(URLRequestTestHTTP, CancelTest5) { |
{ |
TestDelegate d; |
URLRequest r(test_server_.GetURL("cachetime"), &d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
r.Cancel(); |
MessageLoop::current()->Run(); |
@@ -2195,8 +2194,8 @@ TEST_F(URLRequestTestHTTP, PostEmptyTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("echo"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("echo"), &d); |
+ r.set_context(&default_context_); |
r.set_method("POST"); |
r.Start(); |
@@ -2217,8 +2216,8 @@ TEST_F(URLRequestTestHTTP, PostFileTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("echo"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("echo"), &d); |
+ r.set_context(&default_context_); |
r.set_method("POST"); |
FilePath dir; |
@@ -2271,8 +2270,8 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataBeforeStart) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("echo"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("echo"), &d); |
+ r.set_context(&default_context_); |
r.EnableChunkedUpload(); |
r.set_method("POST"); |
AddChunksToUpload(&r); |
@@ -2290,8 +2289,8 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataAfterStart) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("echo"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("echo"), &d); |
+ r.set_context(&default_context_); |
r.EnableChunkedUpload(); |
r.set_method("POST"); |
r.Start(); |
@@ -2308,8 +2307,8 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataAfterStart) { |
TEST_F(URLRequestTest, AboutBlankTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(GURL("about:blank"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(GURL("about:blank"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2328,7 +2327,7 @@ TEST_F(URLRequestTest, DataURLImageTest) { |
TestDelegate d; |
{ |
// Use our nice little Chrome logo. |
- TestURLRequest r(GURL( |
+ URLRequest r(GURL( |
"data:image/png;base64," |
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADVklEQVQ4jX2TfUwUBBjG3" |
"w1y+HGcd9dxhXR8T4awOccJGgOSWclHImznLkTlSw0DDQXkrmgYgbUYnlQTqQxIEVxitD" |
@@ -2349,7 +2348,7 @@ TEST_F(URLRequestTest, DataURLImageTest) { |
"moRWRNZr/F1KfVMjW+IKEnv2FwZfKdzt0BQR6lClcZR0EfEXEfv/G6W9iLiIyCoReV5En" |
"hORIBHx+ufPj/gLB/zGI/G4Bk0AAAAASUVORK5CYII="), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2371,8 +2370,8 @@ TEST_F(URLRequestTest, FileTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(app_url, &d); |
- r.set_context(default_context_); |
+ URLRequest r(app_url, &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2412,8 +2411,8 @@ TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { |
TestDelegate d; |
{ |
- TestURLRequest r(temp_url, &d); |
- r.set_context(default_context_); |
+ URLRequest r(temp_url, &d); |
+ r.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kRange, |
@@ -2457,8 +2456,8 @@ TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { |
TestDelegate d; |
{ |
- TestURLRequest r(temp_url, &d); |
- r.set_context(default_context_); |
+ URLRequest r(temp_url, &d); |
+ r.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kRange, |
@@ -2495,8 +2494,8 @@ TEST_F(URLRequestTest, FileTestMultipleRanges) { |
TestDelegate d; |
{ |
- TestURLRequest r(temp_url, &d); |
- r.set_context(default_context_); |
+ URLRequest r(temp_url, &d); |
+ r.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kRange, |
@@ -2515,8 +2514,8 @@ TEST_F(URLRequestTest, FileTestMultipleRanges) { |
TEST_F(URLRequestTest, InvalidUrlTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(GURL("invalid url"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(GURL("invalid url"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2530,8 +2529,8 @@ TEST_F(URLRequestTestHTTP, ResponseHeadersTest) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("files/with-headers.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("files/with-headers.html"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2592,8 +2591,8 @@ TEST_F(URLRequestTest, ResolveShortcutTest) { |
TestDelegate d; |
{ |
- TestURLRequest r(FilePathToFileURL(FilePath(lnk_path)), &d); |
- r.set_context(default_context_); |
+ URLRequest r(FilePathToFileURL(FilePath(lnk_path)), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -2630,9 +2629,9 @@ TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL( |
+ URLRequest req(test_server_.GetURL( |
"files/content-type-normalization.html"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2657,8 +2656,8 @@ TEST_F(URLRequestTest, FileDirCancelTest) { |
file_path = file_path.Append(FILE_PATH_LITERAL("net")); |
file_path = file_path.Append(FILE_PATH_LITERAL("data")); |
- TestURLRequest req(FilePathToFileURL(file_path), &d); |
- req.set_context(default_context_); |
+ URLRequest req(FilePathToFileURL(file_path), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
EXPECT_TRUE(req.is_pending()); |
@@ -2683,8 +2682,8 @@ TEST_F(URLRequestTest, FileDirRedirectNoCrash) { |
path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); |
TestDelegate d; |
- TestURLRequest req(FilePathToFileURL(path), &d); |
- req.set_context(default_context_); |
+ URLRequest req(FilePathToFileURL(path), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2698,8 +2697,8 @@ TEST_F(URLRequestTest, FileDirRedirectNoCrash) { |
// Don't accept the url "file:///" on windows. See http://crbug.com/1474. |
TEST_F(URLRequestTest, FileDirRedirectSingleSlash) { |
TestDelegate d; |
- TestURLRequest req(GURL("file:///"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("file:///"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2712,9 +2711,9 @@ TEST_F(URLRequestTestHTTP, RestrictRedirects) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL( |
+ URLRequest req(test_server_.GetURL( |
"files/redirect-to-file.html"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2726,9 +2725,9 @@ TEST_F(URLRequestTestHTTP, RedirectToInvalidURL) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL( |
+ URLRequest req(test_server_.GetURL( |
"files/redirect-to-invalid-url.html"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2740,8 +2739,8 @@ TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Referer"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?Referer"), &d); |
+ req.set_context(&default_context_); |
req.set_referrer("http://user:pass@foo.com/"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2755,8 +2754,8 @@ TEST_F(URLRequestTestHTTP, CancelRedirect) { |
TestDelegate d; |
{ |
d.set_cancel_in_received_redirect(true); |
- TestURLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2773,8 +2772,8 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect) { |
TestDelegate d; |
{ |
d.set_quit_on_redirect(true); |
- TestURLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2806,8 +2805,8 @@ TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) { |
TestDelegate d; |
{ |
d.set_quit_on_redirect(true); |
- TestURLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("files/redirect-test.html"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2830,7 +2829,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) { |
{ |
TestDelegate d; |
URLRequest req(test_server_.GetURL("echoheadercache?foo"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader("foo", "1"); |
req.SetExtraRequestHeaders(headers); |
@@ -2842,7 +2841,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) { |
{ |
TestDelegate d; |
URLRequest req(test_server_.GetURL("echoheadercache?foo"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader("foo", "1"); |
req.SetExtraRequestHeaders(headers); |
@@ -2856,7 +2855,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) { |
{ |
TestDelegate d; |
URLRequest req(test_server_.GetURL("echoheadercache?foo"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader("foo", "2"); |
req.SetExtraRequestHeaders(headers); |
@@ -2876,7 +2875,7 @@ TEST_F(URLRequestTestHTTP, BasicAuth) { |
d.set_credentials(AuthCredentials(kUser, kSecret)); |
URLRequest r(test_server_.GetURL("auth-basic"), &d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -2892,7 +2891,7 @@ TEST_F(URLRequestTestHTTP, BasicAuth) { |
d.set_credentials(AuthCredentials(kUser, kSecret)); |
URLRequest r(test_server_.GetURL("auth-basic"), &d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.set_load_flags(LOAD_VALIDATE_CACHE); |
r.Start(); |
@@ -2917,16 +2916,15 @@ TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) { |
// Verify that when the transaction is restarted, it includes the new cookie. |
{ |
TestNetworkDelegate network_delegate; // must outlive URLRequest |
- scoped_refptr<TestURLRequestContext> context( |
- new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
TestDelegate d; |
d.set_credentials(AuthCredentials(kUser, kSecret)); |
URLRequest r(url_requiring_auth, &d); |
- r.set_context(context); |
+ r.set_context(&context); |
r.Start(); |
MessageLoop::current()->Run(); |
@@ -2943,19 +2941,19 @@ TEST_F(URLRequestTest, DelayedCookieCallback) { |
LocalHttpTestServer test_server; |
ASSERT_TRUE(test_server.Start()); |
- scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
+ TestURLRequestContext context; |
scoped_refptr<DelayedCookieMonster> delayed_cm = |
new DelayedCookieMonster(); |
scoped_refptr<CookieStore> cookie_store = delayed_cm; |
- context->set_cookie_store(delayed_cm); |
+ context.set_cookie_store(delayed_cm); |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- context->set_network_delegate(&network_delegate); |
+ context.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
- req.set_context(context); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
@@ -2966,10 +2964,10 @@ TEST_F(URLRequestTest, DelayedCookieCallback) { |
// Verify that the cookie is set. |
{ |
TestNetworkDelegate network_delegate; |
- context->set_network_delegate(&network_delegate); |
+ context.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(context); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -2987,10 +2985,10 @@ TEST_F(URLRequestTest, DoNotSendCookies) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
@@ -3000,10 +2998,10 @@ TEST_F(URLRequestTest, DoNotSendCookies) { |
// Verify that the cookie is set. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3016,11 +3014,11 @@ TEST_F(URLRequestTest, DoNotSendCookies) { |
// Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
req.set_load_flags(LOAD_DO_NOT_SEND_COOKIES); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3032,7 +3030,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) { |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSaveCookies) { |
@@ -3042,10 +3040,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3057,12 +3055,12 @@ TEST_F(URLRequestTest, DoNotSaveCookies) { |
// Try to set-up another cookie and update the previous cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL( |
"set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d); |
req.set_load_flags(LOAD_DO_NOT_SAVE_COOKIES); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3076,10 +3074,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies) { |
// Verify the cookies weren't saved or updated. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3093,7 +3091,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) { |
EXPECT_EQ(0, network_delegate.set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
@@ -3103,10 +3101,10 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3117,10 +3115,10 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
// Verify that the cookie is set. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3134,11 +3132,11 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
// Verify that the cookie isn't sent. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
network_delegate.set_cookie_options(TestNetworkDelegate::NO_GET_COOKIES); |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3149,7 +3147,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
@@ -3159,10 +3157,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3173,12 +3171,12 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
// Try to set-up another cookie and update the previous cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
network_delegate.set_cookie_options(TestNetworkDelegate::NO_SET_COOKIE); |
URLRequest req(test_server.GetURL( |
"set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3191,10 +3189,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
// Verify the cookies weren't saved or updated. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3207,7 +3205,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { |
@@ -3217,10 +3215,10 @@ TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { |
// Set up an empty cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3229,7 +3227,7 @@ TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { |
EXPECT_EQ(0, network_delegate.set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
@@ -3239,10 +3237,10 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3253,10 +3251,10 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
// Verify that the cookie is set. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3270,11 +3268,11 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
// Verify that the cookie isn't sent. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
network_delegate.set_cookie_options(TestNetworkDelegate::NO_GET_COOKIES); |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3285,7 +3283,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
@@ -3295,10 +3293,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3309,12 +3307,12 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
// Try to set-up another cookie and update the previous cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
network_delegate.set_cookie_options(TestNetworkDelegate::NO_SET_COOKIE); |
URLRequest req(test_server.GetURL( |
"set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3326,10 +3324,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
// Verify the cookies weren't saved or updated. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Cookie"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3342,7 +3340,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
} |
void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { |
@@ -3359,12 +3357,12 @@ TEST_F(URLRequestTest, CookiePolicy_ForceSession) { |
// Set up a cookie. |
{ |
TestNetworkDelegate network_delegate; |
- default_context_->set_network_delegate(&network_delegate); |
+ default_context_.set_network_delegate(&network_delegate); |
TestDelegate d; |
network_delegate.set_cookie_options(TestNetworkDelegate::FORCE_SESSION); |
URLRequest req(test_server.GetURL( |
"set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
req.Start(); // Triggers an asynchronous cookie policy check. |
MessageLoop::current()->Run(); |
@@ -3372,11 +3370,11 @@ TEST_F(URLRequestTest, CookiePolicy_ForceSession) { |
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
} |
- default_context_->set_network_delegate(&default_network_delegate_); |
+ default_context_.set_network_delegate(&default_network_delegate_); |
// Now, check the cookie store. |
bool was_run = false; |
- default_context_->cookie_store()->GetCookieMonster()->GetAllCookiesAsync( |
+ default_context_.cookie_store()->GetCookieMonster()->GetAllCookiesAsync( |
base::Bind(&CheckCookiePolicyCallback, &was_run)); |
MessageLoop::current()->RunAllPending(); |
DCHECK(was_run); |
@@ -3392,8 +3390,8 @@ TEST_F(URLRequestTestHTTP, Post302RedirectGet) { |
const char kData[] = "hello world"; |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("files/redirect-to-echoall"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("files/redirect-to-echoall"), &d); |
+ req.set_context(&default_context_); |
req.set_method("POST"); |
req.set_upload(CreateSimpleUploadData(kData)); |
@@ -3479,8 +3477,8 @@ TEST_F(URLRequestTestHTTP, InterceptPost302RedirectGet) { |
const char kData[] = "hello world"; |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("empty.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("empty.html"), &d); |
+ req.set_context(&default_context_); |
req.set_method("POST"); |
req.set_upload(CreateSimpleUploadData(kData).get()); |
HttpRequestHeaders headers; |
@@ -3503,8 +3501,8 @@ TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { |
const char kData[] = "hello world"; |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("empty.html"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("empty.html"), &d); |
+ req.set_context(&default_context_); |
req.set_method("POST"); |
req.set_upload(CreateSimpleUploadData(kData).get()); |
HttpRequestHeaders headers; |
@@ -3723,8 +3721,8 @@ TEST_F(URLRequestTest, Intercept) { |
interceptor.main_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
base::SupportsUserData::Data* user_data0 = new base::SupportsUserData::Data(); |
base::SupportsUserData::Data* user_data1 = new base::SupportsUserData::Data(); |
base::SupportsUserData::Data* user_data2 = new base::SupportsUserData::Data(); |
@@ -3765,8 +3763,8 @@ TEST_F(URLRequestTest, InterceptRedirect) { |
interceptor.redirect_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3799,8 +3797,8 @@ TEST_F(URLRequestTest, InterceptServerError) { |
interceptor.final_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3829,8 +3827,8 @@ TEST_F(URLRequestTest, InterceptNetworkError) { |
interceptor.final_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3859,8 +3857,8 @@ TEST_F(URLRequestTest, InterceptRestartRequired) { |
interceptor.main_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3891,8 +3889,8 @@ TEST_F(URLRequestTest, InterceptRespectsCancelMain) { |
interceptor.final_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3923,8 +3921,8 @@ TEST_F(URLRequestTest, InterceptRespectsCancelRedirect) { |
interceptor.final_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3949,8 +3947,8 @@ TEST_F(URLRequestTest, InterceptRespectsCancelFinal) { |
interceptor.cancel_final_request_ = true; |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -3976,8 +3974,8 @@ TEST_F(URLRequestTest, InterceptRespectsCancelInRestart) { |
interceptor.final_data_ = TestInterceptor::ok_data(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://test_intercept/foo"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("http://test_intercept/foo"), &d); |
+ req.set_context(&default_context_); |
req.set_method("GET"); |
req.Start(); |
MessageLoop::current()->Run(); |
@@ -4007,15 +4005,15 @@ TEST_F(URLRequestTest, NetworkDelegateProxyError) { |
host_resolver.rules()->AddSimulatedFailure("*"); |
TestNetworkDelegate network_delegate; // must outlive URLRequests |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->SetProxyFromString("myproxy:70"); |
- context->set_host_resolver(&host_resolver); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.SetProxyFromString("myproxy:70"); |
+ context.set_host_resolver(&host_resolver); |
+ context.Init(); |
TestDelegate d; |
- TestURLRequest req(GURL("http://example.com"), &d); |
- req.set_context(context); |
+ URLRequest req(GURL("http://example.com"), &d); |
+ req.set_context(&context); |
req.set_method("GET"); |
req.Start(); |
@@ -4041,9 +4039,9 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
// only the latter shall be respected. |
{ |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
+ URLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
req.set_referrer("http://foo.com/"); |
- req.set_context(default_context_); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); |
@@ -4059,8 +4057,8 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
// shall be sent in the header. |
{ |
TestDelegate d; |
- TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); |
@@ -4078,9 +4076,8 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
// content is empty. |
TEST_F(URLRequestTest, RequestCompletionForEmptyResponse) { |
TestDelegate d; |
- TestURLRequest req(GURL("data:,"), &d); |
- req.set_context(new TestURLRequestContext()); |
- req.set_context(default_context_); |
+ URLRequest req(GURL("data:,"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ("", d.data_received()); |
@@ -4103,8 +4100,8 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) { |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("/"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("/"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4130,8 +4127,8 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTestAnonymous) { |
app_path = app_path.AppendASCII("LICENSE"); |
TestDelegate d; |
{ |
- TestURLRequest r(test_server_.GetURL("/LICENSE"), &d); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("/LICENSE"), &d); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4160,10 +4157,10 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTest) { |
app_path = app_path.AppendASCII("LICENSE"); |
TestDelegate d; |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome", "chrome"), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4192,12 +4189,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPassword) { |
app_path = app_path.AppendASCII("LICENSE"); |
TestDelegate d; |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"chrome", |
"wrong_password"), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4225,12 +4222,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPasswordRestart) { |
// the initial login with wrong credentials will fail. |
d.set_credentials(AuthCredentials(kChrome, kChrome)); |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"chrome", |
"wrong_password"), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4255,12 +4252,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUser) { |
app_path = app_path.AppendASCII("LICENSE"); |
TestDelegate d; |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"wrong_user", |
"chrome"), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4288,12 +4285,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUserRestart) { |
// the initial login with wrong credentials will fail. |
d.set_credentials(AuthCredentials(kChrome, kChrome)); |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"wrong_user", |
"chrome"), |
&d); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4320,12 +4317,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) { |
scoped_ptr<TestDelegate> d(new TestDelegate); |
{ |
// Pass correct login identity in the URL. |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"chrome", |
"chrome"), |
d.get()); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4343,8 +4340,8 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) { |
d.reset(new TestDelegate); |
{ |
// This request should use cached identity from previous request. |
- TestURLRequest r(test_server_.GetURL("/LICENSE"), d.get()); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("/LICENSE"), d.get()); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4373,12 +4370,12 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) { |
// the initial login with wrong credentials will fail. |
d->set_credentials(AuthCredentials(kChrome, kChrome)); |
{ |
- TestURLRequest r( |
+ URLRequest r( |
test_server_.GetURLWithUserAndPassword("/LICENSE", |
"chrome", |
"wrong_password"), |
d.get()); |
- r.set_context(default_context_); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4399,8 +4396,8 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) { |
{ |
// Don't pass wrong credentials in the URL, they would override valid cached |
// ones. |
- TestURLRequest r(test_server_.GetURL("/LICENSE"), d.get()); |
- r.set_context(default_context_); |
+ URLRequest r(test_server_.GetURL("/LICENSE"), d.get()); |
+ r.set_context(&default_context_); |
r.Start(); |
EXPECT_TRUE(r.is_pending()); |
@@ -4421,14 +4418,14 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequests |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->set_accept_language("en"); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.set_accept_language("en"); |
+ context.Init(); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
- req.set_context(context); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ("en", d.data_received()); |
@@ -4439,16 +4436,16 @@ TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequests |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
// We override the language after initialization because empty entries |
// get overridden by Init(). |
- context->set_accept_language(""); |
+ context.set_accept_language(""); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
- req.set_context(context); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ("None", d.data_received()); |
@@ -4460,8 +4457,8 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kAcceptLanguage, "ru"); |
req.SetExtraRequestHeaders(headers); |
@@ -4475,8 +4472,8 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptEncoding) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
req.SetExtraRequestHeaders(headers); |
req.Start(); |
@@ -4490,8 +4487,8 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptEncoding) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, "identity"); |
req.SetExtraRequestHeaders(headers); |
@@ -4506,14 +4503,14 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequests |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->set_accept_charset("en"); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.set_accept_charset("en"); |
+ context.Init(); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
- req.set_context(context); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ("en", d.data_received()); |
@@ -4524,16 +4521,16 @@ TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) { |
ASSERT_TRUE(test_server_.Start()); |
TestNetworkDelegate network_delegate; // must outlive URLRequests |
- scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
- context->set_network_delegate(&network_delegate); |
- context->Init(); |
+ TestURLRequestContext context(true); |
+ context.set_network_delegate(&network_delegate); |
+ context.Init(); |
// We override the accepted charset after initialization because empty |
// entries get overridden otherwise. |
- context->set_accept_charset(""); |
+ context.set_accept_charset(""); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
- req.set_context(context); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
+ req.set_context(&context); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ("None", d.data_received()); |
@@ -4545,8 +4542,8 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kAcceptCharset, "koi-8r"); |
req.SetExtraRequestHeaders(headers); |
@@ -4560,8 +4557,8 @@ TEST_F(URLRequestTestHTTP, DefaultUserAgent) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?User-Agent"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?User-Agent"), &d); |
+ req.set_context(&default_context_); |
req.Start(); |
MessageLoop::current()->Run(); |
EXPECT_EQ(req.context()->GetUserAgent(req.url()), d.data_received()); |
@@ -4573,8 +4570,8 @@ TEST_F(URLRequestTestHTTP, OverrideUserAgent) { |
ASSERT_TRUE(test_server_.Start()); |
TestDelegate d; |
- TestURLRequest req(test_server_.GetURL("echoheader?User-Agent"), &d); |
- req.set_context(default_context_); |
+ URLRequest req(test_server_.GetURL("echoheader?User-Agent"), &d); |
+ req.set_context(&default_context_); |
HttpRequestHeaders headers; |
headers.SetHeader(HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); |
req.SetExtraRequestHeaders(headers); |