summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-06 22:12:28 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-06 22:12:28 +0000
commitc694427c13725a8d73303fbe2c47e8cbd6abd6c3 (patch)
treeed40f286e831e116b5718f37e454d8dace85abfb /base
parent0b8545bf5feeb7e5340eeff11279402c2d06a778 (diff)
downloadchromium_src-c694427c13725a8d73303fbe2c47e8cbd6abd6c3.zip
chromium_src-c694427c13725a8d73303fbe2c47e8cbd6abd6c3.tar.gz
chromium_src-c694427c13725a8d73303fbe2c47e8cbd6abd6c3.tar.bz2
Remove task.h and finish base::Bind() migration.
Over 341 CLs, in ~3 months, touching 3251 unique files! Top 5 most CLs: (121) jhawkins ( 45) dcheng ( 24) achuith ( 23) csilv ( 12) tfarina ( 12) groby ~1000 files touched: (918) jhawkins 100+ files touched: (486) ajwong (385) willchan (372) dcheng (126) csilv (123) fischman (112) sergeyu 49+ files touched: (65) tfarina (57) acolwell (52) adamk (49) tzik BUG=35223 TEST=existing Review URL: http://codereview.chromium.org/9114020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/at_exit.cc2
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi3
-rw-r--r--base/bind_helpers.cc (renamed from base/task.cc)7
-rw-r--r--base/bind_helpers.h43
-rw-r--r--base/bind_helpers_unittest.cc (renamed from base/task_unittest.cc)9
-rw-r--r--base/files/file_path_watcher_linux.cc1
-rw-r--r--base/message_loop.h1
-rw-r--r--base/message_loop_proxy.h1
-rw-r--r--base/message_loop_unittest.cc1
-rw-r--r--base/message_pump_glib_unittest.cc20
-rw-r--r--base/observer_list_threadsafe.h1
-rw-r--r--base/task.h69
-rw-r--r--base/threading/worker_pool_posix.cc2
-rw-r--r--base/threading/worker_pool_unittest.cc1
-rw-r--r--base/threading/worker_pool_win.cc2
-rw-r--r--base/timer_unittest.cc1
17 files changed, 66 insertions, 100 deletions
diff --git a/base/at_exit.cc b/base/at_exit.cc
index 38e8bbe..0fba355 100644
--- a/base/at_exit.cc
+++ b/base/at_exit.cc
@@ -8,8 +8,8 @@
#include <ostream>
#include "base/bind.h"
+#include "base/callback.h"
#include "base/logging.h"
-#include "base/task.h"
namespace base {
diff --git a/base/base.gyp b/base/base.gyp
index a5c045c..b3262b5 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -127,6 +127,7 @@
'at_exit_unittest.cc',
'atomicops_unittest.cc',
'base64_unittest.cc',
+ 'bind_helpers_unittest.cc',
'bind_unittest.cc',
'bind_unittest.nc',
'bits_unittest.cc',
@@ -219,7 +220,6 @@
'sys_string_conversions_mac_unittest.mm',
'sys_string_conversions_unittest.cc',
'system_monitor/system_monitor_unittest.cc',
- 'task_unittest.cc',
'template_util_unittest.cc',
'test/trace_event_analyzer_unittest.cc',
'threading/non_thread_safe_unittest.cc',
diff --git a/base/base.gypi b/base/base.gypi
index 8ffde65..3c02234 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -51,6 +51,7 @@
'base_switches.h',
'basictypes.h',
'bind.h',
+ 'bind_helpers.cc',
'bind_helpers.h',
'bind_internal.h',
'bind_internal_win.h',
@@ -304,8 +305,6 @@
'sys_string_conversions_mac.mm',
'sys_string_conversions_posix.cc',
'sys_string_conversions_win.cc',
- 'task.cc',
- 'task.h',
'template_util.h',
'threading/non_thread_safe.h',
'threading/non_thread_safe_impl.cc',
diff --git a/base/task.cc b/base/bind_helpers.cc
index baf4e0f6..f2fc3bb 100644
--- a/base/task.cc
+++ b/base/bind_helpers.cc
@@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/task.h"
+#include "base/bind_helpers.h"
+
+#include "base/callback.h"
namespace base {
+void DoNothing() {
+}
+
ScopedClosureRunner::ScopedClosureRunner(const Closure& closure)
: closure_(closure) {
}
diff --git a/base/bind_helpers.h b/base/bind_helpers.h
index af6ff26..ae2a63c 100644
--- a/base/bind_helpers.h
+++ b/base/bind_helpers.h
@@ -6,7 +6,13 @@
// can be used specify the refcounting and reference semantics of arguments
// that are bound by the Bind() function in base/bind.h.
//
-// The public functions are base::Unretained(), base::Owned(), bass::Passed(),
+// It also defines a set of simple functions and utilities that people want
+// when using Callback<> and Bind().
+//
+//
+// ARGUMENT BINDING WRAPPERS
+//
+// The wrapper functions are base::Unretained(), base::Owned(), bass::Passed(),
// base::ConstRef(), and base::IgnoreResult().
//
// Unretained() allows Bind() to bind a non-refcounted class, and to disable
@@ -124,6 +130,19 @@
// ownership of an argument into a task, but don't necessarily know if the
// task will always be executed. This can happen if the task is cancellable
// or if it is posted to a MessageLoopProxy.
+//
+//
+// SIMPLE FUNCTIONS AND UTILITIES.
+//
+// DoNothing() - Useful for creating a Closure that does nothing when called.
+// DeletePointer<T>() - Useful for creating a Closure that will delete a
+// pointer when invoked. Only use this when necessary.
+// In most cases MessageLoop::DeleteSoon() is a better
+// fit.
+// ScopedClosureRunner - Scoper object that runs the wrapped closure when it
+// goes out of scope. It's conceptually similar to
+// scoped_ptr<> but calls Run() instead of deleting
+// the pointer.
#ifndef BASE_BIND_HELPERS_H_
#define BASE_BIND_HELPERS_H_
@@ -517,6 +536,28 @@ IgnoreResult(const Callback<T>& data) {
return internal::IgnoreResultHelper<Callback<T> >(data);
}
+BASE_EXPORT void DoNothing();
+
+template<typename T>
+void DeletePointer(T* obj) {
+ delete obj;
+}
+
+// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the
+// Closure is executed and deleted no matter how the current scope exits.
+class BASE_EXPORT ScopedClosureRunner {
+ public:
+ explicit ScopedClosureRunner(const Closure& closure);
+ ~ScopedClosureRunner();
+
+ Closure Release();
+
+ private:
+ Closure closure_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedClosureRunner);
+};
+
} // namespace base
#endif // BASE_BIND_HELPERS_H_
diff --git a/base/task_unittest.cc b/base/bind_helpers_unittest.cc
index 1fcbfa9..3ef2d75 100644
--- a/base/task_unittest.cc
+++ b/base/bind_helpers_unittest.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind_helpers.h"
+
+#include "base/callback.h"
#include "base/bind.h"
-#include "base/memory/ref_counted.h"
-#include "base/task.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -13,7 +14,7 @@ void Increment(int* value) {
(*value)++;
}
-TEST(TaskTest, TestScopedClosureRunnerExitScope) {
+TEST(BindHelpersTest, TestScopedClosureRunnerExitScope) {
int run_count = 0;
{
base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count));
@@ -22,7 +23,7 @@ TEST(TaskTest, TestScopedClosureRunnerExitScope) {
EXPECT_EQ(1, run_count);
}
-TEST(TaskTest, TestScopedClosureRunnerRelease) {
+TEST(BindHelpersTest, TestScopedClosureRunnerRelease) {
int run_count = 0;
base::Closure c;
{
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index 9711766..be4e760 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -28,7 +28,6 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/synchronization/lock.h"
-#include "base/task.h"
#include "base/threading/thread.h"
namespace base {
diff --git a/base/message_loop.h b/base/message_loop.h
index edaa71a..e14baa7 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -20,7 +20,6 @@
#include "base/observer_list.h"
#include "base/pending_task.h"
#include "base/synchronization/lock.h"
-#include "base/task.h"
#include "base/tracking_info.h"
#include "base/time.h"
diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h
index ef1f658..4487775 100644
--- a/base/message_loop_proxy.h
+++ b/base/message_loop_proxy.h
@@ -11,7 +11,6 @@
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop_helpers.h"
-#include "base/task.h"
namespace tracked_objects {
class Location;
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index e528286..9cf4400 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -11,7 +11,6 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/base/message_pump_glib_unittest.cc b/base/message_pump_glib_unittest.cc
index 467088c..c709355 100644
--- a/base/message_pump_glib_unittest.cc
+++ b/base/message_pump_glib_unittest.cc
@@ -141,10 +141,6 @@ GSourceFuncs EventInjector::SourceFuncs = {
NULL
};
-// Does nothing. This function can be called from a task.
-void DoNothing() {
-}
-
void IncrementInt(int *value) {
++*value;
}
@@ -211,24 +207,24 @@ TEST_F(MessagePumpGLibTest, TestEventTaskInterleave) {
// If changes cause this test to fail, it is reasonable to change it, but
// TestWorkWhileWaitingForEvents and TestEventsWhileWaitingForWork have to be
// changed accordingly, otherwise they can become flaky.
- injector()->AddEventAsTask(0, base::Bind(&DoNothing));
+ injector()->AddEventAsTask(0, base::Bind(&base::DoNothing));
base::Closure check_task =
base::Bind(&ExpectProcessedEvents, base::Unretained(injector()), 2);
base::Closure posted_task =
base::Bind(&PostMessageLoopTask, FROM_HERE, check_task);
injector()->AddEventAsTask(0, posted_task);
- injector()->AddEventAsTask(0, base::Bind(&DoNothing));
+ injector()->AddEventAsTask(0, base::Bind(&base::DoNothing));
injector()->AddEvent(0, MessageLoop::QuitClosure());
loop()->Run();
EXPECT_EQ(4, injector()->processed_events());
injector()->Reset();
- injector()->AddEventAsTask(0, base::Bind(&DoNothing));
+ injector()->AddEventAsTask(0, base::Bind(&base::DoNothing));
check_task =
base::Bind(&ExpectProcessedEvents, base::Unretained(injector()), 2);
posted_task = base::Bind(&PostMessageLoopTask, FROM_HERE, check_task);
injector()->AddEventAsTask(0, posted_task);
- injector()->AddEventAsTask(10, base::Bind(&DoNothing));
+ injector()->AddEventAsTask(10, base::Bind(&base::DoNothing));
injector()->AddEvent(0, MessageLoop::QuitClosure());
loop()->Run();
EXPECT_EQ(4, injector()->processed_events());
@@ -384,8 +380,8 @@ void AddEventsAndDrainGLib(EventInjector* injector) {
injector->AddEvent(0, MessageLoop::QuitClosure());
// Post a couple of dummy tasks
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DoNothing));
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DoNothing));
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&base::DoNothing));
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&base::DoNothing));
// Drain the events
while (g_main_context_pending(NULL)) {
@@ -417,8 +413,8 @@ void AddEventsAndDrainGtk(EventInjector* injector) {
injector->AddEvent(0, MessageLoop::QuitClosure());
// Post a couple of dummy tasks
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DoNothing));
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DoNothing));
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&base::DoNothing));
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&base::DoNothing));
// Drain the events
while (gtk_events_pending()) {
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h
index 9acb82a..c24e96a 100644
--- a/base/observer_list_threadsafe.h
+++ b/base/observer_list_threadsafe.h
@@ -17,7 +17,6 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/observer_list.h"
-#include "base/task.h"
#include "base/threading/platform_thread.h"
///////////////////////////////////////////////////////////////////////////////
diff --git a/base/task.h b/base/task.h
deleted file mode 100644
index dbef70b..0000000
--- a/base/task.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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.
-
-// ============================================================================
-// ****************************************************************************
-// * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION *
-// ****************************************************************************
-// ============================================================================
-// ============================================================================
-// ****************************************************************************
-// * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION *
-// ****************************************************************************
-// ============================================================================
-// ============================================================================
-// ****************************************************************************
-// * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION *
-// ****************************************************************************
-// ============================================================================
-// ============================================================================
-// ****************************************************************************
-// * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION *
-// ****************************************************************************
-// ============================================================================
-// ============================================================================
-// ****************************************************************************
-// * THIS HEADER IS DEPRECATED, SEE base/callback.h FOR NEW IMPLEMENTATION *
-// ****************************************************************************
-// ============================================================================
-#ifndef BASE_TASK_H_
-#define BASE_TASK_H_
-#pragma once
-
-#include "base/base_export.h"
-#include "base/callback.h"
-#include "base/debug/alias.h"
-#include "base/memory/raw_scoped_refptr_mismatch_checker.h"
-#include "base/memory/weak_ptr.h"
-#include "base/tuple.h"
-
-namespace base {
-const size_t kDeadTask = 0xDEAD7A53;
-}
-
-template<typename T>
-void DeletePointer(T* obj) {
- delete obj;
-}
-
-namespace base {
-
-// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the
-// Closure is executed and deleted no matter how the current scope exits.
-class BASE_EXPORT ScopedClosureRunner {
- public:
- explicit ScopedClosureRunner(const Closure& closure);
- ~ScopedClosureRunner();
-
- Closure Release();
-
- private:
- Closure closure_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedClosureRunner);
-};
-
-} // namespace base
-
-#endif // BASE_TASK_H_
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index 2655b85c..c139ffa 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -5,12 +5,12 @@
#include "base/threading/worker_pool_posix.h"
#include "base/bind.h"
+#include "base/callback.h"
#include "base/debug/trace_event.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/stringprintf.h"
-#include "base/task.h"
#include "base/threading/platform_thread.h"
#include "base/threading/worker_pool.h"
#include "base/tracked_objects.h"
diff --git a/base/threading/worker_pool_unittest.cc b/base/threading/worker_pool_unittest.cc
index d36cb1b..4be06d3 100644
--- a/base/threading/worker_pool_unittest.cc
+++ b/base/threading/worker_pool_unittest.cc
@@ -8,7 +8,6 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "base/test/test_timeouts.h"
#include "base/time.h"
#include "base/threading/thread_checker_impl.h"
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc
index d4249ea..9f7c19f 100644
--- a/base/threading/worker_pool_win.cc
+++ b/base/threading/worker_pool_win.cc
@@ -5,10 +5,10 @@
#include "base/threading/worker_pool.h"
#include "base/bind.h"
+#include "base/callback.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/pending_task.h"
-#include "base/task.h"
#include "base/tracked_objects.h"
namespace base {
diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc
index a31f7ba..d4b666f 100644
--- a/base/timer_unittest.cc
+++ b/base/timer_unittest.cc
@@ -4,7 +4,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
-#include "base/task.h"
#include "base/timer.h"
#include "testing/gtest/include/gtest/gtest.h"