Fix high DPI with Surfaces by treating Surface size as content bounds of layer
[chromium-blink-merge.git] / cc / base / rolling_time_delta_history.h
blob603c813425fe6d3a070d3b915244da11880c193f
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
3 // found in the LICENSE file.
5 #ifndef CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_
6 #define CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_
8 #include <deque>
9 #include <set>
11 #include "base/time/time.h"
12 #include "cc/base/cc_export.h"
14 namespace cc {
16 // Stores a limited number of samples. When the maximum size is reached, each
17 // insertion results in the deletion of the oldest remaining sample.
18 class CC_EXPORT RollingTimeDeltaHistory {
19 public:
20 explicit RollingTimeDeltaHistory(size_t max_size);
22 ~RollingTimeDeltaHistory();
24 void InsertSample(base::TimeDelta time);
26 size_t SampleCount();
28 void Clear();
30 // Returns the smallest sample that is greater than or equal to the specified
31 // percent of samples. If there aren't any samples, returns base::TimeDelta().
32 base::TimeDelta Percentile(double percent) const;
34 private:
35 typedef std::multiset<base::TimeDelta> TimeDeltaMultiset;
37 TimeDeltaMultiset sample_set_;
38 std::deque<TimeDeltaMultiset::iterator> chronological_sample_deque_;
39 size_t max_size_;
41 DISALLOW_COPY_AND_ASSIGN(RollingTimeDeltaHistory);
44 } // namespace cc
46 #endif // CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_