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

Side by Side Diff: net/base/bandwidth_metrics.h

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 NET_BASE_BANDWIDTH_METRICS_H_ 5 #ifndef NET_BASE_BANDWIDTH_METRICS_H_
6 #define NET_BASE_BANDWIDTH_METRICS_H_ 6 #define NET_BASE_BANDWIDTH_METRICS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int64 bytes_since_last_start_; // Bytes tracked during this "session". 115 int64 bytes_since_last_start_; // Bytes tracked during this "session".
116 base::TimeTicks last_start_; // Timestamp of the begin of this "session". 116 base::TimeTicks last_start_; // Timestamp of the begin of this "session".
117 }; 117 };
118 118
119 // A utility class for managing the lifecycle of a measured stream. 119 // A utility class for managing the lifecycle of a measured stream.
120 // It is important that we not leave unclosed streams, and this class helps 120 // It is important that we not leave unclosed streams, and this class helps
121 // ensure we always stop them. 121 // ensure we always stop them.
122 class ScopedBandwidthMetrics { 122 class ScopedBandwidthMetrics {
123 public: 123 public:
124 ScopedBandwidthMetrics(); 124 ScopedBandwidthMetrics();
125 ~ScopedBandwidthMetrics();
125 126
126 ~ScopedBandwidthMetrics() { 127 void StartStream();
127 if (started_) 128 void StopStream();
128 metrics_->StopStream(); 129 void RecordBytes(int bytes);
129 }
130
131 void StartStream() {
132 started_ = true;
133 metrics_->StartStream();
134 }
135
136 void StopStream() {
137 started_ = false;
138 metrics_->StopStream();
139 }
140
141 void RecordBytes(int bytes) { metrics_->RecordBytes(bytes); }
142 130
143 private: 131 private:
144 BandwidthMetrics* metrics_;
145 bool started_; 132 bool started_;
146 }; 133 };
147 134
148 } // namespace net 135 } // namespace net
149 136
150 #endif // NET_BASE_BANDWIDTH_METRICS_H_ 137 #endif // NET_BASE_BANDWIDTH_METRICS_H_
151
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698