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

Side by Side Diff: content/browser/download/rate_estimator.h

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_
6 #define CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <string> 11 #include <string>
9 #include <vector> 12 #include <vector>
10 13
11 #include "base/basictypes.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
14 16
15 namespace content { 17 namespace content {
16 18
17 // RateEstimator generates rate estimates based on recent activity. 19 // RateEstimator generates rate estimates based on recent activity.
18 // 20 //
19 // Internally it uses a fixed-size ring buffer, and develops estimates 21 // Internally it uses a fixed-size ring buffer, and develops estimates
20 // based on a small sliding window of activity. 22 // based on a small sliding window of activity.
21 class CONTENT_EXPORT RateEstimator { 23 class CONTENT_EXPORT RateEstimator {
22 public: 24 public:
23 RateEstimator(); 25 RateEstimator();
24 RateEstimator(base::TimeDelta bucket_time, 26 RateEstimator(base::TimeDelta bucket_time,
25 size_t num_buckets, 27 size_t num_buckets,
26 base::TimeTicks now); 28 base::TimeTicks now);
27 ~RateEstimator(); 29 ~RateEstimator();
28 30
29 // Increment the counter by |count|. The first variant uses the current time, 31 // Increment the counter by |count|. The first variant uses the current time,
30 // the second variant provides the time that |count| is observed. 32 // the second variant provides the time that |count| is observed.
31 void Increment(uint32 count); 33 void Increment(uint32_t count);
32 void Increment(uint32 count, base::TimeTicks now); 34 void Increment(uint32_t count, base::TimeTicks now);
33 35
34 // Get a rate estimate, in terms of counts/second. The first variant uses the 36 // Get a rate estimate, in terms of counts/second. The first variant uses the
35 // current time, the second variant provides the time. 37 // current time, the second variant provides the time.
36 uint64 GetCountPerSecond() const; 38 uint64_t GetCountPerSecond() const;
37 uint64 GetCountPerSecond(base::TimeTicks now) const; 39 uint64_t GetCountPerSecond(base::TimeTicks now) const;
38 40
39 private: 41 private:
40 void ClearOldBuckets(base::TimeTicks now); 42 void ClearOldBuckets(base::TimeTicks now);
41 void ResetBuckets(base::TimeTicks now); 43 void ResetBuckets(base::TimeTicks now);
42 44
43 std::vector<uint32> history_; 45 std::vector<uint32_t> history_;
44 base::TimeDelta bucket_time_; 46 base::TimeDelta bucket_time_;
45 size_t oldest_index_; 47 size_t oldest_index_;
46 size_t bucket_count_; 48 size_t bucket_count_;
47 base::TimeTicks oldest_time_; 49 base::TimeTicks oldest_time_;
48 }; 50 };
49 51
50 } // namespace content 52 } // namespace content
51 53
52 #endif // CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_ 54 #endif // CONTENT_BROWSER_DOWNLOAD_RATE_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « content/browser/download/mock_download_file.h ('k') | content/browser/download/rate_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698