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

Unified Diff: base/test/test_pending_task_info.h

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/test_pending_task.cc ('k') | base/test/test_pending_task_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_pending_task_info.h
diff --git a/base/test/test_pending_task.h b/base/test/test_pending_task_info.h
similarity index 64%
rename from base/test/test_pending_task.h
rename to base/test/test_pending_task_info.h
index 2dbdb7eeccbdcc1927dca53114258f83eb06e477..81676244e00e2519d06a5bc37f8dd6fc68a6f6ed 100644
--- a/base/test/test_pending_task.h
+++ b/base/test/test_pending_task_info.h
@@ -2,32 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_TEST_TEST_PENDING_TASK_H_
-#define BASE_TEST_TEST_PENDING_TASK_H_
+#ifndef BASE_TEST_TEST_PENDING_TASK_INFO_H_
+#define BASE_TEST_TEST_PENDING_TASK_INFO_H_
+#include <deque>
+#include <iosfwd>
+#include <memory>
#include <string>
-#include "base/callback.h"
+#include "base/callback_forward.h"
#include "base/location.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event_argument.h"
namespace base {
-// TestPendingTask is a helper class for test TaskRunner
+// TestPendingTaskInfo is a helper class for test TaskRunner
// implementations. See test_simple_task_runner.h for example usage.
-struct TestPendingTask {
+struct TestPendingTaskInfo {
enum TestNestability { NESTABLE, NON_NESTABLE };
- TestPendingTask();
- TestPendingTask(const TestPendingTask& other);
- TestPendingTask(const tracked_objects::Location& location,
- const Closure& task,
- TimeTicks post_time,
- TimeDelta delay,
- TestNestability nestability);
- ~TestPendingTask();
+ TestPendingTaskInfo();
+ TestPendingTaskInfo(const TestPendingTaskInfo& other);
+ TestPendingTaskInfo(const tracked_objects::Location& location,
+ TimeTicks post_time,
+ TimeDelta delay,
+ TestNestability nestability);
+ ~TestPendingTaskInfo();
// Returns post_time + delay.
TimeTicks GetTimeToRun() const;
@@ -48,13 +50,12 @@ struct TestPendingTask {
//
// - std::max_element
// - std::sort.
- bool ShouldRunBefore(const TestPendingTask& other) const;
+ bool ShouldRunBefore(const TestPendingTaskInfo& other) const;
tracked_objects::Location location;
- Closure task;
TimeTicks post_time;
TimeDelta delay;
- TestNestability nestability;
+ TestNestability nestability = NESTABLE;
// Functions for using test pending task with tracing, useful in unit
// testing.
@@ -63,11 +64,14 @@ struct TestPendingTask {
std::string ToString() const;
};
+using TestPendingTaskQueue =
+ std::deque<std::pair<TestPendingTaskInfo, OnceClosure>>;
+
// gtest helpers which allow pretty printing of the tasks, very useful in unit
// testing.
-std::ostream& operator<<(std::ostream& os, const TestPendingTask& task);
-void PrintTo(const TestPendingTask& task, std::ostream* os);
+std::ostream& operator<<(std::ostream& os, const TestPendingTaskInfo& task);
+void PrintTo(const TestPendingTaskInfo& task, std::ostream* os);
} // namespace base
-#endif // BASE_TEST_TEST_PENDING_TASK_H_
+#endif // BASE_TEST_TEST_PENDING_TASK_INFO_H_
« no previous file with comments | « base/test/test_pending_task.cc ('k') | base/test/test_pending_task_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698