Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Unified Diff: base/test/scoped_mock_time_message_loop_task_runner.cc

Issue 2627863002: Split Closure part of TestPendingTask out of the struct (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_mock_time_message_loop_task_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_mock_time_message_loop_task_runner.cc
diff --git a/base/test/scoped_mock_time_message_loop_task_runner.cc b/base/test/scoped_mock_time_message_loop_task_runner.cc
index 03c9c42c2292cfcd36e136d72182c15ba1102060..eba24e6c8039c21349e42c7c38deb9c48c6b24b5 100644
--- a/base/test/scoped_mock_time_message_loop_task_runner.cc
+++ b/base/test/scoped_mock_time_message_loop_task_runner.cc
@@ -6,14 +6,24 @@
#include <deque>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/test/test_pending_task.h"
+#include "base/test/test_pending_task_info.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
namespace base {
+namespace {
+
+// TODO(tzik): Remove this helper once TaskRunner has migrated from Closure to
+// OnceClosure.
+void RunOnceClosure(OnceClosure closure) {
+ std::move(closure).Run();
+}
+
+} // namespace
ScopedMockTimeMessageLoopTaskRunner::ScopedMockTimeMessageLoopTaskRunner()
: task_runner_(new TestMockTimeTaskRunner),
@@ -28,10 +38,12 @@ ScopedMockTimeMessageLoopTaskRunner::ScopedMockTimeMessageLoopTaskRunner()
ScopedMockTimeMessageLoopTaskRunner::~ScopedMockTimeMessageLoopTaskRunner() {
DCHECK(previous_task_runner_->RunsTasksOnCurrentThread());
DCHECK_EQ(task_runner_, ThreadTaskRunnerHandle::Get());
- for (const auto& pending_task : task_runner_->TakePendingTasks()) {
+ for (auto& pending_task : task_runner_->TakePendingTasks()) {
+ const TestPendingTaskInfo& task_info = pending_task.first;
+ OnceClosure task = std::move(pending_task.second);
previous_task_runner_->PostDelayedTask(
- pending_task.location, pending_task.task,
- pending_task.GetTimeToRun() - task_runner_->NowTicks());
+ task_info.location, Bind(&RunOnceClosure, Passed(&task)),
+ task_info.GetTimeToRun() - task_runner_->NowTicks());
}
MessageLoop::current()->SetTaskRunner(std::move(previous_task_runner_));
}
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_mock_time_message_loop_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698