| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_EVENT_TRACKER_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_EVENT_TRACKER_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "google_apis/gcm/base/gcm_export.h" |
| 12 #include "google_apis/gcm/protocol/mcs.pb.h" |
| 13 #include "net/base/net_errors.h" |
| 14 |
| 15 namespace gcm { |
| 16 |
| 17 class GCM_EXPORT ConnectionEventTracker { |
| 18 public: |
| 19 // TODO(harkness): Pass in the storage information. |
| 20 ConnectionEventTracker(); |
| 21 ~ConnectionEventTracker(); |
| 22 |
| 23 // Start recording a new connection attempt. This should never be called if |
| 24 // a connection attempt is already ongoing. |
| 25 void StartConnectionAttempt(); |
| 26 |
| 27 // Ends the record for a connection attempt and moves it to the completed |
| 28 // connections list. |
| 29 void EndConnectionAttempt(); |
| 30 |
| 31 // Record that the existing connection attempt has succeeded. Note that this |
| 32 // doesn't mean the connection is necessarily valid. It could still fail with |
| 33 // an authentication error. |
| 34 void ConnectionAttemptSucceeded(); |
| 35 |
| 36 // Records that the connection succeeded but then failed to login. |
| 37 void ConnectionLoginFailed(); |
| 38 |
| 39 // Record that the existing connection attempt has failed. |
| 40 void ConnectionAttemptFailed(int error); |
| 41 |
| 42 // Write any previous connection information to the |*login_request|. |
| 43 void WriteToLoginRequest(mcs_proto::LoginRequest* login_request); |
| 44 |
| 45 private: |
| 46 // Storage for all the events which have completed. |
| 47 std::deque<mcs_proto::ClientEvent> completed_events_; |
| 48 |
| 49 // Current connection attempt. |
| 50 mcs_proto::ClientEvent current_event_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(ConnectionEventTracker); |
| 53 }; |
| 54 |
| 55 } // namespace gcm |
| 56 |
| 57 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_EVENT_TRACKER_H_ |
| OLD | NEW |