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 |