Chromium Code Reviews| Index: google_apis/gcm/engine/connection_factory_impl.cc |
| diff --git a/google_apis/gcm/engine/connection_factory_impl.cc b/google_apis/gcm/engine/connection_factory_impl.cc |
| index 73cfe51a1d938a6507207703f9fe6f74657e8d45..51a5d2b278ac2dca972c196da666ad8229cb82c4 100644 |
| --- a/google_apis/gcm/engine/connection_factory_impl.cc |
| +++ b/google_apis/gcm/engine/connection_factory_impl.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/sparse_histogram.h" |
| #include "google_apis/gcm/engine/connection_handler_impl.h" |
| +#include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| #include "google_apis/gcm/protocol/mcs.pb.h" |
| #include "net/base/net_errors.h" |
| #include "net/http/http_network_session.h" |
| @@ -44,7 +45,8 @@ ConnectionFactoryImpl::ConnectionFactoryImpl( |
| const std::vector<GURL>& mcs_endpoints, |
| const net::BackoffEntry::Policy& backoff_policy, |
| scoped_refptr<net::HttpNetworkSession> network_session, |
| - net::NetLog* net_log) |
| + net::NetLog* net_log, |
| + GCMStatsRecorder* recorder) |
| : mcs_endpoints_(mcs_endpoints), |
| next_endpoint_(0), |
| last_successful_endpoint_(0), |
| @@ -56,6 +58,7 @@ ConnectionFactoryImpl::ConnectionFactoryImpl( |
| connecting_(false), |
| waiting_for_backoff_(false), |
| logging_in_(false), |
| + recorder_(recorder), |
| weak_ptr_factory_(this) { |
| DCHECK_GE(mcs_endpoints_.size(), 1U); |
| } |
| @@ -118,6 +121,8 @@ void ConnectionFactoryImpl::ConnectWithBackoff() { |
| << backoff_entry_->GetTimeUntilRelease().InMilliseconds() |
| << " milliseconds."; |
| waiting_for_backoff_ = true; |
| + recorder_->RecordConnectionDelayedDueToBackoff( |
| + backoff_entry_->GetTimeUntilRelease().InMilliseconds()); |
| base::MessageLoop::current()->PostDelayedTask( |
| FROM_HERE, |
| base::Bind(&ConnectionFactoryImpl::ConnectWithBackoff, |
| @@ -147,6 +152,7 @@ void ConnectionFactoryImpl::SignalConnectionReset( |
| UMA_HISTOGRAM_ENUMERATION("GCM.ConnectionResetReason", |
| reason, |
| CONNECTION_RESET_COUNT); |
| + recorder_->RecordConnectionResetSignaled(reason); |
| if (!last_login_time_.is_null()) { |
| UMA_HISTOGRAM_CUSTOM_TIMES("GCM.ConnectionUpTime", |
| NowTicks() - last_login_time_, |
| @@ -233,8 +239,10 @@ void ConnectionFactoryImpl::ConnectImpl() { |
| DCHECK(!socket_handle_.socket()); |
| connecting_ = true; |
| + GURL cur_endpoint = GetCurrentEndpoint(); |
|
jianli
2014/04/23 17:22:35
nit: avoid using abbreviation if possible. so name
juyik
2014/04/23 21:36:56
Done.
|
| + recorder_->RecordConnectionInitiated(cur_endpoint.host()); |
| int status = network_session_->proxy_service()->ResolveProxy( |
| - GetCurrentEndpoint(), |
| + cur_endpoint, |
| &proxy_info_, |
| base::Bind(&ConnectionFactoryImpl::OnProxyResolveDone, |
| weak_ptr_factory_.GetWeakPtr()), |
| @@ -307,6 +315,7 @@ void ConnectionFactoryImpl::OnConnectDone(int result) { |
| UMA_HISTOGRAM_BOOLEAN("GCM.ConnectedViaProxy", |
| !(proxy_info_.is_empty() || proxy_info_.is_direct())); |
| ReportSuccessfulProxyConnection(); |
| + recorder_->RecordConnectionSuccess(); |
| // Reset the endpoint back to the default. |
| // TODO(zea): consider prioritizing endpoints more intelligently based on |