summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 01:01:38 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 01:01:38 +0000
commit69ae835f4346c41cac6118c9b8b6429cc594f786 (patch)
tree2db4b6068ce6f6003e75d925613edcdf465be4d0 /content/common
parentf4c1ca41a01215980aab846adf6eacd8dcc2e7db (diff)
downloadchromium_src-69ae835f4346c41cac6118c9b8b6429cc594f786.zip
chromium_src-69ae835f4346c41cac6118c9b8b6429cc594f786.tar.gz
chromium_src-69ae835f4346c41cac6118c9b8b6429cc594f786.tar.bz2
base::Bind() cleanup in URLFetcherImpl test.
BUG=none TEST=content_unittests --gtest_filter=URLFetcher* Review URL: http://codereview.chromium.org/8885002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/net/url_fetcher_impl_unittest.cc36
1 files changed, 12 insertions, 24 deletions
diff --git a/content/common/net/url_fetcher_impl_unittest.cc b/content/common/net/url_fetcher_impl_unittest.cc
index aae975e..c00d33d 100644
--- a/content/common/net/url_fetcher_impl_unittest.cc
+++ b/content/common/net/url_fetcher_impl_unittest.cc
@@ -326,24 +326,6 @@ TEST_F(URLFetcherTempFileTest, CanTakeOwnershipOfFile) {
<< temp_file_.value() << " not removed.";
}
-// Wrapper that lets us call CreateFetcher() on a thread of our choice. We
-// could make URLFetcherTest refcounted and use PostTask(FROM_HERE.. ) to call
-// CreateFetcher() directly, but the ownership of the URLFetcherTest is a bit
-// confusing in that case because GTest doesn't know about the refcounting.
-// It's less confusing to just do it this way.
-class FetcherWrapperTask : public Task {
- public:
- FetcherWrapperTask(URLFetcherTest* test, const GURL& url)
- : test_(test), url_(url) { }
- virtual void Run() {
- test_->CreateFetcher(url_);
- }
-
- private:
- URLFetcherTest* test_;
- GURL url_;
-};
-
void URLFetcherPostTest::CreateFetcher(const GURL& url) {
fetcher_ = new URLFetcherImpl(url, content::URLFetcher::POST, this);
fetcher_->SetRequestContext(new TestURLRequestContextGetter(
@@ -571,8 +553,11 @@ TEST_F(URLFetcherTest, DifferentThreadsTest) {
// scope.
base::Thread t("URLFetcher test thread");
ASSERT_TRUE(t.Start());
- t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this,
- test_server.GetURL("defaultresponse")));
+ t.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&URLFetcherTest::CreateFetcher,
+ base::Unretained(this),
+ test_server.GetURL("defaultresponse")));
MessageLoop::current()->Run();
}
@@ -726,7 +711,9 @@ TEST_F(URLFetcherCancelTest, ReleasesContext) {
// scope.
base::Thread t("URLFetcher test thread");
ASSERT_TRUE(t.Start());
- t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url));
+ t.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&URLFetcherTest::CreateFetcher, base::Unretained(this), url));
MessageLoop::current()->Run();
@@ -757,7 +744,9 @@ TEST_F(URLFetcherCancelTest, CancelWhileDelayedStartTaskPending) {
base::Thread t("URLFetcher test thread");
ASSERT_TRUE(t.Start());
- t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url));
+ t.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&URLFetcherTest::CreateFetcher, base::Unretained(this), url));
MessageLoop::current()->Run();
@@ -792,8 +781,7 @@ TEST_F(URLFetcherTest, CancelAll) {
io_message_loop_proxy()->PostTaskAndReply(
FROM_HERE,
base::Bind(&CancelAllOnIO),
- base::Bind(&MessageLoop::Quit,
- base::Unretained(MessageLoop::current())));
+ MessageLoop::QuitClosure());
MessageLoop::current()->Run();
EXPECT_EQ(0, GetNumFetcherCores());
delete fetcher_;