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 25 matching lines...) Expand all Loading... | |
36 namespace gcm { | 36 namespace gcm { |
37 | 37 |
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 // Any change made to this enum should have corresponding change in the | |
jianli
2014/03/04 23:47:39
The comment should be placed right before the enum
juyik
2014/03/05 05:08:08
Done.
| |
47 // GetStateString(...) function. | |
46 class GCM_EXPORT MCSClient { | 48 class GCM_EXPORT MCSClient { |
47 public: | 49 public: |
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 { |
(...skipping 21 matching lines...) Expand all Loading... | |
77 typedef base::Callback<void(const MCSMessage& message)> | 79 typedef base::Callback<void(const MCSMessage& message)> |
78 OnMessageReceivedCallback; | 80 OnMessageReceivedCallback; |
79 // Callback when a message is sent (and receipt has been acknowledged by | 81 // Callback when a message is sent (and receipt has been acknowledged by |
80 // the MCS endpoint). | 82 // the MCS endpoint). |
81 typedef base::Callback< | 83 typedef base::Callback< |
82 void(int64 user_serial_number, | 84 void(int64 user_serial_number, |
83 const std::string& app_id, | 85 const std::string& app_id, |
84 const std::string& message_id, | 86 const std::string& message_id, |
85 MessageSendStatus status)> OnMessageSentCallback; | 87 MessageSendStatus status)> OnMessageSentCallback; |
86 | 88 |
89 // Returns text representation of the enum State. | |
90 static std::string GetStateString(State state); | |
jianli
2014/03/04 23:47:39
ditto
juyik
2014/03/05 05:08:08
Done.
| |
91 | |
87 MCSClient(const std::string& version_string, | 92 MCSClient(const std::string& version_string, |
88 base::Clock* clock, | 93 base::Clock* clock, |
89 ConnectionFactory* connection_factory, | 94 ConnectionFactory* connection_factory, |
90 GCMStore* gcm_store); | 95 GCMStore* gcm_store); |
91 virtual ~MCSClient(); | 96 virtual ~MCSClient(); |
92 | 97 |
93 // Initialize the client. Will load any previous id/token information as well | 98 // Initialize the client. Will load any previous id/token information as well |
94 // as unacknowledged message information from the GCM storage, if it exists, | 99 // as unacknowledged message information from the GCM storage, if it exists, |
95 // passing the id/token information back via |initialization_callback| along | 100 // passing the id/token information back via |initialization_callback| along |
96 // with a |success == true| result. If no GCM information is present (and | 101 // with a |success == true| result. If no GCM information is present (and |
(...skipping 164 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 |