diff options
author | simonhong@chromium.org <simonhong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-04 07:04:32 +0000 |
---|---|---|
committer | simonhong@chromium.org <simonhong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-04 07:04:32 +0000 |
commit | eade06d5228433c3e7cfa19dfeebce7f9620d194 (patch) | |
tree | 02777e49f14209c54ce67fe2b63e44071694cd89 /cc/base/rolling_time_delta_history.h | |
parent | fe1afdbc112c34e3fa9625a0d53c33204114cbc7 (diff) | |
download | chromium_src-eade06d5228433c3e7cfa19dfeebce7f9620d194.zip chromium_src-eade06d5228433c3e7cfa19dfeebce7f9620d194.tar.gz chromium_src-eade06d5228433c3e7cfa19dfeebce7f9620d194.tar.bz2 |
[cc] cleanup: re-arrange some file locations in cc/scheduler
* Move rolling_time_delta_history.[cc|h] to cc/base
* Move texture_uploader.[cc|h] to cc/resources
R=enne@chromium.org
BUG=340190
TEST=cc_unittests
Review URL: https://codereview.chromium.org/130173007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base/rolling_time_delta_history.h')
-rw-r--r-- | cc/base/rolling_time_delta_history.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cc/base/rolling_time_delta_history.h b/cc/base/rolling_time_delta_history.h new file mode 100644 index 0000000..e51fb86 --- /dev/null +++ b/cc/base/rolling_time_delta_history.h @@ -0,0 +1,44 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_ +#define CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_ + +#include <deque> +#include <set> + +#include "base/time/time.h" +#include "cc/base/cc_export.h" + +namespace cc { + +// Stores a limited number of samples. When the maximum size is reached, each +// insertion results in the deletion of the oldest remaining sample. +class CC_EXPORT RollingTimeDeltaHistory { + public: + explicit RollingTimeDeltaHistory(size_t max_size); + + ~RollingTimeDeltaHistory(); + + void InsertSample(base::TimeDelta time); + + void Clear(); + + // Returns the smallest sample that is greater than or equal to the specified + // percent of samples. If there aren't any samples, returns base::TimeDelta(). + base::TimeDelta Percentile(double percent) const; + + private: + typedef std::multiset<base::TimeDelta> TimeDeltaMultiset; + + TimeDeltaMultiset sample_set_; + std::deque<TimeDeltaMultiset::iterator> chronological_sample_deque_; + size_t max_size_; + + DISALLOW_COPY_AND_ASSIGN(RollingTimeDeltaHistory); +}; + +} // namespace cc + +#endif // CC_BASE_ROLLING_TIME_DELTA_HISTORY_H_ |