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

Unified Diff: chrome/browser/prerender/prerender_resource_handler_unittest.cc

Issue 6136006: Fix leak in PrerenderResourceHandlerTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 9 years, 11 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 | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_resource_handler_unittest.cc
diff --git a/chrome/browser/prerender/prerender_resource_handler_unittest.cc b/chrome/browser/prerender/prerender_resource_handler_unittest.cc
index 92ae2e38e77741381f463adad34e4e1652eac220..bb56d5971514243f993e902c1c328cea3d43f66b 100644
--- a/chrome/browser/prerender/prerender_resource_handler_unittest.cc
+++ b/chrome/browser/prerender/prerender_resource_handler_unittest.cc
@@ -87,19 +87,26 @@ class PrerenderResourceHandlerTest : public testing::Test {
protected:
PrerenderResourceHandlerTest()
: prerender_duration_(base::TimeDelta::FromSeconds(10)),
- mock_handler_(new MockResourceHandler()),
ALLOW_THIS_IN_INITIALIZER_LIST(
pre_handler_(new PrerenderResourceHandler(
- mock_handler_,
+ new MockResourceHandler(),
NewCallback(
this,
&PrerenderResourceHandlerTest::SetLastHandledURL)))),
ui_thread_(BrowserThread::UI, &loop_),
+ io_thread_(BrowserThread::IO, &loop_),
default_url_("http://www.prerender.com") {
pre_handler_->set_prerender_duration(prerender_duration_);
pre_handler_->set_get_current_time_function(&FixedGetCurrentTime);
}
+ virtual ~PrerenderResourceHandlerTest() {
+ // ResourceHandler's will post a task to get deleted when their
+ // reference count go to 0.
gavinp 2011/01/18 22:25:06 The grammar above confused me, especially the apos
cbentzel 2011/01/19 13:55:17 I changed the comment to be clearer.
+ pre_handler_ = NULL;
+ loop_.RunAllPending();
+ }
+
void SetLastHandledURL(const GURL& url) {
last_handled_url_ = url;
}
@@ -119,17 +126,16 @@ class PrerenderResourceHandlerTest : public testing::Test {
EXPECT_TRUE(last_handled_url_.is_empty());
// Start the response. If it is able to prerender, a task will
- // be posted to loop_ (masquerading as the UI thread), and
- // |SetLastHandledURL| will be called.
+ // be posted to the UI thread and |SetLastHandledURL| will be called.
EXPECT_TRUE(pre_handler_->OnResponseStarted(request_id, response));
loop_.RunAllPending();
}
base::TimeDelta prerender_duration_;
- scoped_refptr<MockResourceHandler> mock_handler_;
scoped_refptr<PrerenderResourceHandler> pre_handler_;
MessageLoop loop_;
BrowserThread ui_thread_;
+ BrowserThread io_thread_;
GURL last_handled_url_;
GURL default_url_;
};
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698