roll skia to 4276
[chromium-blink-merge.git] / net / socket / client_socket_pool_histograms.cc
blob5c3bddb14af893963d31e55ee09451680b4a076f
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/socket/client_socket_pool_histograms.h"
7 #include <string>
9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h"
11 #include "net/socket/client_socket_handle.h"
13 namespace net {
15 using base::Histogram;
16 using base::LinearHistogram;
18 ClientSocketPoolHistograms::ClientSocketPoolHistograms(
19 const std::string& pool_name)
20 : is_http_proxy_connection_(false),
21 is_socks_connection_(false) {
22 // UMA_HISTOGRAM_ENUMERATION
23 socket_type_ = LinearHistogram::FactoryGet("Net.SocketType_" + pool_name, 1,
24 ClientSocketHandle::NUM_TYPES, ClientSocketHandle::NUM_TYPES + 1,
25 Histogram::kUmaTargetedHistogramFlag);
26 // UMA_HISTOGRAM_CUSTOM_TIMES
27 request_time_ = Histogram::FactoryTimeGet(
28 "Net.SocketRequestTime_" + pool_name,
29 base::TimeDelta::FromMilliseconds(1),
30 base::TimeDelta::FromMinutes(10),
31 100, Histogram::kUmaTargetedHistogramFlag);
32 // UMA_HISTOGRAM_CUSTOM_TIMES
33 unused_idle_time_ = Histogram::FactoryTimeGet(
34 "Net.SocketIdleTimeBeforeNextUse_UnusedSocket_" + pool_name,
35 base::TimeDelta::FromMilliseconds(1),
36 base::TimeDelta::FromMinutes(6),
37 100, Histogram::kUmaTargetedHistogramFlag);
38 // UMA_HISTOGRAM_CUSTOM_TIMES
39 reused_idle_time_ = Histogram::FactoryTimeGet(
40 "Net.SocketIdleTimeBeforeNextUse_ReusedSocket_" + pool_name,
41 base::TimeDelta::FromMilliseconds(1),
42 base::TimeDelta::FromMinutes(6),
43 100, Histogram::kUmaTargetedHistogramFlag);
45 if (pool_name == "HTTPProxy")
46 is_http_proxy_connection_ = true;
47 else if (pool_name == "SOCK")
48 is_socks_connection_ = true;
51 ClientSocketPoolHistograms::~ClientSocketPoolHistograms() {
54 void ClientSocketPoolHistograms::AddSocketType(int type) const {
55 socket_type_->Add(type);
58 void ClientSocketPoolHistograms::AddRequestTime(base::TimeDelta time) const {
59 request_time_->AddTime(time);
61 static const bool proxy_connection_impact_trial_exists =
62 base::FieldTrialList::TrialExists("ProxyConnectionImpact");
63 if (proxy_connection_impact_trial_exists && is_http_proxy_connection_) {
64 UMA_HISTOGRAM_CUSTOM_TIMES(
65 base::FieldTrial::MakeName("Net.HttpProxySocketRequestTime",
66 "ProxyConnectionImpact"),
67 time,
68 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10),
69 100);
71 if (proxy_connection_impact_trial_exists && is_socks_connection_) {
72 UMA_HISTOGRAM_CUSTOM_TIMES(
73 base::FieldTrial::MakeName("Net.SocksSocketRequestTime",
74 "ProxyConnectionImpact"),
75 time,
76 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10),
77 100);
81 void ClientSocketPoolHistograms::AddUnusedIdleTime(base::TimeDelta time) const {
82 unused_idle_time_->AddTime(time);
85 void ClientSocketPoolHistograms::AddReusedIdleTime(base::TimeDelta time) const {
86 reused_idle_time_->AddTime(time);
89 } // namespace net