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..1f2671ab9cedc05613272fcbb591933da1a31942 100644 |
--- a/google_apis/gcm/engine/connection_event_tracker.cc |
+++ b/google_apis/gcm/engine/connection_event_tracker.cc |
@@ -21,6 +21,10 @@ ConnectionEventTracker::ConnectionEventTracker() = default; |
ConnectionEventTracker::~ConnectionEventTracker() = default; |
+bool ConnectionEventTracker::EventInProgress() { |
+ return current_event_.has_time_connection_started_ms(); |
+} |
+ |
void ConnectionEventTracker::StartConnectionAttempt() { |
// TODO(harkness): Can we dcheck here that there is not an in progress |
// connection? |
@@ -32,14 +36,17 @@ void ConnectionEventTracker::StartConnectionAttempt() { |
} |
void ConnectionEventTracker::EndConnectionAttempt() { |
- // TODO(harkness): Modify tests so that we can put a DCHECK here. |
+ // EndConnectionAttempt should only be called if there was a previous |
+ // StartConnectionAttempt. |
Peter Beverloo
2017/01/12 16:03:27
optional nit: I'd drop the comment - that's obviou
harkness
2017/01/16 12:20:37
Done.
|
+ DCHECK(EventInProgress()); |
+ |
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 now completed, so add it to our list of completed 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(); |