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

Side by Side Diff: remoting/base/running_samples.cc

Issue 2871143003: Adding ThreadChecker statement to d'tor for remoting/base classes (Closed)
Patch Set: Created 3 years, 7 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/buffered_socket_writer.cc ('k') | remoting/base/telemetry_log_writer.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "remoting/base/running_samples.h" 5 #include "remoting/base/running_samples.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace remoting { 11 namespace remoting {
12 12
13 RunningSamples::RunningSamples(int window_size) 13 RunningSamples::RunningSamples(int window_size)
14 : window_size_(window_size) { 14 : window_size_(window_size) {
15 DCHECK_GT(window_size, 0); 15 DCHECK_GT(window_size, 0);
16 } 16 }
17 17
18 RunningSamples::~RunningSamples() {} 18 RunningSamples::~RunningSamples() {
19 DCHECK(thread_checker_.CalledOnValidThread());
20 }
19 21
20 void RunningSamples::Record(int64_t value) { 22 void RunningSamples::Record(int64_t value) {
21 DCHECK(thread_checker_.CalledOnValidThread()); 23 DCHECK(thread_checker_.CalledOnValidThread());
22 24
23 data_points_.push_back(value); 25 data_points_.push_back(value);
24 sum_ += value; 26 sum_ += value;
25 27
26 if (data_points_.size() > window_size_) { 28 if (data_points_.size() > window_size_) {
27 sum_ -= data_points_[0]; 29 sum_ -= data_points_[0];
28 data_points_.pop_front(); 30 data_points_.pop_front();
(...skipping 11 matching lines...) Expand all
40 int64_t RunningSamples::Max() const { 42 int64_t RunningSamples::Max() const {
41 DCHECK(thread_checker_.CalledOnValidThread()); 43 DCHECK(thread_checker_.CalledOnValidThread());
42 44
43 if (data_points_.empty()) 45 if (data_points_.empty())
44 return 0; 46 return 0;
45 47
46 return *std::max_element(data_points_.begin(), data_points_.end()); 48 return *std::max_element(data_points_.begin(), data_points_.end());
47 } 49 }
48 50
49 } // namespace remoting 51 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/buffered_socket_writer.cc ('k') | remoting/base/telemetry_log_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698