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

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: s/base::ResetAndReturn/std::move/ 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..fbc4e1aa1ee4b46528ae67277da0676ee46c4c6a 100644
--- a/chrome/browser/memory/tab_manager_unittest.cc
+++ b/chrome/browser/memory/tab_manager_unittest.cc
@@ -8,6 +8,7 @@
#include <map>
#include <vector>
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
@@ -91,10 +92,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 +121,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 +136,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();
sky 2017/03/22 17:34:11 ?
std::pop_heap(tasks_.begin(), tasks_.end(), TaskComparator());
tasks_.pop_back();
++count;
@@ -595,7 +595,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 +622,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 +638,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());

Powered by Google App Engine
This is Rietveld 408576698