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 // Utility methods for MCS interactions. | 5 // Utility methods for MCS interactions. |
6 | 6 |
7 #ifndef GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ | 7 #ifndef GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ |
8 #define GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ | 8 #define GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "google_apis/gcm/base/gcm_export.h" | 15 #include "google_apis/gcm/base/gcm_export.h" |
16 #include "google_apis/gcm/protocol/mcs.pb.h" | 16 #include "google_apis/gcm/protocol/mcs.pb.h" |
17 | 17 |
| 18 namespace base { |
| 19 class Clock; |
| 20 } |
| 21 |
18 namespace net { | 22 namespace net { |
19 class StreamSocket; | 23 class StreamSocket; |
20 } | 24 } |
21 | 25 |
22 namespace gcm { | 26 namespace gcm { |
23 | 27 |
24 // MCS Message tags. | 28 // MCS Message tags. |
25 // WARNING: the order of these tags must remain the same, as the tag values | 29 // WARNING: the order of these tags must remain the same, as the tag values |
26 // must be consistent with those used on the server. | 30 // must be consistent with those used on the server. |
27 enum MCSProtoTag { | 31 enum MCSProtoTag { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const google::protobuf::MessageLite& message); | 73 const google::protobuf::MessageLite& message); |
70 GCM_EXPORT void SetPersistentId( | 74 GCM_EXPORT void SetPersistentId( |
71 const std::string& persistent_id, | 75 const std::string& persistent_id, |
72 google::protobuf::MessageLite* message); | 76 google::protobuf::MessageLite* message); |
73 GCM_EXPORT uint32 GetLastStreamIdReceived( | 77 GCM_EXPORT uint32 GetLastStreamIdReceived( |
74 const google::protobuf::MessageLite& protobuf); | 78 const google::protobuf::MessageLite& protobuf); |
75 GCM_EXPORT void SetLastStreamIdReceived( | 79 GCM_EXPORT void SetLastStreamIdReceived( |
76 uint32 last_stream_id_received, | 80 uint32 last_stream_id_received, |
77 google::protobuf::MessageLite* protobuf); | 81 google::protobuf::MessageLite* protobuf); |
78 | 82 |
| 83 // Returns whether the TTL (time to live) for this message has expired, based |
| 84 // on the |sent| timestamps and base::TimeTicks::Now(). If |protobuf| is not |
| 85 // for a DataMessageStanza or the TTL is 0, will return false. |
| 86 GCM_EXPORT bool HasTTLExpired(const google::protobuf::MessageLite& protobuf, |
| 87 base::Clock* clock); |
| 88 GCM_EXPORT int GetTTL(const google::protobuf::MessageLite& protobuf); |
| 89 |
79 } // namespace gcm | 90 } // namespace gcm |
80 | 91 |
81 #endif // GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ | 92 #endif // GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_ |
OLD | NEW |