blob: 0644122d7ddc7dd7e7c0c7049bc3d2db5a0d5f0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/lazy_instance.h"
#include "net/base/bandwidth_metrics.h"
static base::LazyInstance<net::BandwidthMetrics> g_bandwidth_metrics =
LAZY_INSTANCE_INITIALIZER;
namespace net {
ScopedBandwidthMetrics::ScopedBandwidthMetrics()
: 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
|