diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 20:06:52 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 20:06:52 +0000 |
commit | 7bffd08c27787a806bd89529e694ffa3f90883cb (patch) | |
tree | e144b438606c783dc81506534ec5805b00739f44 /net/url_request/url_request_unittest.cc | |
parent | 8d1c406dc8ae48e357ea315df4e9c965eb8a811a (diff) | |
download | chromium_src-7bffd08c27787a806bd89529e694ffa3f90883cb.zip chromium_src-7bffd08c27787a806bd89529e694ffa3f90883cb.tar.gz chromium_src-7bffd08c27787a806bd89529e694ffa3f90883cb.tar.bz2 |
Change the request tracking done by about:net-internals to be per context rather than global accross all contexts.
Before there was a singleton "request tracker" (URLRequest::InstanceTracker) that kept track of all outstanding requests and recently completed.
Whereas now, each URLRequestContext gets its own "request tracker" (URLRequestTracker) to track the requests associated with that context.
This change is to limit the lifetime of information relating to incognito windows. Before you were able to see the recent requests issued by incognito windows even after the last incognito windows was closed (by loading about:net-internals in a non-incognito window).
Whereas now you can only see the incognito requests information by loading "about:net-internals" within an incognito tab. And once the last incognito tab is closed, the OTR context is destroyed, which in turn destroys any profiling information that was being stored.
BUG=24630
Review URL: http://codereview.chromium.org/295050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29804 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_unittest.cc')
-rw-r--r-- | net/url_request/url_request_unittest.cc | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 21fd22b..0693ac1 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -120,10 +120,6 @@ scoped_refptr<net::UploadData> CreateSimpleUploadData(const char* data) { // Inherit PlatformTest since we require the autorelease pool on Mac OS X.f class URLRequestTest : public PlatformTest { - public: - ~URLRequestTest() { - EXPECT_EQ(0u, URLRequest::InstanceTracker::Get()->GetLiveRequests().size()); - } }; class URLRequestTestHTTP : public URLRequestTest { @@ -234,109 +230,6 @@ TEST_F(URLRequestTestHTTP, GetTest) { } } -// Test the instance tracking functionality of URLRequest. -TEST_F(URLRequestTest, Tracking) { - URLRequest::InstanceTracker::Get()->ClearRecentlyDeceased(); - EXPECT_EQ(0u, URLRequest::InstanceTracker::Get()->GetLiveRequests().size()); - EXPECT_EQ(0u, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); - - { - URLRequest req1(GURL("http://req1"), NULL); - URLRequest req2(GURL("http://req2"), NULL); - URLRequest req3(GURL("http://req3"), NULL); - - std::vector<URLRequest*> live_reqs = - URLRequest::InstanceTracker::Get()->GetLiveRequests(); - ASSERT_EQ(3u, live_reqs.size()); - EXPECT_EQ(GURL("http://req1"), live_reqs[0]->original_url()); - EXPECT_EQ(GURL("http://req2"), live_reqs[1]->original_url()); - EXPECT_EQ(GURL("http://req3"), live_reqs[2]->original_url()); - } - - EXPECT_EQ(0u, URLRequest::InstanceTracker::Get()->GetLiveRequests().size()); - - URLRequest::InstanceTracker::RecentRequestInfoList recent_reqs = - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased(); - - // Note that the order is reversed from definition order, because - // this matches the destructor order. - ASSERT_EQ(3u, recent_reqs.size()); - EXPECT_EQ(GURL("http://req3"), recent_reqs[0].original_url); - EXPECT_EQ(GURL("http://req2"), recent_reqs[1].original_url); - EXPECT_EQ(GURL("http://req1"), recent_reqs[2].original_url); -} - -// Test the instance tracking functionality of URLRequest. -TEST_F(URLRequestTest, TrackingGraveyardBounded) { - URLRequest::InstanceTracker::Get()->ClearRecentlyDeceased(); - EXPECT_EQ(0u, URLRequest::InstanceTracker::Get()->GetLiveRequests().size()); - EXPECT_EQ(0u, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); - - const size_t kMaxGraveyardSize = - URLRequest::InstanceTracker::kMaxGraveyardSize; - const size_t kMaxURLLen = URLRequest::InstanceTracker::kMaxGraveyardURLSize; - - // Add twice as many requests as will fit in the graveyard. - for (size_t i = 0; i < kMaxGraveyardSize * 2; ++i) - URLRequest req(GURL(StringPrintf("http://req%d", i).c_str()), NULL); - - // Check that only the last |kMaxGraveyardSize| requests are in-memory. - - URLRequest::InstanceTracker::RecentRequestInfoList recent_reqs = - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased(); - - ASSERT_EQ(kMaxGraveyardSize, recent_reqs.size()); - - for (size_t i = 0; i < kMaxGraveyardSize; ++i) { - size_t req_number = i + kMaxGraveyardSize; - GURL url(StringPrintf("http://req%d", req_number).c_str()); - EXPECT_EQ(url, recent_reqs[i].original_url); - } - - URLRequest::InstanceTracker::Get()->ClearRecentlyDeceased(); - EXPECT_EQ(0u, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); - - // Check that very long URLs are truncated. - std::string big_url_spec("http://"); - big_url_spec.resize(2 * kMaxURLLen, 'x'); - GURL big_url(big_url_spec); - { - URLRequest req(big_url, NULL); - } - ASSERT_EQ(1u, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); - // The +1 is because GURL canonicalizes with a trailing '/' ... maybe - // we should just save the std::string rather than the GURL. - EXPECT_EQ(kMaxURLLen + 1, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased()[0] - .original_url.spec().size()); -} - -// Test the instance tracking functionality of URLRequest does not -// fail if the URL was invalid. http://crbug.com/21423. -TEST_F(URLRequestTest, TrackingInvalidURL) { - URLRequest::InstanceTracker::Get()->ClearRecentlyDeceased(); - EXPECT_EQ(0u, URLRequest::InstanceTracker::Get()->GetLiveRequests().size()); - EXPECT_EQ(0u, - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); - - { - GURL invalid_url("xabc"); - EXPECT_FALSE(invalid_url.is_valid()); - URLRequest req(invalid_url, NULL); - } - - // Check that the invalid URL made it into graveyard. - URLRequest::InstanceTracker::RecentRequestInfoList recent_reqs = - URLRequest::InstanceTracker::Get()->GetRecentlyDeceased(); - - ASSERT_EQ(1u, recent_reqs.size()); - EXPECT_FALSE(recent_reqs[0].original_url.is_valid()); -} - TEST_F(URLRequestTest, QuitTest) { // Don't use shared server here because we order it to quit. // It would impact other tests. |