summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/callback_internal.h12
-rw-r--r--base/task_runner_util_unittest.cc31
2 files changed, 37 insertions, 6 deletions
diff --git a/base/callback_internal.h b/base/callback_internal.h
index 92ea80a..56d88a3 100644
--- a/base/callback_internal.h
+++ b/base/callback_internal.h
@@ -143,10 +143,10 @@ struct CallbackParamTraits<scoped_array<T> > {
typedef scoped_array<T> StorageType;
};
-template <typename T>
-struct CallbackParamTraits<scoped_ptr_malloc<T> > {
- typedef scoped_ptr_malloc<T> ForwardType;
- typedef scoped_ptr_malloc<T> StorageType;
+template <typename T, typename R>
+struct CallbackParamTraits<scoped_ptr_malloc<T, R> > {
+ typedef scoped_ptr_malloc<T, R> ForwardType;
+ typedef scoped_ptr_malloc<T, R> StorageType;
};
template <typename T>
@@ -180,8 +180,8 @@ scoped_ptr<T> CallbackForward(scoped_ptr<T>& p) { return p.Pass(); }
template <typename T>
scoped_array<T> CallbackForward(scoped_array<T>& p) { return p.Pass(); }
-template <typename T>
-scoped_ptr_malloc<T> CallbackForward(scoped_ptr_malloc<T>& p) {
+template <typename T, typename R>
+scoped_ptr_malloc<T, R> CallbackForward(scoped_ptr_malloc<T, R>& p) {
return p.Pass();
}
diff --git a/base/task_runner_util_unittest.cc b/base/task_runner_util_unittest.cc
index daed770..eba3bd6 100644
--- a/base/task_runner_util_unittest.cc
+++ b/base/task_runner_util_unittest.cc
@@ -21,6 +21,7 @@ void StoreValue(int* destination, int value) {
}
int g_foo_destruct_count = 0;
+int g_foo_free_count = 0;
struct Foo {
~Foo() {
@@ -39,6 +40,23 @@ void ExpectFoo(scoped_ptr<Foo> foo) {
EXPECT_FALSE(foo.get());
}
+struct FreeFooFunctor {
+ void operator()(Foo* foo) const {
+ ++g_foo_free_count;
+ };
+};
+
+scoped_ptr_malloc<Foo, FreeFooFunctor> CreateScopedFoo() {
+ return scoped_ptr_malloc<Foo, FreeFooFunctor>(new Foo);
+}
+
+void ExpectScopedFoo(scoped_ptr_malloc<Foo, FreeFooFunctor> foo) {
+ EXPECT_TRUE(foo.get());
+ scoped_ptr_malloc<Foo, FreeFooFunctor> local_foo(foo.Pass());
+ EXPECT_TRUE(local_foo.get());
+ EXPECT_FALSE(foo.get());
+}
+
} // namespace
TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResult) {
@@ -58,6 +76,7 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResult) {
TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassed) {
g_foo_destruct_count = 0;
+ g_foo_free_count = 0;
MessageLoop message_loop;
@@ -70,6 +89,18 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassed) {
message_loop.RunAllPending();
EXPECT_EQ(1, g_foo_destruct_count);
+ EXPECT_EQ(0, g_foo_free_count);
+
+ PostTaskAndReplyWithResult(
+ message_loop.message_loop_proxy(),
+ FROM_HERE,
+ Bind(&CreateScopedFoo),
+ Bind(&ExpectScopedFoo));
+
+ message_loop.RunAllPending();
+
+ EXPECT_EQ(1, g_foo_destruct_count);
+ EXPECT_EQ(1, g_foo_free_count);
}
} // namespace base