summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorgroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 19:14:36 +0000
committergroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 19:14:36 +0000
commit315e7c893a7a87a908c936815fd434608c0d447e (patch)
treea77be42569108a697ddf1ffce5d67a05466d3af8 /net
parent3a5a78231314e451edb16644917536071a8cf7e3 (diff)
downloadchromium_src-315e7c893a7a87a908c936815fd434608c0d447e.zip
chromium_src-315e7c893a7a87a908c936815fd434608c0d447e.tar.gz
chromium_src-315e7c893a7a87a908c936815fd434608c0d447e.tar.bz2
base::Bind fixes - killing OldCompletionCallback
TBR=eroman@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/9023014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115729 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/test_completion_callback.cc4
-rw-r--r--net/base/test_completion_callback.h12
-rw-r--r--net/base/test_completion_callback_unittest.cc19
3 files changed, 10 insertions, 25 deletions
diff --git a/net/base/test_completion_callback.cc b/net/base/test_completion_callback.cc
index aa04d22..d68678b 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -43,10 +43,6 @@ TestCompletionCallbackBase::TestCompletionCallbackBase()
waiting_for_result_(false) {
}
-void TestOldCompletionCallback::RunWithParams(const Tuple1<int>& params) {
- SetResult(params.a);
-}
-
namespace net {
TestCompletionCallback::TestCompletionCallback()
diff --git a/net/base/test_completion_callback.h b/net/base/test_completion_callback.h
index 5dff389..ac3463f 100644
--- a/net/base/test_completion_callback.h
+++ b/net/base/test_completion_callback.h
@@ -42,18 +42,6 @@ class TestCompletionCallbackBase {
DISALLOW_COPY_AND_ASSIGN(TestCompletionCallbackBase);
};
-class TestOldCompletionCallback : public TestCompletionCallbackBase,
- public CallbackRunner<Tuple1<int> > {
- public:
- TestOldCompletionCallback() {};
- virtual ~TestOldCompletionCallback() {}
-
- virtual void RunWithParams(const Tuple1<int>& params) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestOldCompletionCallback);
-};
-
namespace net {
class TestCompletionCallback : public TestCompletionCallbackBase {
diff --git a/net/base/test_completion_callback_unittest.cc b/net/base/test_completion_callback_unittest.cc
index 3d2aa01..3c0fc1c 100644
--- a/net/base/test_completion_callback_unittest.cc
+++ b/net/base/test_completion_callback_unittest.cc
@@ -13,7 +13,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
-typedef PlatformTest TestOldCompletionCallbackTest;
+typedef PlatformTest TestCompletionCallbackTest;
using net::OldCompletionCallback;
@@ -30,7 +30,7 @@ class ExampleEmployer {
// Do some imaginary work on a worker thread;
// when done, worker posts callback on the original thread.
// Returns true on success
- bool DoSomething(OldCompletionCallback* callback);
+ bool DoSomething(const net::CompletionCallback& callback);
private:
class ExampleWorker;
@@ -43,7 +43,8 @@ class ExampleEmployer {
class ExampleEmployer::ExampleWorker
: public base::RefCountedThreadSafe<ExampleWorker> {
public:
- ExampleWorker(ExampleEmployer* employer, OldCompletionCallback* callback)
+ ExampleWorker(ExampleEmployer* employer,
+ const net::CompletionCallback& callback)
: employer_(employer), callback_(callback),
origin_loop_(MessageLoop::current()) {
}
@@ -56,7 +57,7 @@ class ExampleEmployer::ExampleWorker
// Only used on the origin thread (where DoSomething was called).
ExampleEmployer* employer_;
- OldCompletionCallback* callback_;
+ net::CompletionCallback callback_;
// Used to post ourselves onto the origin thread.
base::Lock origin_loop_lock_;
MessageLoop* origin_loop_;
@@ -85,7 +86,7 @@ void ExampleEmployer::ExampleWorker::DoCallback() {
// destroyed.
employer_->request_ = NULL;
- callback_->Run(kMagicResult);
+ callback_.Run(kMagicResult);
}
ExampleEmployer::ExampleEmployer() {
@@ -94,7 +95,7 @@ ExampleEmployer::ExampleEmployer() {
ExampleEmployer::~ExampleEmployer() {
}
-bool ExampleEmployer::DoSomething(OldCompletionCallback* callback) {
+bool ExampleEmployer::DoSomething(const net::CompletionCallback& callback) {
DCHECK(!request_) << "already in use";
request_ = new ExampleWorker(this, callback);
@@ -112,10 +113,10 @@ bool ExampleEmployer::DoSomething(OldCompletionCallback* callback) {
return true;
}
-TEST_F(TestOldCompletionCallbackTest, Simple) {
+TEST_F(TestCompletionCallbackTest, Simple) {
ExampleEmployer boss;
- TestOldCompletionCallback callback;
- bool queued = boss.DoSomething(&callback);
+ net::TestCompletionCallback callback;
+ bool queued = boss.DoSomething(callback.callback());
EXPECT_EQ(queued, true);
int result = callback.WaitForResult();
EXPECT_EQ(result, kMagicResult);