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

Unified Diff: net/base/bandwidth_metrics.cc

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 side-by-side diff with in-line comments
Download patch
Index: net/base/bandwidth_metrics.cc
diff --git a/net/base/bandwidth_metrics.cc b/net/base/bandwidth_metrics.cc
index eaaa3c01b89a267881f076d01ddbe4fc67b9afb1..fa23a77da5423e2d61054a0fde7581751aeb06ac 100644
--- a/net/base/bandwidth_metrics.cc
+++ b/net/base/bandwidth_metrics.cc
@@ -2,14 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/singleton.h"
+#include "base/lazy_instance.h"
#include "net/base/bandwidth_metrics.h"
+static base::LazyInstance<net::BandwidthMetrics> g_bandwidth_metrics(
+ base::LINKER_INITIALIZED);
+
namespace net {
ScopedBandwidthMetrics::ScopedBandwidthMetrics()
- : metrics_(Singleton<BandwidthMetrics>::get()),
- started_(false) {
+ : started_(false) {
+}
+
+ScopedBandwidthMetrics::~ScopedBandwidthMetrics() {
+ if (started_)
+ g_bandwidth_metrics.Get().StopStream();
+}
+
+void ScopedBandwidthMetrics::StartStream() {
+ started_ = true;
+ g_bandwidth_metrics.Get().StartStream();
+}
+
+void ScopedBandwidthMetrics::StopStream() {
+ started_ = false;
+ g_bandwidth_metrics.Get().StopStream();
+}
+
+void ScopedBandwidthMetrics::RecordBytes(int bytes) {
+ g_bandwidth_metrics.Get().RecordBytes(bytes);
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698