| 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 27 matching lines...) Expand all Loading... |
| 38 class CollapseKey; | 38 class CollapseKey; |
| 39 class ConnectionFactory; | 39 class ConnectionFactory; |
| 40 struct ReliablePacketInfo; | 40 struct ReliablePacketInfo; |
| 41 | 41 |
| 42 // An MCS client. This client is in charge of all communications with an | 42 // An MCS client. This client is in charge of all communications with an |
| 43 // MCS endpoint, and is capable of reliably sending/receiving GCM messages. | 43 // MCS endpoint, and is capable of reliably sending/receiving GCM messages. |
| 44 // NOTE: Not thread safe. This class should live on the same thread as that | 44 // NOTE: Not thread safe. This class should live on the same thread as that |
| 45 // network requests are performed on. | 45 // network requests are performed on. |
| 46 class GCM_EXPORT MCSClient { | 46 class GCM_EXPORT MCSClient { |
| 47 public: | 47 public: |
| 48 // Any change made to this enum should have corresponding change in the |
| 49 // GetStateString(...) function. |
| 48 enum State { | 50 enum State { |
| 49 UNINITIALIZED, // Uninitialized. | 51 UNINITIALIZED, // Uninitialized. |
| 50 LOADED, // GCM Load finished, waiting to connect. | 52 LOADED, // GCM Load finished, waiting to connect. |
| 51 CONNECTING, // Connection in progress. | 53 CONNECTING, // Connection in progress. |
| 52 CONNECTED, // Connected and running. | 54 CONNECTED, // Connected and running. |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 enum MessageSendStatus { | 57 enum MessageSendStatus { |
| 56 // Message was queued succcessfully. | 58 // Message was queued succcessfully. |
| 57 QUEUED, | 59 QUEUED, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Whether to use RMQ depends on whether the protobuf has |ttl| set or not. | 120 // Whether to use RMQ depends on whether the protobuf has |ttl| set or not. |
| 119 // |ttl == 0| denotes the message should only be sent if the connection is | 121 // |ttl == 0| denotes the message should only be sent if the connection is |
| 120 // open. |ttl > 0| will keep the message saved for |ttl| seconds, after which | 122 // open. |ttl > 0| will keep the message saved for |ttl| seconds, after which |
| 121 // it will be dropped if it was unable to be sent. When a message is dropped, | 123 // it will be dropped if it was unable to be sent. When a message is dropped, |
| 122 // |message_sent_callback_| is invoked with a TTL expiration error. | 124 // |message_sent_callback_| is invoked with a TTL expiration error. |
| 123 virtual void SendMessage(const MCSMessage& message); | 125 virtual void SendMessage(const MCSMessage& message); |
| 124 | 126 |
| 125 // Returns the current state of the client. | 127 // Returns the current state of the client. |
| 126 State state() const { return state_; } | 128 State state() const { return state_; } |
| 127 | 129 |
| 130 // Returns text representation of the state enum. |
| 131 std::string GetStateString() const; |
| 132 |
| 128 protected: | 133 protected: |
| 129 // Sets a |gcm_store| for testing. Does not take ownership. | 134 // Sets a |gcm_store| for testing. Does not take ownership. |
| 130 // TODO(fgorski): Remove this method. Create GCMEngineFactory that will create | 135 // TODO(fgorski): Remove this method. Create GCMEngineFactory that will create |
| 131 // components of the engine. | 136 // components of the engine. |
| 132 void SetGCMStoreForTesting(GCMStore* gcm_store); | 137 void SetGCMStoreForTesting(GCMStore* gcm_store); |
| 133 | 138 |
| 134 private: | 139 private: |
| 135 typedef uint32 StreamId; | 140 typedef uint32 StreamId; |
| 136 typedef std::string PersistentId; | 141 typedef std::string PersistentId; |
| 137 typedef std::vector<StreamId> StreamIdList; | 142 typedef std::vector<StreamId> StreamIdList; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 HeartbeatManager heartbeat_manager_; | 266 HeartbeatManager heartbeat_manager_; |
| 262 | 267 |
| 263 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; | 268 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; |
| 264 | 269 |
| 265 DISALLOW_COPY_AND_ASSIGN(MCSClient); | 270 DISALLOW_COPY_AND_ASSIGN(MCSClient); |
| 266 }; | 271 }; |
| 267 | 272 |
| 268 } // namespace gcm | 273 } // namespace gcm |
| 269 | 274 |
| 270 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 275 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
| OLD | NEW |