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 67dab986357359282be3801f335d061de23c1f9d..feb16367edae64f8472652b087b1511690ecadfa 100644 |
| --- a/google_apis/gcm/engine/connection_factory_impl.cc |
| +++ b/google_apis/gcm/engine/connection_factory_impl.cc |
| @@ -205,6 +205,10 @@ void ConnectionFactoryImpl::SignalConnectionReset( |
| // connection. |
| } |
| + if (logging_in_) |
| + event_tracker_.ConnectionLoginFailed(); |
| + event_tracker_.EndConnectionAttempt(); |
|
Peter Beverloo
2016/12/02 15:19:13
It seems to me like you'd want this to live in Con
harkness
2016/12/05 15:39:01
The problem here may be naming. The issue is that
Peter Beverloo
2016/12/05 16:29:34
When a connection attempt fails, the connection it
|
| + |
| CloseSocket(); |
| DCHECK(!IsEndpointReachable()); |
| @@ -260,6 +264,9 @@ base::TimeTicks ConnectionFactoryImpl::NextRetryAttempt() const { |
| void ConnectionFactoryImpl::OnNetworkChanged( |
| net::NetworkChangeNotifier::ConnectionType type) { |
| + // Let the connection tracker know about the network type. |
|
Peter Beverloo
2016/12/02 15:19:13
nit: I'd drop the comment. It's already clear from
harkness
2016/12/05 15:39:00
Removed.
|
| + event_tracker_.OnNetworkChanged(type); |
| + |
| if (type == net::NetworkChangeNotifier::CONNECTION_NONE) { |
| DVLOG(1) << "Network lost, resettion connection."; |
| waiting_for_network_online_ = true; |
| @@ -296,6 +303,11 @@ net::IPEndPoint ConnectionFactoryImpl::GetPeerIP() { |
| } |
| void ConnectionFactoryImpl::ConnectImpl() { |
| + event_tracker_.StartConnectionAttempt(); |
| + StartConnection(); |
| +} |
| + |
| +void ConnectionFactoryImpl::StartConnection() { |
| DCHECK(!IsEndpointReachable()); |
| // TODO(zea): Make this a dcheck again. crbug.com/462319 |
| CHECK(!socket_handle_.socket()); |
| @@ -324,6 +336,7 @@ void ConnectionFactoryImpl::InitHandler() { |
| // May be null in tests. |
| mcs_proto::LoginRequest login_request; |
| if (!request_builder_.is_null()) { |
| + event_tracker_.WriteToLoginRequest(&login_request); |
|
Peter Beverloo
2016/12/02 15:19:13
MCSClient::ResetStateAndBuildLoginRequest actually
harkness
2016/12/05 15:39:00
Nice catch! It looks like this isn't caught by the
|
| request_builder_.Run(&login_request); |
| DCHECK(login_request.IsInitialized()); |
| } |
| @@ -371,6 +384,9 @@ void ConnectionFactoryImpl::OnConnectDone(int result) { |
| backoff_entry_->InformOfRequest(false); |
| UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionFailureErrorCode", result); |
| + event_tracker_.ConnectionAttemptFailed(result); |
| + event_tracker_.EndConnectionAttempt(); |
| + |
| // If there are other endpoints available, use the next endpoint on the |
| // subsequent retry. |
| next_endpoint_++; |
| @@ -419,6 +435,8 @@ void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) { |
| backoff_entry_->Reset(); |
| logging_in_ = false; |
| + event_tracker_.ConnectionAttemptSucceeded(); |
|
Peter Beverloo
2016/12/02 15:19:13
It seems to me that, logically, this would be a be
harkness
2016/12/05 15:39:01
Actually, I think this placement is correct. The m
Peter Beverloo
2016/12/05 16:29:34
Acknowledged.
|
| + |
| if (listener_) |
| listener_->OnConnected(GetCurrentEndpoint(), GetPeerIP()); |
| } |