diff options
-rw-r--r-- | base/files/file_path_watcher_linux.cc | 113 | ||||
-rw-r--r-- | base/message_loop.cc | 64 | ||||
-rw-r--r-- | base/message_loop.h | 32 | ||||
-rw-r--r-- | base/message_loop_proxy.h | 25 | ||||
-rw-r--r-- | base/message_loop_proxy_impl.cc | 46 | ||||
-rw-r--r-- | base/message_loop_proxy_impl.h | 18 | ||||
-rw-r--r-- | base/message_loop_proxy_impl_unittest.cc | 46 | ||||
-rw-r--r-- | base/task.cc | 37 | ||||
-rw-r--r-- | base/task.h | 52 | ||||
-rw-r--r-- | base/threading/thread_unittest.cc | 24 | ||||
-rw-r--r-- | base/threading/worker_pool.h | 7 | ||||
-rw-r--r-- | base/threading/worker_pool_posix.cc | 30 | ||||
-rw-r--r-- | base/threading/worker_pool_posix.h | 9 | ||||
-rw-r--r-- | base/threading/worker_pool_win.cc | 11 | ||||
-rw-r--r-- | chrome/test/webdriver/webdriver_session.h | 4 | ||||
-rw-r--r-- | content/browser/browser_thread_impl.cc | 102 | ||||
-rw-r--r-- | content/browser/browser_thread_impl.h | 9 | ||||
-rw-r--r-- | content/browser/browser_thread_unittest.cc | 63 | ||||
-rw-r--r-- | content/public/browser/browser_thread.h | 19 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.cc | 49 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.h | 20 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_thread_unittest.cc | 38 |
22 files changed, 101 insertions, 717 deletions
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index 86c963c..9711766 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.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. @@ -152,76 +152,62 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl); }; -class InotifyReaderTask : public Task { - public: - InotifyReaderTask(InotifyReader* reader, int inotify_fd, int shutdown_fd) - : reader_(reader), - inotify_fd_(inotify_fd), - shutdown_fd_(shutdown_fd) { - // Make sure the file descriptors are good for use with select(). - CHECK_LE(0, inotify_fd_); - CHECK_GT(FD_SETSIZE, inotify_fd_); - CHECK_LE(0, shutdown_fd_); - CHECK_GT(FD_SETSIZE, shutdown_fd_); - } - - virtual void Run() { - while (true) { - fd_set rfds; - FD_ZERO(&rfds); - FD_SET(inotify_fd_, &rfds); - FD_SET(shutdown_fd_, &rfds); - - // Wait until some inotify events are available. - int select_result = - HANDLE_EINTR(select(std::max(inotify_fd_, shutdown_fd_) + 1, - &rfds, NULL, NULL, NULL)); - if (select_result < 0) { - DPLOG(WARNING) << "select failed"; - return; - } +void InotifyReaderCallback(InotifyReader* reader, int inotify_fd, + int shutdown_fd) { + // Make sure the file descriptors are good for use with select(). + CHECK_LE(0, inotify_fd); + CHECK_GT(FD_SETSIZE, inotify_fd); + CHECK_LE(0, shutdown_fd); + CHECK_GT(FD_SETSIZE, shutdown_fd); + + while (true) { + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(inotify_fd, &rfds); + FD_SET(shutdown_fd, &rfds); + + // Wait until some inotify events are available. + int select_result = + HANDLE_EINTR(select(std::max(inotify_fd, shutdown_fd) + 1, + &rfds, NULL, NULL, NULL)); + if (select_result < 0) { + DPLOG(WARNING) << "select failed"; + return; + } - if (FD_ISSET(shutdown_fd_, &rfds)) - return; + if (FD_ISSET(shutdown_fd, &rfds)) + return; - // Adjust buffer size to current event queue size. - int buffer_size; - int ioctl_result = HANDLE_EINTR(ioctl(inotify_fd_, FIONREAD, - &buffer_size)); + // Adjust buffer size to current event queue size. + int buffer_size; + int ioctl_result = HANDLE_EINTR(ioctl(inotify_fd, FIONREAD, + &buffer_size)); - if (ioctl_result != 0) { - DPLOG(WARNING) << "ioctl failed"; - return; - } + if (ioctl_result != 0) { + DPLOG(WARNING) << "ioctl failed"; + return; + } - std::vector<char> buffer(buffer_size); + std::vector<char> buffer(buffer_size); - ssize_t bytes_read = HANDLE_EINTR(read(inotify_fd_, &buffer[0], - buffer_size)); + ssize_t bytes_read = HANDLE_EINTR(read(inotify_fd, &buffer[0], + buffer_size)); - if (bytes_read < 0) { - DPLOG(WARNING) << "read from inotify fd failed"; - return; - } + if (bytes_read < 0) { + DPLOG(WARNING) << "read from inotify fd failed"; + return; + } - ssize_t i = 0; - while (i < bytes_read) { - inotify_event* event = reinterpret_cast<inotify_event*>(&buffer[i]); - size_t event_size = sizeof(inotify_event) + event->len; - DCHECK(i + event_size <= static_cast<size_t>(bytes_read)); - reader_->OnInotifyEvent(event); - i += event_size; - } + ssize_t i = 0; + while (i < bytes_read) { + inotify_event* event = reinterpret_cast<inotify_event*>(&buffer[i]); + size_t event_size = sizeof(inotify_event) + event->len; + DCHECK(i + event_size <= static_cast<size_t>(bytes_read)); + reader->OnInotifyEvent(event); + i += event_size; } } - - private: - InotifyReader* reader_; - int inotify_fd_; - int shutdown_fd_; - - DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask); -}; +} static base::LazyInstance<InotifyReader> g_inotify_reader = LAZY_INSTANCE_INITIALIZER; @@ -234,7 +220,8 @@ InotifyReader::InotifyReader() shutdown_pipe_[1] = -1; if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { thread_.message_loop()->PostTask( - FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0])); + FROM_HERE, base::Bind(&InotifyReaderCallback, this, inotify_fd_, + shutdown_pipe_[0])); valid_ = true; } } diff --git a/base/message_loop.cc b/base/message_loop.cc index 6da3b6b..aa04f45 100644 --- a/base/message_loop.cc +++ b/base/message_loop.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. @@ -249,68 +249,6 @@ void MessageLoop::RemoveDestructionObserver( } void MessageLoop::PostTask( - const tracked_objects::Location& from_here, Task* task) { - DCHECK(task); - PendingTask pending_task( - from_here, - base::Bind( - &base::subtle::TaskClosureAdapter::Run, - new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), - CalculateDelayedRuntime(0), true); - AddToIncomingQueue(&pending_task); -} - -void MessageLoop::PostDelayedTask( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { - DCHECK(task); - PendingTask pending_task( - from_here, - base::Bind( - &base::subtle::TaskClosureAdapter::Run, - new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), - CalculateDelayedRuntime(delay_ms), true); - AddToIncomingQueue(&pending_task); -} - -void MessageLoop::PostDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - base::TimeDelta delay) { - PostDelayedTask(from_here, task, delay.InMillisecondsRoundedUp()); -} - -void MessageLoop::PostNonNestableTask( - const tracked_objects::Location& from_here, Task* task) { - DCHECK(task); - PendingTask pending_task( - from_here, - base::Bind( - &base::subtle::TaskClosureAdapter::Run, - new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), - CalculateDelayedRuntime(0), false); - AddToIncomingQueue(&pending_task); -} - -void MessageLoop::PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { - DCHECK(task); - PendingTask pending_task( - from_here, - base::Bind( - &base::subtle::TaskClosureAdapter::Run, - new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), - CalculateDelayedRuntime(delay_ms), false); - AddToIncomingQueue(&pending_task); -} - -void MessageLoop::PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - base::TimeDelta delay) { - PostNonNestableDelayedTask(from_here, task, delay.InMillisecondsRoundedUp()); -} - -void MessageLoop::PostTask( const tracked_objects::Location& from_here, const base::Closure& task) { DCHECK(!task.is_null()) << from_here.ToString(); PendingTask pending_task(from_here, task, CalculateDelayedRuntime(0), true); diff --git a/base/message_loop.h b/base/message_loop.h index 2f66d26..edaa71a 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -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. @@ -162,36 +162,6 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate { // // NOTE: These methods may be called on any thread. The Task will be invoked // on the thread that executes MessageLoop::Run(). - - void PostTask( - const tracked_objects::Location& from_here, Task* task); - - void PostDelayedTask( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms); - - void PostDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - base::TimeDelta delay); - - void PostNonNestableTask( - const tracked_objects::Location& from_here, Task* task); - - void PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms); - - void PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - base::TimeDelta delay); - - // TODO(ajwong): Remove the functions above once the Task -> Closure migration - // is complete. - // - // There are 2 sets of Post*Task functions, one which takes the older Task* - // function object representation, and one that takes the newer base::Closure. - // We have this overload to allow a staged transition between the two systems. - // Once the transition is done, the functions above should be deleted. void PostTask( const tracked_objects::Location& from_here, const base::Closure& task); diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h index b6da5e4..ef1f658 100644 --- a/base/message_loop_proxy.h +++ b/base/message_loop_proxy.h @@ -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. @@ -33,33 +33,14 @@ class BASE_EXPORT MessageLoopProxy MessageLoopProxyTraits> { public: // These methods are the same as in message_loop.h, but are guaranteed to - // either post the Task to the MessageLoop (if it's still alive), or to - // delete the Task otherwise. + // either post the Task to the MessageLoop (if it's still alive), or the task + // is discarded. // They return true iff the thread existed and the task was posted. Note that // even if the task is posted, there's no guarantee that it will run; for // example the target loop may already be quitting, or in the case of a // delayed task a Quit message may preempt it in the message loop queue. // Conversely, a return value of false is a guarantee the task will not run. virtual bool PostTask(const tracked_objects::Location& from_here, - Task* task) = 0; - virtual bool PostDelayedTask(const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) = 0; - virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, - Task* task) = 0; - virtual bool PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) = 0; - - // TODO(ajwong): Remove the functions above once the Task -> Closure migration - // is complete. - // - // There are 2 sets of Post*Task functions, one which takes the older Task* - // function object representation, and one that takes the newer base::Closure. - // We have this overload to allow a staged transition between the two systems. - // Once the transition is done, the functions above should be deleted. - virtual bool PostTask(const tracked_objects::Location& from_here, const base::Closure& task) = 0; virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc index b826916..e0ecd89 100644 --- a/base/message_loop_proxy_impl.cc +++ b/base/message_loop_proxy_impl.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. @@ -12,29 +12,6 @@ namespace base { MessageLoopProxyImpl::~MessageLoopProxyImpl() { } - // MessageLoopProxy implementation -bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here, - Task* task) { - return PostTaskHelper(from_here, task, 0, true); -} - -bool MessageLoopProxyImpl::PostDelayedTask( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, true); -} - -bool MessageLoopProxyImpl::PostNonNestableTask( - const tracked_objects::Location& from_here, Task* task) { - return PostTaskHelper(from_here, task, 0, false); -} - -bool MessageLoopProxyImpl::PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, false); -} - bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here, const base::Closure& task) { return PostTaskHelper(from_here, task, 0, true); @@ -100,27 +77,6 @@ MessageLoopProxyImpl::MessageLoopProxyImpl() } bool MessageLoopProxyImpl::PostTaskHelper( - const tracked_objects::Location& from_here, Task* task, int64 delay_ms, - bool nestable) { - bool ret = false; - { - AutoLock lock(message_loop_lock_); - if (target_message_loop_) { - if (nestable) { - target_message_loop_->PostDelayedTask(from_here, task, delay_ms); - } else { - target_message_loop_->PostNonNestableDelayedTask(from_here, task, - delay_ms); - } - ret = true; - } - } - if (!ret) - delete task; - return ret; -} - -bool MessageLoopProxyImpl::PostTaskHelper( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms, bool nestable) { AutoLock lock(message_loop_lock_); diff --git a/base/message_loop_proxy_impl.h b/base/message_loop_proxy_impl.h index 0c44c82..bb1fc0b 100644 --- a/base/message_loop_proxy_impl.h +++ b/base/message_loop_proxy_impl.h @@ -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. @@ -23,17 +23,6 @@ class BASE_EXPORT MessageLoopProxyImpl // MessageLoopProxy implementation virtual bool PostTask(const tracked_objects::Location& from_here, - Task* task) OVERRIDE; - virtual bool PostDelayedTask(const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) OVERRIDE; - virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, - Task* task) OVERRIDE; - virtual bool PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) OVERRIDE; - virtual bool PostTask(const tracked_objects::Location& from_here, const base::Closure& task) OVERRIDE; virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, @@ -58,11 +47,6 @@ class BASE_EXPORT MessageLoopProxyImpl virtual void WillDestroyCurrentMessageLoop(); - // TODO(ajwong): Remove this after we've fully migrated to base::Closure. - bool PostTaskHelper(const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms, - bool nestable); bool PostTaskHelper(const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms, diff --git a/base/message_loop_proxy_impl_unittest.cc b/base/message_loop_proxy_impl_unittest.cc index 2935911..612312a 100644 --- a/base/message_loop_proxy_impl_unittest.cc +++ b/base/message_loop_proxy_impl_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. @@ -58,21 +58,6 @@ class MessageLoopProxyImplTest : public testing::Test { FAIL() << "Callback Should not get executed."; } - class DummyTask : public Task { - public: - explicit DummyTask(bool* deleted) : deleted_(deleted) { } - ~DummyTask() { - *deleted_ = true; - } - - void Run() { - FAIL(); - } - - private: - bool* deleted_; - }; - class DeletedOnFile { public: explicit DeletedOnFile(MessageLoopProxyImplTest* test) : test_(test) {} @@ -105,35 +90,6 @@ TEST_F(MessageLoopProxyImplTest, Delete) { MessageLoop::current()->Run(); } -TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadExits) { - scoped_ptr<base::Thread> test_thread( - new base::Thread("MessageLoopProxyImplTest_Dummy")); - test_thread->Start(); - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = - test_thread->message_loop_proxy(); - test_thread->Stop(); - - bool deleted = false; - bool ret = message_loop_proxy->PostTask( - FROM_HERE, new DummyTask(&deleted)); - EXPECT_FALSE(ret); - EXPECT_TRUE(deleted); -} - -TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadIsDeleted) { - scoped_refptr<base::MessageLoopProxy> message_loop_proxy; - { - scoped_ptr<base::Thread> test_thread( - new base::Thread("MessageLoopProxyImplTest_Dummy")); - test_thread->Start(); - message_loop_proxy = test_thread->message_loop_proxy(); - } - bool deleted = false; - bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); - EXPECT_FALSE(ret); - EXPECT_TRUE(deleted); -} - TEST_F(MessageLoopProxyImplTest, PostTask) { EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask( FROM_HERE, base::Bind(&MessageLoopProxyImplTest::BasicFunction, diff --git a/base/task.cc b/base/task.cc index 38ac086..baf4e0f6 100644 --- a/base/task.cc +++ b/base/task.cc @@ -1,15 +1,9 @@ -// 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. #include "base/task.h" -Task::Task() { -} - -Task::~Task() { -} - namespace base { ScopedClosureRunner::ScopedClosureRunner(const Closure& closure) @@ -27,33 +21,4 @@ Closure ScopedClosureRunner::Release() { return result; } -namespace subtle { - -TaskClosureAdapter::TaskClosureAdapter(Task* task) - : task_(task), - should_leak_task_(&kTaskLeakingDefault) { -} - -TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task) - : task_(task), - should_leak_task_(should_leak_task) { -} - -TaskClosureAdapter::~TaskClosureAdapter() { - if (!*should_leak_task_) { - delete task_; - } -} - -void TaskClosureAdapter::Run() { - task_->Run(); - delete task_; - task_ = NULL; -} - -// Don't leak tasks by default. -bool TaskClosureAdapter::kTaskLeakingDefault = false; - -} // namespace subtle - } // namespace base diff --git a/base/task.h b/base/task.h index a310e0d..dbef70b 100644 --- a/base/task.h +++ b/base/task.h @@ -42,20 +42,6 @@ namespace base { const size_t kDeadTask = 0xDEAD7A53; } -// Task ------------------------------------------------------------------------ -// -// A task is a generic runnable thingy, usually used for running code on a -// different thread or for scheduling future tasks off of the message loop. - -class BASE_EXPORT Task { - public: - Task(); - virtual ~Task(); - - // Tasks are automatically deleted after Run is called. - virtual void Run() = 0; -}; - template<typename T> void DeletePointer(T* obj) { delete obj; @@ -78,44 +64,6 @@ class BASE_EXPORT ScopedClosureRunner { DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedClosureRunner); }; -namespace subtle { - -// This class is meant for use in the implementation of MessageLoop classes -// such as MessageLoop, MessageLoopProxy, BrowserThread, and WorkerPool to -// implement the compatibility APIs while we are transitioning from Task to -// Callback. -// -// It should NOT be used anywhere else! -// -// In particular, notice that this is RefCounted instead of -// RefCountedThreadSafe. We rely on the fact that users of this class are -// careful to ensure that a lock is taken during transfer of ownership for -// objects from this class to ensure the refcount is not corrupted. -class TaskClosureAdapter : public RefCounted<TaskClosureAdapter> { - public: - explicit TaskClosureAdapter(Task* task); - - // |should_leak_task| points to a flag variable that can be used to determine - // if this class should leak the Task on destruction. This is important - // at MessageLoop shutdown since not all tasks can be safely deleted without - // running. See MessageLoop::DeletePendingTasks() for the exact behavior - // of when a Task should be deleted. It is subtle. - TaskClosureAdapter(Task* task, bool* should_leak_task); - - void Run(); - - private: - friend class base::RefCounted<TaskClosureAdapter>; - - ~TaskClosureAdapter(); - - Task* task_; - bool* should_leak_task_; - static bool kTaskLeakingDefault; -}; - -} // namespace subtle - } // namespace base #endif // BASE_TASK_H_ diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc index 0444947..87df252 100644 --- a/base/threading/thread_unittest.cc +++ b/base/threading/thread_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. @@ -105,21 +105,9 @@ class CapturingDestructionObserver : public MessageLoop::DestructionObserver { }; // Task that adds a destruction observer to the current message loop. -class RegisterDestructionObserver : public Task { - public: - explicit RegisterDestructionObserver( - MessageLoop::DestructionObserver* observer) - : observer_(observer) { - } - - virtual void Run() { - MessageLoop::current()->AddDestructionObserver(observer_); - observer_ = NULL; - } - - private: - MessageLoop::DestructionObserver* observer_; -}; +void RegisterDestructionObserver(MessageLoop::DestructionObserver* observer) { + MessageLoop::current()->AddDestructionObserver(observer); +} } // namespace @@ -234,8 +222,8 @@ TEST_F(ThreadTest, CleanUp) { // Register an observer that writes into |captured_events| once the // thread's message loop is destroyed. t.message_loop()->PostTask( - FROM_HERE, - new RegisterDestructionObserver(&loop_destruction_observer)); + FROM_HERE, base::Bind(&RegisterDestructionObserver, + base::Unretained(&loop_destruction_observer))); // Upon leaving this scope, the thread is deleted. } diff --git a/base/threading/worker_pool.h b/base/threading/worker_pool.h index 0db6122..6694830 100644 --- a/base/threading/worker_pool.h +++ b/base/threading/worker_pool.h @@ -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. @@ -31,11 +31,6 @@ class BASE_EXPORT WorkerPool { // should be used for tasks that will take a long time to execute. Returns // false if |task| could not be posted to a worker thread. Regardless of // return value, ownership of |task| is transferred to the worker pool. - // - // TODO(ajwong): Remove the Task* based overload once we've finished the - // Task -> Closure migration. - static bool PostTask(const tracked_objects::Location& from_here, - Task* task, bool task_is_slow); static bool PostTask(const tracked_objects::Location& from_here, const base::Closure& task, bool task_is_slow); diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc index f93c447..2655b85c 100644 --- a/base/threading/worker_pool_posix.cc +++ b/base/threading/worker_pool_posix.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. @@ -31,8 +31,6 @@ class WorkerPoolImpl { WorkerPoolImpl(); ~WorkerPoolImpl(); - void PostTask(const tracked_objects::Location& from_here, Task* task, - bool task_is_slow); void PostTask(const tracked_objects::Location& from_here, const base::Closure& task, bool task_is_slow); @@ -50,11 +48,6 @@ WorkerPoolImpl::~WorkerPoolImpl() { } void WorkerPoolImpl::PostTask(const tracked_objects::Location& from_here, - Task* task, bool task_is_slow) { - pool_->PostTask(from_here, task); -} - -void WorkerPoolImpl::PostTask(const tracked_objects::Location& from_here, const base::Closure& task, bool task_is_slow) { pool_->PostTask(from_here, task); } @@ -109,12 +102,6 @@ void WorkerThread::ThreadMain() { } // namespace bool WorkerPool::PostTask(const tracked_objects::Location& from_here, - Task* task, bool task_is_slow) { - g_lazy_worker_pool.Pointer()->PostTask(from_here, task, task_is_slow); - return true; -} - -bool WorkerPool::PostTask(const tracked_objects::Location& from_here, const base::Closure& task, bool task_is_slow) { g_lazy_worker_pool.Pointer()->PostTask(from_here, task, task_is_slow); return true; @@ -146,21 +133,6 @@ void PosixDynamicThreadPool::Terminate() { void PosixDynamicThreadPool::PostTask( const tracked_objects::Location& from_here, - Task* task) { - PendingTask pending_task(from_here, - base::Bind(&subtle::TaskClosureAdapter::Run, - new subtle::TaskClosureAdapter(task))); - // |pending_task| and AddTask() work in conjunction here to ensure that after - // a successful AddTask(), the TaskClosureAdapter object is deleted on the - // worker thread. In AddTask(), the reference |pending_task.task| is handed - // off in a destructive manner to ensure that the local copy of - // |pending_task| doesn't keep a ref on the Closure causing the - // TaskClosureAdapter to be deleted on the wrong thread. - AddTask(&pending_task); -} - -void PosixDynamicThreadPool::PostTask( - const tracked_objects::Location& from_here, const base::Closure& task) { PendingTask pending_task(from_here, task); AddTask(&pending_task); diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h index 491dbbb..f56582d 100644 --- a/base/threading/worker_pool_posix.h +++ b/base/threading/worker_pool_posix.h @@ -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. // @@ -59,13 +59,6 @@ class BASE_EXPORT PosixDynamicThreadPool // worker threads. Wakes up all the idle threads to let them exit. void Terminate(); - // Adds |task| to the thread pool. PosixDynamicThreadPool assumes ownership - // of |task|. - // - // TODO(ajwong): Remove this compatibility API once the Task -> Closure - // migration is finished. - void PostTask(const tracked_objects::Location& from_here, Task* task); - // Adds |task| to the thread pool. void PostTask(const tracked_objects::Location& from_here, const Closure& task); diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc index 188c4a9..d4249ea 100644 --- a/base/threading/worker_pool_win.cc +++ b/base/threading/worker_pool_win.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. @@ -53,15 +53,6 @@ bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { } // namespace bool WorkerPool::PostTask(const tracked_objects::Location& from_here, - Task* task, bool task_is_slow) { - PendingTask* pending_task = - new PendingTask(from_here, - base::Bind(&subtle::TaskClosureAdapter::Run, - new subtle::TaskClosureAdapter(task))); - return PostTaskInternal(pending_task, task_is_slow); -} - -bool WorkerPool::PostTask(const tracked_objects::Location& from_here, const base::Closure& task, bool task_is_slow) { PendingTask* pending_task = new PendingTask(from_here, task); return PostTaskInternal(pending_task, task_is_slow); diff --git a/chrome/test/webdriver/webdriver_session.h b/chrome/test/webdriver/webdriver_session.h index 6fb7cee..28d422a 100644 --- a/chrome/test/webdriver/webdriver_session.h +++ b/chrome/test/webdriver/webdriver_session.h @@ -350,10 +350,6 @@ class Session { Error* GetAppCacheStatus(int* status); private: - void RunSessionTask(Task* task); - void RunSessionTaskOnSessionThread( - Task* task, - base::WaitableEvent* done_event); void RunSessionTask(const base::Closure& task); void RunClosureOnSessionThread( const base::Closure& task, diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc index 94ef3f1..a66477a 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.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. @@ -116,47 +116,6 @@ BrowserThreadImpl::~BrowserThreadImpl() { bool BrowserThreadImpl::PostTaskHelper( BrowserThread::ID identifier, const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms, - bool nestable) { - DCHECK(identifier >= 0 && identifier < ID_COUNT); - // Optimization: to avoid unnecessary locks, we listed the ID enumeration in - // order of lifetime. So no need to lock if we know that the other thread - // outlives this one. - // Note: since the array is so small, ok to loop instead of creating a map, - // which would require a lock because std::map isn't thread safe, defeating - // the whole purpose of this optimization. - BrowserThread::ID current_thread; - bool guaranteed_to_outlive_target_thread = - GetCurrentThreadIdentifier(¤t_thread) && - current_thread <= identifier; - - if (!guaranteed_to_outlive_target_thread) - g_lock.Get().Acquire(); - - MessageLoop* message_loop = g_browser_threads[identifier] ? - g_browser_threads[identifier]->message_loop() : NULL; - if (message_loop) { - if (nestable) { - message_loop->PostDelayedTask(from_here, task, delay_ms); - } else { - message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); - } - } - - if (!guaranteed_to_outlive_target_thread) - g_lock.Get().Release(); - - if (!message_loop) - delete task; - - return !!message_loop; -} - -// static -bool BrowserThreadImpl::PostTaskHelper( - BrowserThread::ID identifier, - const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms, bool nestable) { @@ -201,29 +160,6 @@ class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { // MessageLoopProxy implementation. virtual bool PostTask(const tracked_objects::Location& from_here, - Task* task) { - return BrowserThread::PostTask(id_, from_here, task); - } - - virtual bool PostDelayedTask(const tracked_objects::Location& from_here, - Task* task, int64 delay_ms) { - return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); - } - - virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, - Task* task) { - return BrowserThread::PostNonNestableTask(id_, from_here, task); - } - - virtual bool PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, - delay_ms); - } - - virtual bool PostTask(const tracked_objects::Location& from_here, const base::Closure& task) { return BrowserThread::PostTask(id_, from_here, task); } @@ -321,42 +257,6 @@ bool BrowserThread::PostNonNestableDelayedTask( } // static -bool BrowserThread::PostTask(ID identifier, - const tracked_objects::Location& from_here, - Task* task) { - return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, 0, true); -} - -// static -bool BrowserThread::PostDelayedTask(ID identifier, - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, delay_ms, true); -} - -// static -bool BrowserThread::PostNonNestableTask( - ID identifier, - const tracked_objects::Location& from_here, - Task* task) { - return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, 0, false); -} - -// static -bool BrowserThread::PostNonNestableDelayedTask( - ID identifier, - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, delay_ms, false); -} - -// static bool BrowserThread::PostTaskAndReply( ID identifier, const tracked_objects::Location& from_here, diff --git a/content/browser/browser_thread_impl.h b/content/browser/browser_thread_impl.h index d00ff5b..feea986 100644 --- a/content/browser/browser_thread_impl.h +++ b/content/browser/browser_thread_impl.h @@ -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. @@ -35,13 +35,6 @@ class CONTENT_EXPORT BrowserThreadImpl // the API cleaner. Therefore make BrowserThread a friend class. friend class BrowserThread; - // TODO(brettw) remove this variant when Task->Closure migration is complete. - static bool PostTaskHelper( - BrowserThread::ID identifier, - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms, - bool nestable); static bool PostTaskHelper( BrowserThread::ID identifier, const tracked_objects::Location& from_here, diff --git a/content/browser/browser_thread_unittest.cc b/content/browser/browser_thread_unittest.cc index 59ec5f7..458f872 100644 --- a/content/browser/browser_thread_unittest.cc +++ b/content/browser/browser_thread_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. @@ -41,21 +41,6 @@ class BrowserThreadTest : public testing::Test { static void DoNothing() { } - class DummyTask : public Task { - public: - explicit DummyTask(bool* deleted) : deleted_(deleted) { } - ~DummyTask() { - *deleted_ = true; - } - - void Run() { - CHECK(false); - } - - private: - bool* deleted_; - }; - class DeletedOnFile : public base::RefCountedThreadSafe< DeletedOnFile, BrowserThread::DeleteOnFileThread> { @@ -101,14 +86,6 @@ TEST_F(BrowserThreadTest, Release) { MessageLoop::current()->Run(); } -TEST_F(BrowserThreadTest, TaskToNonExistentThreadIsDeleted) { - bool deleted = false; - BrowserThread::PostTask( - BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, - new DummyTask(&deleted)); - EXPECT_TRUE(deleted); -} - TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { { scoped_refptr<DeletedOnFile> test( @@ -148,42 +125,4 @@ TEST_F(BrowserThreadTest, PostTaskAndReply) { MessageLoop::current()->Run(); } - -TEST_F(BrowserThreadTest, TaskToNonExistentThreadIsDeletedViaMessageLoopProxy) { - bool deleted = false; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = - BrowserThread::GetMessageLoopProxyForThread( - BrowserThread::WEBKIT_DEPRECATED); - message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); - EXPECT_TRUE(deleted); -} - -TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxyAfterThreadExits) { - scoped_ptr<BrowserThreadImpl> io_thread( - new BrowserThreadImpl(BrowserThread::IO)); - io_thread->Start(); - io_thread->Stop(); - - bool deleted = false; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); - bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); - EXPECT_FALSE(ret); - EXPECT_TRUE(deleted); -} - -TEST_F(BrowserThreadTest, PostTaskViaMessageLoopProxyAfterThreadIsDeleted) { - { - scoped_ptr<BrowserThreadImpl> io_thread( - new BrowserThreadImpl(BrowserThread::IO)); - io_thread->Start(); - } - bool deleted = false; - scoped_refptr<base::MessageLoopProxy> message_loop_proxy = - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); - bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); - EXPECT_FALSE(ret); - EXPECT_TRUE(deleted); -} - } diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h index 5cc594a..ae9b6a8 100644 --- a/content/public/browser/browser_thread.h +++ b/content/public/browser/browser_thread.h @@ -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. @@ -118,23 +118,6 @@ class CONTENT_EXPORT BrowserThread { const base::Closure& task, int64 delay_ms); - // TODO(brettw) remove these when Task->Closure conversion is done. - static bool PostTask(ID identifier, - const tracked_objects::Location& from_here, - Task* task); - static bool PostDelayedTask(ID identifier, - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms); - static bool PostNonNestableTask(ID identifier, - const tracked_objects::Location& from_here, - Task* task); - static bool PostNonNestableDelayedTask( - ID identifier, - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms); - static bool PostTaskAndReply( ID identifier, const tracked_objects::Location& from_here, diff --git a/remoting/base/plugin_message_loop_proxy.cc b/remoting/base/plugin_message_loop_proxy.cc index 3a8b48e..b3bc453 100644 --- a/remoting/base/plugin_message_loop_proxy.cc +++ b/remoting/base/plugin_message_loop_proxy.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. @@ -24,42 +24,6 @@ void PluginMessageLoopProxy::Detach() { } } -// MessageLoopProxy interface implementation. -bool PluginMessageLoopProxy::PostTask( - const tracked_objects::Location& from_here, - Task* task) { - return PostDelayedTask(from_here, task, 0); -} - -bool PluginMessageLoopProxy::PostDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - base::AutoLock auto_lock(lock_); - if (!delegate_) - return false; - - base::Closure* springpad_closure = new base::Closure(base::Bind( - &PluginMessageLoopProxy::RunTaskIf, this, task)); - return delegate_->RunOnPluginThread( - delay_ms, &PluginMessageLoopProxy::TaskSpringboard, springpad_closure); -} - -bool PluginMessageLoopProxy::PostNonNestableTask( - const tracked_objects::Location& from_here, - Task* task) { - // All tasks running on this message loop are non-nestable. - return PostTask(from_here, task); -} - -bool PluginMessageLoopProxy::PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) { - // All tasks running on this message loop are non-nestable. - return PostDelayedTask(from_here, task, delay_ms); -} - bool PluginMessageLoopProxy::PostTask( const tracked_objects::Location& from_here, const base::Closure& task) { @@ -97,7 +61,7 @@ bool PluginMessageLoopProxy::PostNonNestableDelayedTask( bool PluginMessageLoopProxy::BelongsToCurrentThread() { // In pepper plugins ideally we should use pp::Core::IsMainThread, - // but it is problematic becase we would need to keep reference to + // but it is problematic because we would need to keep reference to // Core somewhere, e.g. make the delegate ref-counted. return base::PlatformThread::CurrentId() == plugin_thread_id_; } @@ -109,15 +73,6 @@ void PluginMessageLoopProxy::TaskSpringboard(void* data) { delete task; } -void PluginMessageLoopProxy::RunTaskIf(Task* task) { - DCHECK(BelongsToCurrentThread()); - // |delegate_| can be changed only from our thread, so it's safe to - // access it without acquiring |lock_|. - if (delegate_) - task->Run(); - delete task; -} - void PluginMessageLoopProxy::RunClosureIf(const base::Closure& task) { // |delegate_| can be changed only from our thread, so it's safe to // access it without acquiring |lock_|. diff --git a/remoting/base/plugin_message_loop_proxy.h b/remoting/base/plugin_message_loop_proxy.h index 8a0d840..19082a0 100644 --- a/remoting/base/plugin_message_loop_proxy.h +++ b/remoting/base/plugin_message_loop_proxy.h @@ -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. @@ -31,22 +31,7 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { void Detach(); - // base::MessageLoopProxy interface. - virtual bool PostTask( - const tracked_objects::Location& from_here, - Task* task) OVERRIDE; - virtual bool PostDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) OVERRIDE; - virtual bool PostNonNestableTask( - const tracked_objects::Location& from_here, - Task* task) OVERRIDE; - virtual bool PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, - Task* task, - int64 delay_ms) OVERRIDE; - + // base::MessageLoopProxy implementation. virtual bool PostTask( const tracked_objects::Location& from_here, const base::Closure& task) OVERRIDE; @@ -67,7 +52,6 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { private: static void TaskSpringboard(void* data); - void RunTaskIf(Task* task); void RunClosureIf(const base::Closure& task); base::PlatformThreadId plugin_thread_id_; diff --git a/remoting/jingle_glue/jingle_thread_unittest.cc b/remoting/jingle_glue/jingle_thread_unittest.cc index 287af05..9deb8db 100644 --- a/remoting/jingle_glue/jingle_thread_unittest.cc +++ b/remoting/jingle_glue/jingle_thread_unittest.cc @@ -1,7 +1,9 @@ -// Copyright (c) 2010 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. +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/message_loop.h" #include "base/time.h" #include "base/synchronization/waitable_event.h" @@ -11,35 +13,39 @@ namespace remoting { -class MockTask : public Task { +class MockCallback { public: MOCK_METHOD0(Run, void()); }; namespace { + // Delay used to test delayed tasks. Shouldn't be too big, so that we don't // slow down the test, yet, should be big enough to be measurable. int kDelayMs = 50; // 0.05 s. int kDelayTimeoutMs = 10000; // 10 s. + } // namespace TEST(JingleThreadTest, PostTask) { JingleThread thread; - MockTask* task = new MockTask(); - EXPECT_CALL(*task, Run()); + MockCallback task; + EXPECT_CALL(task, Run()); thread.Start(); - thread.message_loop()->PostTask(FROM_HERE, task); + thread.message_loop()->PostTask( + FROM_HERE, base::Bind(&MockCallback::Run, base::Unretained(&task))); thread.Stop(); } TEST(JingleThreadTest, PostNonNestableTask) { JingleThread thread; - MockTask* task = new MockTask(); - EXPECT_CALL(*task, Run()); + MockCallback task; + EXPECT_CALL(task, Run()); thread.Start(); - thread.message_loop()->PostNonNestableTask(FROM_HERE, task); + thread.message_loop()->PostNonNestableTask( + FROM_HERE, base::Bind(&MockCallback::Run, base::Unretained(&task))); thread.Stop(); } @@ -49,13 +55,15 @@ ACTION_P(SignalEvent, event) { TEST(JingleThreadTest, PostDelayedTask) { JingleThread thread; - MockTask* task = new MockTask(); + MockCallback task; base::WaitableEvent event(true, false); - EXPECT_CALL(*task, Run()).WillOnce(SignalEvent(&event)); + EXPECT_CALL(task, Run()).WillOnce(SignalEvent(&event)); thread.Start(); base::Time start = base::Time::Now(); - thread.message_loop()->PostDelayedTask(FROM_HERE, task, kDelayMs); + thread.message_loop()->PostDelayedTask( + FROM_HERE, base::Bind(&MockCallback::Run, base::Unretained(&task)), + kDelayMs); event.TimedWait(base::TimeDelta::FromMilliseconds(kDelayTimeoutMs)); base::Time end = base::Time::Now(); thread.Stop(); @@ -65,13 +73,15 @@ TEST(JingleThreadTest, PostDelayedTask) { TEST(JingleThreadTest, PostNonNestableDelayedTask) { JingleThread thread; - MockTask* task = new MockTask(); + MockCallback task; base::WaitableEvent event(true, false); - EXPECT_CALL(*task, Run()).WillOnce(SignalEvent(&event)); + EXPECT_CALL(task, Run()).WillOnce(SignalEvent(&event)); thread.Start(); base::Time start = base::Time::Now(); - thread.message_loop()->PostNonNestableDelayedTask(FROM_HERE, task, kDelayMs); + thread.message_loop()->PostNonNestableDelayedTask( + FROM_HERE, base::Bind(&MockCallback::Run, base::Unretained(&task)), + kDelayMs); event.TimedWait(base::TimeDelta::FromMilliseconds(kDelayTimeoutMs)); base::Time end = base::Time::Now(); thread.Stop(); |