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

Unified Diff: cc/test/ordered_simple_task_runner.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 | « cc/base/delayed_unique_notifier_unittest.cc ('k') | cc/test/ordered_simple_task_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/ordered_simple_task_runner.h
diff --git a/cc/test/ordered_simple_task_runner.h b/cc/test/ordered_simple_task_runner.h
index 9620a96058df422e00c841a5512bca675422d9f0..4dc1772d22e2801ee138127422172a3332a3f706 100644
--- a/cc/test/ordered_simple_task_runner.h
+++ b/cc/test/ordered_simple_task_runner.h
@@ -24,29 +24,33 @@ namespace cc {
// Subclass of TestPendingTask which has a unique ID for every task, supports
// being used inside a std::set and has debug tracing support.
-class TestOrderablePendingTask : public base::TestPendingTask {
+class TestOrderablePendingTaskInfo : public base::TestPendingTaskInfo {
public:
- TestOrderablePendingTask();
- TestOrderablePendingTask(const tracked_objects::Location& location,
- const base::Closure& task,
- base::TimeTicks post_time,
- base::TimeDelta delay,
- TestNestability nestability);
- ~TestOrderablePendingTask();
+ TestOrderablePendingTaskInfo();
+ TestOrderablePendingTaskInfo(const tracked_objects::Location& location,
+ base::TimeTicks post_time,
+ base::TimeDelta delay,
+ TestNestability nestability);
+ ~TestOrderablePendingTaskInfo();
// operators needed by std::set and comparison
- bool operator==(const TestOrderablePendingTask& other) const;
- bool operator<(const TestOrderablePendingTask& other) const;
+ bool operator==(const TestOrderablePendingTaskInfo& other) const;
+ bool operator<(const TestOrderablePendingTaskInfo& other) const;
// base::trace_event tracing functionality
std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
void AsValueInto(base::trace_event::TracedValue* state) const;
+ size_t task_id() const { return task_id_; }
+
private:
static size_t task_id_counter;
const size_t task_id_;
};
+using TestOrderablePendingTaskQueue =
+ std::map<TestOrderablePendingTaskInfo, base::OnceClosure>;
+
// This runs pending tasks based on task's post_time + delay.
// We should not execute a delayed task sooner than some of the queued tasks
// which don't have a delay even though it is queued early.
@@ -132,8 +136,7 @@ class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner {
protected:
static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run);
- bool TaskExistedInitiallyCallback(
- const std::set<TestOrderablePendingTask>& existing_tasks);
+ bool TaskExistedInitiallyCallback(const std::set<size_t>& existing_task_ids);
bool NowBeforeCallback(base::TimeTicks stop_at);
bool AdvanceNowCallback();
@@ -148,7 +151,7 @@ class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner {
size_t max_tasks_;
bool inside_run_tasks_until_;
- std::set<TestOrderablePendingTask> pending_tasks_;
+ TestOrderablePendingTaskQueue pending_tasks_;
private:
DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner);
« no previous file with comments | « cc/base/delayed_unique_notifier_unittest.cc ('k') | cc/test/ordered_simple_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698