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

Side by Side Diff: remoting/base/rate_counter.h

Issue 2911893003: Deprecate NonThreadSafe in remoting in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « remoting/base/oauth_token_getter_impl.cc ('k') | remoting/base/rate_counter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 REMOTING_BASE_RATE_COUNTER_H_ 5 #ifndef REMOTING_BASE_RATE_COUNTER_H_
6 #define REMOTING_BASE_RATE_COUNTER_H_ 6 #define REMOTING_BASE_RATE_COUNTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/sequence_checker.h"
15 #include "base/time/default_tick_clock.h" 15 #include "base/time/default_tick_clock.h"
16 #include "base/time/tick_clock.h" 16 #include "base/time/tick_clock.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 // Measures average rate per second of a sequence of point rate samples 21 // Measures average rate per second of a sequence of point rate samples
22 // over a specified time window. This can be used to measure bandwidth, frame 22 // over a specified time window. This can be used to measure bandwidth, frame
23 // rates, etc. 23 // rates, etc.
24 class RateCounter : public base::NonThreadSafe { 24 class RateCounter {
25 public: 25 public:
26 // Constructs a rate counter over the specified |time_window|. 26 // Constructs a rate counter over the specified |time_window|.
27 explicit RateCounter(base::TimeDelta time_window); 27 explicit RateCounter(base::TimeDelta time_window);
28 virtual ~RateCounter(); 28 virtual ~RateCounter();
29 29
30 // Records a point event count to include in the rate. 30 // Records a point event count to include in the rate.
31 void Record(int64_t value); 31 void Record(int64_t value);
32 32
33 // Returns the rate-per-second of values recorded over the time window. 33 // Returns the rate-per-second of values recorded over the time window.
34 // Note that rates reported before |time_window| has elapsed are not accurate. 34 // Note that rates reported before |time_window| has elapsed are not accurate.
(...skipping 15 matching lines...) Expand all
50 50
51 // Queue containing data points in the order in which they were recorded. 51 // Queue containing data points in the order in which they were recorded.
52 std::queue<DataPoint> data_points_; 52 std::queue<DataPoint> data_points_;
53 53
54 // Sum of values in |data_points_|. 54 // Sum of values in |data_points_|.
55 int64_t sum_; 55 int64_t sum_;
56 56
57 base::DefaultTickClock default_tick_clock_; 57 base::DefaultTickClock default_tick_clock_;
58 base::TickClock* tick_clock_ = &default_tick_clock_; 58 base::TickClock* tick_clock_ = &default_tick_clock_;
59 59
60 SEQUENCE_CHECKER(sequence_checker_);
61
60 DISALLOW_COPY_AND_ASSIGN(RateCounter); 62 DISALLOW_COPY_AND_ASSIGN(RateCounter);
61 }; 63 };
62 64
63 } // namespace remoting 65 } // namespace remoting
64 66
65 #endif // REMOTING_BASE_RATE_COUNTER_H_ 67 #endif // REMOTING_BASE_RATE_COUNTER_H_
OLDNEW
« no previous file with comments | « remoting/base/oauth_token_getter_impl.cc ('k') | remoting/base/rate_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698