| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_COPRESENCE_TIMED_MAP_H_ | 5 #ifndef COMPONENTS_COPRESENCE_TIMED_MAP_H_ |
| 6 #define COMPONENTS_COPRESENCE_TIMED_MAP_H_ | 6 #define COMPONENTS_COPRESENCE_TIMED_MAP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return left.second > right.second; | 89 return left.second > right.second; |
| 90 } | 90 } |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 using ExpiryQueue = std::priority_queue< | 93 using ExpiryQueue = std::priority_queue< |
| 94 KeyTimeTuple, std::vector<KeyTimeTuple>, EarliestFirstComparator>; | 94 KeyTimeTuple, std::vector<KeyTimeTuple>, EarliestFirstComparator>; |
| 95 | 95 |
| 96 const ValueType kEmptyValue; | 96 const ValueType kEmptyValue; |
| 97 | 97 |
| 98 scoped_ptr<base::TickClock> clock_; | 98 scoped_ptr<base::TickClock> clock_; |
| 99 base::RepeatingTimer<TimedMap> timer_; | 99 base::RepeatingTimer timer_; |
| 100 const base::TimeDelta lifetime_; | 100 const base::TimeDelta lifetime_; |
| 101 const size_t max_elements_; | 101 const size_t max_elements_; |
| 102 std::map<KeyType, ValueType> map_; | 102 std::map<KeyType, ValueType> map_; |
| 103 // Priority queue with our element keys ordered by the earliest expiring keys | 103 // Priority queue with our element keys ordered by the earliest expiring keys |
| 104 // first. | 104 // first. |
| 105 ExpiryQueue expiry_queue_; | 105 ExpiryQueue expiry_queue_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(TimedMap); | 107 DISALLOW_COPY_AND_ASSIGN(TimedMap); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace copresence | 110 } // namespace copresence |
| 111 | 111 |
| 112 #endif // COMPONENTS_COPRESENCE_TIMED_MAP_H_ | 112 #endif // COMPONENTS_COPRESENCE_TIMED_MAP_H_ |
| OLD | NEW |