And now NewRunnableMethod(), you die.

Kill off NewRunnableMethod() and remove silly declarations of unused ScopedRunnableMethodFactory(s).

BUG=none
TEST=existing.

Review URL: http://codereview.chromium.org/9034032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116250 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/callback.h b/base/callback.h
index 84abef9..ab8f7bb 100644
--- a/base/callback.h
+++ b/base/callback.h
@@ -3,7 +3,7 @@
 // DO NOT EDIT BY HAND!!!
 
 
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -18,10 +18,6 @@
 // NOTE: Header files that do not require the full definition of Callback or
 // Closure should #include "base/callback_forward.h" instead of this file.
 
-// New, super-duper, unified Callback system.  This will eventually replace
-// NewRunnableMethod, CreateFunctor, and CreateCallback systems currently in the
-// Chromium code base.
-//
 // WHAT IS THIS:
 //
 // The templated Callback class is a generalized function object. Together
diff --git a/base/callback.h.pump b/base/callback.h.pump
index cab7a389..ef65e83 100644
--- a/base/callback.h.pump
+++ b/base/callback.h.pump
@@ -8,7 +8,7 @@
 $$ See comment for MAX_ARITY in base/bind.h.pump.
 $var MAX_ARITY = 7
 
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -23,10 +23,6 @@
 // NOTE: Header files that do not require the full definition of Callback or
 // Closure should #include "base/callback_forward.h" instead of this file.
 
-// New, super-duper, unified Callback system.  This will eventually replace
-// NewRunnableMethod, CreateFunctor, and CreateCallback systems currently in the
-// Chromium code base.
-//
 // WHAT IS THIS:
 //
 // The templated Callback class is a generalized function object. Together
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index 01a57c8..e528286 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -81,38 +81,6 @@
   std::string result_;
 };
 
