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

Unified Diff: chrome/browser/memory/tab_manager_unittest.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 years, 9 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
Index: chrome/browser/memory/tab_manager_unittest.cc
diff --git a/chrome/browser/memory/tab_manager_unittest.cc b/chrome/browser/memory/tab_manager_unittest.cc
index 5fd7b77ff3e94375cca8756ad541df3e19bf01e9..0129a78edaaae0ddc0b58b68a31fc54fb13a40aa 100644
--- a/chrome/browser/memory/tab_manager_unittest.cc
+++ b/chrome/browser/memory/tab_manager_unittest.cc
@@ -91,10 +91,9 @@ class MockTabStripModelObserver : public TabStripModelObserver {
class LenientMockTaskRunner {
public:
LenientMockTaskRunner() {}
- MOCK_METHOD3(PostDelayedTask,
- bool(const tracked_objects::Location&,
- const base::Closure&,
- base::TimeDelta));
+ MOCK_METHOD2(PostDelayedTask,
+ bool(const tracked_objects::Location&, base::TimeDelta));
+
private:
DISALLOW_COPY_AND_ASSIGN(LenientMockTaskRunner);
};
@@ -121,11 +120,11 @@ class TaskRunnerProxy : public base::TaskRunner {
: mock_(mock), clock_(clock) {}
bool RunsTasksOnCurrentThread() const override { return true; }
bool PostDelayedTask(const tracked_objects::Location& location,
- const base::Closure& closure,
+ base::Closure closure,
base::TimeDelta delta) override {
- mock_->PostDelayedTask(location, closure, delta);
+ mock_->PostDelayedTask(location, delta);
base::TimeTicks when = clock_->NowTicks() + delta;
- tasks_.push_back(Task(when, closure));
+ tasks_.push_back(Task(when, std::move(closure)));
// Use 'greater' comparator to make this a min heap.
std::push_heap(tasks_.begin(), tasks_.end(), TaskComparator());
return true;
@@ -136,7 +135,7 @@ class TaskRunnerProxy : public base::TaskRunner {
base::TimeTicks now = clock_->NowTicks();
size_t count = 0;
while (!tasks_.empty() && tasks_.front().first <= now) {
- tasks_.front().second.Run();
+ std::move(tasks_.front().second).Run();
std::pop_heap(tasks_.begin(), tasks_.end(), TaskComparator());
tasks_.pop_back();
++count;
@@ -595,7 +594,6 @@ TEST_F(TabManagerTest, MAYBE_ChildProcessNotifications) {
&ReturnSpecifiedPressure, base::Unretained(&level));
EXPECT_CALL(mock_task_runner, PostDelayedTask(
testing::_,
- testing::_,
base::TimeDelta::FromSeconds(tm.kRendererNotificationDelayInSeconds)));
EXPECT_CALL(*this, NotifyRendererProcess(renderer2, level));
tm.OnMemoryPressure(level);
@@ -623,7 +621,6 @@ TEST_F(TabManagerTest, MAYBE_ChildProcessNotifications) {
// time to the foreground tab. It should also cause another scheduled event.
EXPECT_CALL(mock_task_runner, PostDelayedTask(
testing::_,
- testing::_,
base::TimeDelta::FromSeconds(tm.kRendererNotificationDelayInSeconds)));
EXPECT_CALL(*this, NotifyRendererProcess(renderer1, level));
EXPECT_EQ(1u, task_runner->RunNextTask());
@@ -640,7 +637,6 @@ TEST_F(TabManagerTest, MAYBE_ChildProcessNotifications) {
// background tab. It should also cause another scheduled event.
EXPECT_CALL(mock_task_runner, PostDelayedTask(
testing::_,
- testing::_,
base::TimeDelta::FromSeconds(tm.kRendererNotificationDelayInSeconds)));
EXPECT_CALL(*this, NotifyRendererProcess(renderer2, level));
EXPECT_EQ(1u, task_runner->RunNextTask());
« no previous file with comments | « chrome/browser/chromeos/login/users/mock_user_manager.cc ('k') | chromecast/base/system_time_change_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698