Skip to content

Commit

Permalink
Remove task.h and finish base::Bind() migration.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ajwong@chromium.org committed Jan 6, 2012
1 parent 0b8545b commit c694427
Show file tree
Hide file tree
Showing 245 changed files with 160 additions and 352 deletions.
1 change: 0 additions & 1 deletion ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"

Expand Down
2 changes: 1 addition & 1 deletion base/at_exit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <ostream>

#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "base/task.h"

namespace base {

Expand Down
2 changes: 1 addition & 1 deletion base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'base_switches.h',
'basictypes.h',
'bind.h',
'bind_helpers.cc',
'bind_helpers.h',
'bind_internal.h',
'bind_internal_win.h',
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion base/task.cc → base/bind_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
Expand Down
43 changes: 42 additions & 1 deletion base/bind_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_
Expand Down Expand Up @@ -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_
9 changes: 5 additions & 4 deletions base/task_unittest.cc → base/bind_helpers_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
Expand All @@ -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;
{
Expand Down
1 change: 0 additions & 1 deletion base/files/file_path_watcher_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion base/message_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion base/message_loop_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion base/message_loop_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 8 additions & 12 deletions base/message_pump_glib_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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()) {
Expand Down
1 change: 0 additions & 1 deletion base/observer_list_threadsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

///////////////////////////////////////////////////////////////////////////////
Expand Down
69 changes: 0 additions & 69 deletions base/task.h

This file was deleted.

2 changes: 1 addition & 1 deletion base/threading/worker_pool_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion base/threading/worker_pool_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion base/threading/worker_pool_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion base/timer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion chrome/browser/autocomplete_history_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "base/memory/ref_counted.h"
#include "base/string16.h"
#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/automation/automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/task.h"
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
Expand Down
Loading

0 comments on commit c694427

Please sign in to comment.