Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Unified Diff: google_apis/gcm/engine/connection_factory_impl.cc

Issue 2481873002: Added ClientEvent proto and structure for storing events in the factory. (Closed)
Patch Set: Integrated code review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..20117b60db11abe01941b47bf1a56d813cc71f7e 100644
--- a/google_apis/gcm/engine/connection_factory_impl.cc
+++ b/google_apis/gcm/engine/connection_factory_impl.cc
@@ -124,6 +124,10 @@ void ConnectionFactoryImpl::Connect() {
ConnectWithBackoff();
}
+ConnectionEventTracker* ConnectionFactoryImpl::GetEventTrackerForTesting() {
+ return &event_tracker_;
+}
+
void ConnectionFactoryImpl::ConnectWithBackoff() {
// If a canary managed to connect while a backoff expiration was pending,
// just cleanup the internal state.
@@ -205,6 +209,10 @@ void ConnectionFactoryImpl::SignalConnectionReset(
// connection.
}
+ if (logging_in_)
+ event_tracker_.ConnectionLoginFailed();
+ event_tracker_.EndConnectionAttempt();
+
CloseSocket();
DCHECK(!IsEndpointReachable());
@@ -296,6 +304,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());
@@ -326,6 +339,7 @@ void ConnectionFactoryImpl::InitHandler() {
if (!request_builder_.is_null()) {
request_builder_.Run(&login_request);
DCHECK(login_request.IsInitialized());
+ event_tracker_.WriteToLoginRequest(&login_request);
}
connection_handler_->Init(login_request, socket_handle_.socket());
@@ -371,6 +385,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 +436,8 @@ void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) {
backoff_entry_->Reset();
logging_in_ = false;
+ event_tracker_.ConnectionAttemptSucceeded();
+
if (listener_)
listener_->OnConnected(GetCurrentEndpoint(), GetPeerIP());
}
« no previous file with comments | « google_apis/gcm/engine/connection_factory_impl.h ('k') | google_apis/gcm/engine/connection_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698