Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/task_scheduler/sequence_sort_key.h" | |
| 6 | |
| 7 namespace base { | |
| 8 namespace internal { | |
| 9 | |
| 10 SequenceSortKey::SequenceSortKey() : priority_(TaskPriority::BACKGROUND) {} | |
| 11 | |
| 12 SequenceSortKey::SequenceSortKey(TaskPriority priority, | |
| 13 TimeTicks next_task_post_time) | |
| 14 : priority_(priority), next_task_post_time_(next_task_post_time) {} | |
| 15 | |
| 16 bool SequenceSortKey::operator<(const SequenceSortKey& other) const { | |
| 17 if (static_cast<TaskPriorityUnderlyingType>(priority_) < | |
| 18 static_cast<TaskPriorityUnderlyingType>(other.priority_)) { | |
| 19 return true; | |
| 20 } | |
| 21 if (static_cast<TaskPriorityUnderlyingType>(priority_) > | |
| 22 static_cast<TaskPriorityUnderlyingType>(other.priority_)) { | |
| 23 return false; | |
| 24 } | |
| 25 return next_task_post_time_ > other.next_task_post_time_; | |
|
gab
2016/02/18 03:00:46
How about:
--------------
// Sort by highest prio
fdoray
2016/02/18 14:56:12
Done. Note: priority_diff > 0 instead of priorit
gab
2016/02/18 20:22:34
Ah oops, that's because I meant for priority_diff
| |
| 26 } | |
| 27 | |
| 28 bool SequenceSortKey::operator==(const SequenceSortKey& other) const { | |
| 29 return priority_ == other.priority_ && | |
| 30 next_task_post_time_ == other.next_task_post_time_; | |
| 31 } | |
| 32 | |
| 33 } // namespace internal | |
| 34 } // namespace base | |
| OLD | NEW |