| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "net/socket/client_socket_pool_histograms.h" | 5 #include "net/socket/client_socket_pool_histograms.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/socket/client_socket_handle.h" | 12 #include "net/socket/client_socket_handle.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 using base::Histogram; | 16 using base::Histogram; |
| 17 using base::HistogramBase; | 17 using base::HistogramBase; |
| 18 using base::LinearHistogram; | 18 using base::LinearHistogram; |
| 19 using base::CustomHistogram; | 19 using base::CustomHistogram; |
| 20 | 20 |
| 21 ClientSocketPoolHistograms::ClientSocketPoolHistograms( | 21 ClientSocketPoolHistograms::ClientSocketPoolHistograms( |
| 22 const std::string& pool_name) | 22 const std::string& pool_name) |
| 23 : is_http_proxy_connection_(false), | 23 : is_http_proxy_connection_(false), is_socks_connection_(false) { |
| 24 is_socks_connection_(false) { | |
| 25 // UMA_HISTOGRAM_ENUMERATION | 24 // UMA_HISTOGRAM_ENUMERATION |
| 26 socket_type_ = LinearHistogram::FactoryGet("Net.SocketType_" + pool_name, 1, | 25 socket_type_ = |
| 27 ClientSocketHandle::NUM_TYPES, ClientSocketHandle::NUM_TYPES + 1, | 26 LinearHistogram::FactoryGet("Net.SocketType_" + pool_name, |
| 28 HistogramBase::kUmaTargetedHistogramFlag); | 27 1, |
| 28 ClientSocketHandle::NUM_TYPES, |
| 29 ClientSocketHandle::NUM_TYPES + 1, |
| 30 HistogramBase::kUmaTargetedHistogramFlag); |
| 29 // UMA_HISTOGRAM_CUSTOM_TIMES | 31 // UMA_HISTOGRAM_CUSTOM_TIMES |
| 30 request_time_ = Histogram::FactoryTimeGet( | 32 request_time_ = |
| 31 "Net.SocketRequestTime_" + pool_name, | 33 Histogram::FactoryTimeGet("Net.SocketRequestTime_" + pool_name, |
| 32 base::TimeDelta::FromMilliseconds(1), | 34 base::TimeDelta::FromMilliseconds(1), |
| 33 base::TimeDelta::FromMinutes(10), | 35 base::TimeDelta::FromMinutes(10), |
| 34 100, HistogramBase::kUmaTargetedHistogramFlag); | 36 100, |
| 37 HistogramBase::kUmaTargetedHistogramFlag); |
| 35 // UMA_HISTOGRAM_CUSTOM_TIMES | 38 // UMA_HISTOGRAM_CUSTOM_TIMES |
| 36 unused_idle_time_ = Histogram::FactoryTimeGet( | 39 unused_idle_time_ = Histogram::FactoryTimeGet( |
| 37 "Net.SocketIdleTimeBeforeNextUse_UnusedSocket_" + pool_name, | 40 "Net.SocketIdleTimeBeforeNextUse_UnusedSocket_" + pool_name, |
| 38 base::TimeDelta::FromMilliseconds(1), | 41 base::TimeDelta::FromMilliseconds(1), |
| 39 base::TimeDelta::FromMinutes(6), | 42 base::TimeDelta::FromMinutes(6), |
| 40 100, HistogramBase::kUmaTargetedHistogramFlag); | 43 100, |
| 44 HistogramBase::kUmaTargetedHistogramFlag); |
| 41 // UMA_HISTOGRAM_CUSTOM_TIMES | 45 // UMA_HISTOGRAM_CUSTOM_TIMES |
| 42 reused_idle_time_ = Histogram::FactoryTimeGet( | 46 reused_idle_time_ = Histogram::FactoryTimeGet( |
| 43 "Net.SocketIdleTimeBeforeNextUse_ReusedSocket_" + pool_name, | 47 "Net.SocketIdleTimeBeforeNextUse_ReusedSocket_" + pool_name, |
| 44 base::TimeDelta::FromMilliseconds(1), | 48 base::TimeDelta::FromMilliseconds(1), |
| 45 base::TimeDelta::FromMinutes(6), | 49 base::TimeDelta::FromMinutes(6), |
| 46 100, HistogramBase::kUmaTargetedHistogramFlag); | 50 100, |
| 51 HistogramBase::kUmaTargetedHistogramFlag); |
| 47 // UMA_HISTOGRAM_CUSTOM_ENUMERATION | 52 // UMA_HISTOGRAM_CUSTOM_ENUMERATION |
| 48 error_code_ = CustomHistogram::FactoryGet( | 53 error_code_ = |
| 49 "Net.SocketInitErrorCodes_" + pool_name, | 54 CustomHistogram::FactoryGet("Net.SocketInitErrorCodes_" + pool_name, |
| 50 GetAllErrorCodesForUma(), | 55 GetAllErrorCodesForUma(), |
| 51 HistogramBase::kUmaTargetedHistogramFlag); | 56 HistogramBase::kUmaTargetedHistogramFlag); |
| 52 | 57 |
| 53 if (pool_name == "HTTPProxy") | 58 if (pool_name == "HTTPProxy") |
| 54 is_http_proxy_connection_ = true; | 59 is_http_proxy_connection_ = true; |
| 55 else if (pool_name == "SOCK") | 60 else if (pool_name == "SOCK") |
| 56 is_socks_connection_ = true; | 61 is_socks_connection_ = true; |
| 57 } | 62 } |
| 58 | 63 |
| 59 ClientSocketPoolHistograms::~ClientSocketPoolHistograms() { | 64 ClientSocketPoolHistograms::~ClientSocketPoolHistograms() { |
| 60 } | 65 } |
| 61 | 66 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 void ClientSocketPoolHistograms::AddReusedIdleTime(base::TimeDelta time) const { | 79 void ClientSocketPoolHistograms::AddReusedIdleTime(base::TimeDelta time) const { |
| 75 reused_idle_time_->AddTime(time); | 80 reused_idle_time_->AddTime(time); |
| 76 } | 81 } |
| 77 | 82 |
| 78 void ClientSocketPoolHistograms::AddErrorCode(int error_code) const { | 83 void ClientSocketPoolHistograms::AddErrorCode(int error_code) const { |
| 79 // Error codes are positive (since histograms expect positive sample values). | 84 // Error codes are positive (since histograms expect positive sample values). |
| 80 error_code_->Add(-error_code); | 85 error_code_->Add(-error_code); |
| 81 } | 86 } |
| 82 | 87 |
| 83 } // namespace net | 88 } // namespace net |
| OLD | NEW |