-// TODO(ajwong): Remove this once we've finished getting rid of the PostTask()
-// compatibility methods.
-void RunTest_PostLegacyTask(MessageLoop::Type message_loop_type) {
-  MessageLoop loop(message_loop_type);
-
-  // Add tests to message loop
-  scoped_refptr<Foo> foo(new Foo());
-  std::string a("a"), b("b"), c("c"), d("d");
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-      foo.get(), &Foo::Test0));
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-    foo.get(), &Foo::Test1ConstRef, a));
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-      foo.get(), &Foo::Test1Ptr, &b));
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-      foo.get(), &Foo::Test1Int, 100));
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-      foo.get(), &Foo::Test2Ptr, &a, &c));
-  MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
-    foo.get(), &Foo::Test2Mixed, a, &d));
-
-  // After all tests, post a message that will shut down the message loop
-  MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
-      &MessageLoop::Quit, base::Unretained(MessageLoop::current())));
-
-  // Now kick things off
-  MessageLoop::current()->Run();
-
-  EXPECT_EQ(foo->test_count(), 105);
-  EXPECT_EQ(foo->result(), "abacad");
-}
-
 void RunTest_PostTask(MessageLoop::Type message_loop_type) {
   MessageLoop loop(message_loop_type);
 
@@ -1299,12 +1267,6 @@
 // that message loops work properly in all configurations.  Of course, in some
 // cases, a unit test may only be for a particular type of loop.
 
-TEST(MessageLoopTest, PostLegacyTask) {
-  RunTest_PostLegacyTask(MessageLoop::TYPE_DEFAULT);
-  RunTest_PostLegacyTask(MessageLoop::TYPE_UI);
-  RunTest_PostLegacyTask(MessageLoop::TYPE_IO);
-}
-
 TEST(MessageLoopTest, PostTask) {
   RunTest_PostTask(MessageLoop::TYPE_DEFAULT);
   RunTest_PostTask(MessageLoop::TYPE_UI);
diff --git a/base/message_pump_glib_unittest.cc b/base/message_pump_glib_unittest.cc
index 5286c666..467088c 100644
--- a/base/message_pump_glib_unittest.cc
+++ b/base/message_pump_glib_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -188,9 +188,6 @@
 
 }  // namespace
 
-// EventInjector is expected to always live longer than the runnable methods.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(EventInjector);
-
 TEST_F(MessagePumpGLibTest, TestQuit) {
   // Checks that Quit works and that the basic infrastructure is working.
 
diff --git a/base/task.h b/base/task.h
index 9666a65c..f22300a 100644
--- a/base/task.h
+++ b/base/task.h
@@ -70,231 +70,9 @@
   delete obj;
 }
 
-// RunnableMethodTraits --------------------------------------------------------
-//
-// This traits-class is used by RunnableMethod to manage the lifetime of the
-// callee object.  By default, it is assumed that the callee supports AddRef
-// and Release methods.  A particular class can specialize this template to
-// define other lifetime management.  For example, if the callee is known to
-// live longer than the RunnableMethod object, then a RunnableMethodTraits
-// struct could be defined with empty RetainCallee and ReleaseCallee methods.
-//
-// The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way
-// for declaring a RunnableMethodTraits that disables refcounting.
-
-template <class T>
-struct RunnableMethodTraits {
-  RunnableMethodTraits() {
-#ifndef NDEBUG
-    origin_thread_id_ = base::PlatformThread::CurrentId();
-#endif
-  }
-
-  ~RunnableMethodTraits() {
-#ifndef NDEBUG
-    // If destroyed on a separate thread, then we had better have been using
-    // thread-safe reference counting!
-    if (origin_thread_id_ != base::PlatformThread::CurrentId())
-      DCHECK(T::ImplementsThreadSafeReferenceCounting());
-#endif
-  }
-
-  void RetainCallee(T* obj) {
-#ifndef NDEBUG
-    // Catch NewRunnableMethod being called in an object's constructor.  This
-    // isn't safe since the method can be invoked before the constructor
-    // completes, causing the object to be deleted.
-    obj->AddRef();
-    obj->Release();
-#endif
-    obj->AddRef();
-  }
-
-  void ReleaseCallee(T* obj) {
-    obj->Release();
-  }
-
- private:
-#ifndef NDEBUG
-  base::PlatformThreadId origin_thread_id_;
-#endif
-};
-
-// Convenience macro for declaring a RunnableMethodTraits that disables
-// refcounting of a class.  This is useful if you know that the callee
-// will outlive the RunnableMethod object and thus do not need the ref counts.
-//
-// The invocation of DISABLE_RUNNABLE_METHOD_REFCOUNT should be done at the
-// global namespace scope.  Example:
-//
-//   namespace foo {
-//   class Bar {
-//     ...
-//   };
-//   }  // namespace foo
-//
-//   DISABLE_RUNNABLE_METHOD_REFCOUNT(foo::Bar);
-//
-// This is different from DISALLOW_COPY_AND_ASSIGN which is declared inside the
-// class.
-#define DISABLE_RUNNABLE_METHOD_REFCOUNT(TypeName) \
-  template <>                                      \
-  struct RunnableMethodTraits<TypeName> {          \
-    void RetainCallee(TypeName* manager) {}        \
-    void ReleaseCallee(TypeName* manager) {}       \
-  }
-
-// RunnableMethod --------------------------------------------------------------
-//
-// Runnable methods are a type of task that call a function on an object when
-// they are run. We implement both an object and a set of NewRunnableMethod
-// functions for convenience. These functions are overloaded and will infer the
-// template types, simplifying calling code.
-//
-// The template definitions all use the following names:
-// T                - the class type of the object you're supplying
-//                    this is not needed for the Static version of the call
-// Method/Function  - the signature of a pointer to the method or function you
-//                    want to call
-// Param            - the parameter(s) to the method, possibly packed as a Tuple
-// A                - the first parameter (if any) to the method
-// B                - the second parameter (if any) to the method
-//
-// Put these all together and you get an object that can call a method whose
-// signature is:
-//   R T::MyFunction([A[, B]])
-//
-// Usage:
-// PostTask(FROM_HERE, NewRunnableMethod(object, &Object::method[, a[, b]])
-
-// RunnableMethod and NewRunnableMethod implementation -------------------------
-
-template <class T, class Method, class Params>
-class RunnableMethod : public CancelableTask {
- public:
-  RunnableMethod(T* obj, Method meth, const Params& params)
-      : obj_(obj), meth_(meth), params_(params) {
-    traits_.RetainCallee(obj_);
-    COMPILE_ASSERT(
-        (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value),
-        badrunnablemethodparams);
-  }
-
-  ~RunnableMethod() {
-    ReleaseCallee();
-    obj_ = reinterpret_cast<T*>(base::kDeadTask);
-  }
-
-  virtual void Run() {
-    if (obj_)
-      DispatchToMethod(obj_, meth_, params_);
-  }
-
-  virtual void Cancel() {
-    ReleaseCallee();
-  }
-
- private:
-  void ReleaseCallee() {
-    T* obj = obj_;
-    obj_ = NULL;
-    if (obj)
-      traits_.ReleaseCallee(obj);
-  }
-
-  T* obj_;
-  Method meth_;
-  Params params_;
-  RunnableMethodTraits<T> traits_;
-};
-
-template <class T, class Method>
-inline CancelableTask* NewRunnableMethod(T* object, Method method) {
-  return new RunnableMethod<T, Method, Tuple0>(object, method, MakeTuple());
-}
-
-template <class T, class Method, class A>
-inline CancelableTask* NewRunnableMethod(T* object, Method method, const A& a) {
-  return new RunnableMethod<T, Method, Tuple1<A> >(object,
-                                                   method,
-                                                   MakeTuple(a));
-}
-
-template <class T, class Method, class A, class B>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-const A& a, const B& b) {
-  return new RunnableMethod<T, Method, Tuple2<A, B> >(object, method,
-                                                      MakeTuple(a, b));
-}
-
-template <class T, class Method, class A, class B, class C>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                          const A& a, const B& b, const C& c) {
-  return new RunnableMethod<T, Method, Tuple3<A, B, C> >(object, method,
-                                                         MakeTuple(a, b, c));
-}
-
-template <class T, class Method, class A, class B, class C, class D>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                          const A& a, const B& b,
-                                          const C& c, const D& d) {
-  return new RunnableMethod<T, Method, Tuple4<A, B, C, D> >(object, method,
-                                                            MakeTuple(a, b,
-                                                                      c, d));
-}
-
-template <class T, class Method, class A, class B, class C, class D, class E>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                          const A& a, const B& b,
-                                          const C& c, const D& d, const E& e) {
-  return new RunnableMethod<T,
-                            Method,
-                            Tuple5<A, B, C, D, E> >(object,
-                                                    method,
-                                                    MakeTuple(a, b, c, d, e));
-}
-
-template <class T, class Method, class A, class B, class C, class D, class E,
-          class F>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                          const A& a, const B& b,
-                                          const C& c, const D& d, const E& e,
-                                          const F& f) {
-  return new RunnableMethod<T,
-                            Method,
-                            Tuple6<A, B, C, D, E, F> >(object,
-                                                       method,
-                                                       MakeTuple(a, b, c, d, e,
-                                                                 f));
-}
-
-template <class T, class Method, class A, class B, class C, class D, class E,
-          class F, class G>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                         const A& a, const B& b,
-                                         const C& c, const D& d, const E& e,
-                                         const F& f, const G& g) {
-  return new RunnableMethod<T,
-                            Method,
-                            Tuple7<A, B, C, D, E, F, G> >(object,
-                                                          method,
-                                                          MakeTuple(a, b, c, d,
-                                                                    e, f, g));
-}
-
-template <class T, class Method, class A, class B, class C, class D, class E,
-          class F, class G, class H>
-inline CancelableTask* NewRunnableMethod(T* object, Method method,
-                                         const A& a, const B& b,
-                                         const C& c, const D& d, const E& e,
-                                         const F& f, const G& g, const H& h) {
-  return new RunnableMethod<T,
-                            Method,
-                            Tuple8<A, B, C, D, E, F, G, H> >(object,
-                                                             method,
-                                                             MakeTuple(a, b, c,
-                                                                       d, e, f,
-                                                                       g, h));
+template<typename T>
+void ReleasePointer(T* obj) {
+  obj->Release();
 }
 
 namespace base {
diff --git a/base/task_unittest.cc b/base/task_unittest.cc
index f192415..956e77f 100644
--- a/base/task_unittest.cc
+++ b/base/task_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -9,47 +9,6 @@
 
 namespace {
 
-class CancelInDestructor : public base::RefCounted<CancelInDestructor> {
- public:
-  CancelInDestructor() : cancelable_task_(NULL) {}
-
-  void Start() {
-    if (cancelable_task_) {
-      ADD_FAILURE();
-      return;
-    }
-    AddRef();
-    cancelable_task_ = NewRunnableMethod(
-        this, &CancelInDestructor::NeverIssuedCallback);
-    Release();
-  }
-
-  CancelableTask* cancelable_task() {
-    return cancelable_task_;
-  }
-
- private:
-  friend class base::RefCounted<CancelInDestructor>;
-
-  ~CancelInDestructor() {
-    if (cancelable_task_)
-      cancelable_task_->Cancel();
-  }
-
-  void NeverIssuedCallback() { NOTREACHED(); }
-
-  CancelableTask* cancelable_task_;
-};
-
-TEST(TaskTest, TestCancelInDestructor) {
-  // Intentionally not using a scoped_refptr for cancel_in_destructor.
-  CancelInDestructor* cancel_in_destructor = new CancelInDestructor();
-  cancel_in_destructor->Start();
-  CancelableTask* cancelable_task = cancel_in_destructor->cancelable_task();
-  ASSERT_TRUE(cancelable_task);
-  delete cancelable_task;
-}
-
 class DoneTask : public Task {
  public:
   DoneTask(int* run_count, bool* was_deleted)