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

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

Issue 2628733004: Update ConnectionEventTracker to check if there is an in progress attempt. (Closed)
Patch Set: Created 3 years, 11 months 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
« no previous file with comments | « no previous file | google_apis/gcm/engine/connection_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/connection_event_tracker.cc
diff --git a/google_apis/gcm/engine/connection_event_tracker.cc b/google_apis/gcm/engine/connection_event_tracker.cc
index cad77ebd37e1387c8c24e1fadc0d7ca85401beaa..223cafcf0e38c84fbe8c7dc028a33ebaeb2c13bd 100644
--- a/google_apis/gcm/engine/connection_event_tracker.cc
+++ b/google_apis/gcm/engine/connection_event_tracker.cc
@@ -32,17 +32,22 @@ void ConnectionEventTracker::StartConnectionAttempt() {
}
void ConnectionEventTracker::EndConnectionAttempt() {
- // TODO(harkness): Modify tests so that we can put a DCHECK here.
Peter Beverloo 2017/01/11 14:31:48 Why isn't the TODO relevant anymore?
- if (completed_events_.size() == kMaxClientEvents) {
- // Don't let the completed events grow beyond the max.
- completed_events_.pop_front();
- number_discarded_events_++;
+ // It is possible to get EndConnectionAttempt when there is not an in progress
+ // event, because EndConnectionAttempt is called from SignalConnectionReset,
+ // which will be called any time the network changes state. Only save the
+ // current_event_ if it has data.
+ if (current_event_.has_time_connection_started_ms()) {
Peter Beverloo 2017/01/11 14:31:48 style nit: prefer early return over nesting. if
harkness 2017/01/12 11:04:48 No longer applicable.
+ if (completed_events_.size() == kMaxClientEvents) {
+ // Don't let the completed events grow beyond the max.
+ completed_events_.pop_front();
+ number_discarded_events_++;
+ }
+
+ // Current event is finished, so add it to our list of completed events.
+ current_event_.set_time_connection_ended_ms(base::Time::Now().ToJavaTime());
+ completed_events_.push_back(current_event_);
+ current_event_.Clear();
}
-
- // Current event is now completed, so add it to our list of completed events.
- current_event_.set_time_connection_ended_ms(base::Time::Now().ToJavaTime());
- completed_events_.push_back(current_event_);
- current_event_.Clear();
}
void ConnectionEventTracker::ConnectionAttemptSucceeded() {
« no previous file with comments | « no previous file | google_apis/gcm/engine/connection_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698