OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 typedef base::Callback< | 93 typedef base::Callback< |
94 void(int64 user_serial_number, | 94 void(int64 user_serial_number, |
95 const std::string& app_id, | 95 const std::string& app_id, |
96 const std::string& message_id, | 96 const std::string& message_id, |
97 MessageSendStatus status)> OnMessageSentCallback; | 97 MessageSendStatus status)> OnMessageSentCallback; |
98 | 98 |
99 MCSClient(const std::string& version_string, | 99 MCSClient(const std::string& version_string, |
100 base::Clock* clock, | 100 base::Clock* clock, |
101 ConnectionFactory* connection_factory, | 101 ConnectionFactory* connection_factory, |
102 GCMStore* gcm_store, | 102 GCMStore* gcm_store, |
103 GCMStatsRecorder* recorder, | 103 GCMStatsRecorder* recorder); |
104 scoped_ptr<base::Timer> heartbeat_timer); | |
105 virtual ~MCSClient(); | 104 virtual ~MCSClient(); |
106 | 105 |
107 // Initialize the client. Will load any previous id/token information as well | 106 // Initialize the client. Will load any previous id/token information as well |
108 // as unacknowledged message information from the GCM storage, if it exists, | 107 // as unacknowledged message information from the GCM storage, if it exists, |
109 // passing the id/token information back via |initialization_callback| along | 108 // passing the id/token information back via |initialization_callback| along |
110 // with a |success == true| result. If no GCM information is present (and | 109 // with a |success == true| result. If no GCM information is present (and |
111 // this is therefore a fresh client), a clean GCM store will be created and | 110 // this is therefore a fresh client), a clean GCM store will be created and |
112 // values of 0 will be returned via |initialization_callback| with | 111 // values of 0 will be returned via |initialization_callback| with |
113 // |success == true|. | 112 // |success == true|. |
114 /// If an error loading the GCM store is encountered, | 113 /// If an error loading the GCM store is encountered, |
(...skipping 26 matching lines...) Expand all Loading... |
141 | 140 |
142 // Returns the size of the send message queue. | 141 // Returns the size of the send message queue. |
143 int GetSendQueueSize() const; | 142 int GetSendQueueSize() const; |
144 | 143 |
145 // Returns the size of the resend messaage queue. | 144 // Returns the size of the resend messaage queue. |
146 int GetResendQueueSize() const; | 145 int GetResendQueueSize() const; |
147 | 146 |
148 // Returns text representation of the state enum. | 147 // Returns text representation of the state enum. |
149 std::string GetStateString() const; | 148 std::string GetStateString() const; |
150 | 149 |
| 150 // Updates the timer used by |heartbeat_manager_| for sending heartbeats. |
| 151 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); |
| 152 |
151 private: | 153 private: |
152 typedef uint32 StreamId; | 154 typedef uint32 StreamId; |
153 typedef std::string PersistentId; | 155 typedef std::string PersistentId; |
154 typedef std::vector<StreamId> StreamIdList; | 156 typedef std::vector<StreamId> StreamIdList; |
155 typedef std::vector<PersistentId> PersistentIdList; | 157 typedef std::vector<PersistentId> PersistentIdList; |
156 typedef std::map<StreamId, PersistentId> StreamIdToPersistentIdMap; | 158 typedef std::map<StreamId, PersistentId> StreamIdToPersistentIdMap; |
157 typedef linked_ptr<ReliablePacketInfo> MCSPacketInternal; | 159 typedef linked_ptr<ReliablePacketInfo> MCSPacketInternal; |
158 | 160 |
159 // Resets the internal state and builds a new login request, acknowledging | 161 // Resets the internal state and builds a new login request, acknowledging |
160 // any pending server-to-device messages and rebuilding the send queue | 162 // any pending server-to-device messages and rebuilding the send queue |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 GCMStatsRecorder* recorder_; | 283 GCMStatsRecorder* recorder_; |
282 | 284 |
283 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; | 285 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; |
284 | 286 |
285 DISALLOW_COPY_AND_ASSIGN(MCSClient); | 287 DISALLOW_COPY_AND_ASSIGN(MCSClient); |
286 }; | 288 }; |
287 | 289 |
288 } // namespace gcm | 290 } // namespace gcm |
289 | 291 |
290 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 292 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
OLD | NEW |