diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 03:27:09 +0000 |
commit | ef2bf421b04de3134cd7c02aac40a5565ef24dd9 (patch) | |
tree | 5bf90cca0bd015c23e843614ebf2e9f99cb8cd99 /net/proxy/proxy_script_fetcher_impl_unittest.cc | |
parent | 280e9b5d4b2fb0fe14824e526521710a658bce56 (diff) | |
download | chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.zip chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.gz chromium_src-ef2bf421b04de3134cd7c02aac40a5565ef24dd9.tar.bz2 |
Stop refcounting URLRequestContext.
While doing so, fix a few issues with the code like ordering of URLRequestContext to ensure correct destruction order. Also fix const correctness in some places.
BUG=58859
TEST=none
TBR=willchan
Review URL: https://chromiumcodereview.appspot.com/10299002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_script_fetcher_impl_unittest.cc')
-rw-r--r-- | net/proxy/proxy_script_fetcher_impl_unittest.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc index 45fcc07..dd95e7e 100644 --- a/net/proxy/proxy_script_fetcher_impl_unittest.cc +++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc @@ -96,10 +96,10 @@ class RequestContext : public URLRequestContext { new CheckNoRevocationFlagSetInterceptor); } - private: - ~RequestContext() { + virtual ~RequestContext() { } + private: URLRequestContextStorage storage_; scoped_ptr<URLRequestJobFactory> url_request_job_factory_; }; @@ -197,22 +197,17 @@ class ProxyScriptFetcherImplTest : public PlatformTest { : test_server_(TestServer::TYPE_HTTP, net::TestServer::kLocalhost, FilePath(kDocRoot)) { - } - - // testing::Test overrides - virtual void SetUp() OVERRIDE { - context_ = new RequestContext; - context_->set_network_delegate(&network_delegate_); + context_.set_network_delegate(&network_delegate_); } protected: TestServer test_server_; BasicNetworkDelegate network_delegate_; - scoped_refptr<URLRequestContext> context_; + RequestContext context_; }; TEST_F(ProxyScriptFetcherImplTest, FileUrl) { - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); { // Fetch a non-existent file. string16 text; @@ -239,7 +234,7 @@ TEST_F(ProxyScriptFetcherImplTest, FileUrl) { TEST_F(ProxyScriptFetcherImplTest, HttpMimeType) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); { // Fetch a PAC with mime type "text/plain" GURL url(test_server_.GetURL("files/pac.txt")); @@ -273,7 +268,7 @@ TEST_F(ProxyScriptFetcherImplTest, HttpMimeType) { TEST_F(ProxyScriptFetcherImplTest, HttpStatusCode) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); { // Fetch a PAC which gives a 500 -- FAIL GURL url(test_server_.GetURL("files/500.pac")); @@ -298,7 +293,7 @@ TEST_F(ProxyScriptFetcherImplTest, HttpStatusCode) { TEST_F(ProxyScriptFetcherImplTest, ContentDisposition) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); // Fetch PAC scripts via HTTP with a Content-Disposition header -- should // have no effect. @@ -314,7 +309,7 @@ TEST_F(ProxyScriptFetcherImplTest, ContentDisposition) { TEST_F(ProxyScriptFetcherImplTest, NoCache) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); // Fetch a PAC script whose HTTP headers make it cacheable for 1 hour. GURL url(test_server_.GetURL("files/cacheable_1hr.pac")); @@ -345,7 +340,7 @@ TEST_F(ProxyScriptFetcherImplTest, NoCache) { TEST_F(ProxyScriptFetcherImplTest, TooLarge) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); // Set the maximum response size to 50 bytes. int prev_size = pac_fetcher.SetSizeConstraint(50); @@ -385,7 +380,7 @@ TEST_F(ProxyScriptFetcherImplTest, TooLarge) { TEST_F(ProxyScriptFetcherImplTest, Hang) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); // Set the timeout period to 0.5 seconds. base::TimeDelta prev_timeout = pac_fetcher.SetTimeoutConstraint( @@ -393,7 +388,8 @@ TEST_F(ProxyScriptFetcherImplTest, Hang) { // Try fetching a URL which takes 1.2 seconds. We should abort the request // after 500 ms, and fail with a timeout error. - { GURL url(test_server_.GetURL("slow/proxy.pac?1.2")); + { + GURL url(test_server_.GetURL("slow/proxy.pac?1.2")); string16 text; TestCompletionCallback callback; int result = pac_fetcher.Fetch(url, &text, callback.callback()); @@ -422,7 +418,7 @@ TEST_F(ProxyScriptFetcherImplTest, Hang) { TEST_F(ProxyScriptFetcherImplTest, Encodings) { ASSERT_TRUE(test_server_.Start()); - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); // Test a response that is gzip-encoded -- should get inflated. { @@ -449,7 +445,7 @@ TEST_F(ProxyScriptFetcherImplTest, Encodings) { } TEST_F(ProxyScriptFetcherImplTest, DataURLs) { - ProxyScriptFetcherImpl pac_fetcher(context_.get()); + ProxyScriptFetcherImpl pac_fetcher(&context_); const char kEncodedUrl[] = "data:application/x-ns-proxy-autoconfig;base64,ZnVuY3Rpb24gRmluZFByb3h5R" |