| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // A class that manages the registration of types for server-issued | 5 // A class that manages the registration of types for server-issued |
| 6 // notifications. | 6 // notifications. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ | 8 #ifndef COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ |
| 9 #define COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ | 9 #define COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/sequence_checker.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 // For invalidation::InvalidationListener::RegistrationState. | 18 // For invalidation::InvalidationListener::RegistrationState. |
| 19 #include "components/invalidation/public/invalidation_export.h" | 19 #include "components/invalidation/public/invalidation_export.h" |
| 20 #include "components/invalidation/public/invalidation_util.h" | 20 #include "components/invalidation/public/invalidation_util.h" |
| 21 #include "google/cacheinvalidation/include/invalidation-listener.h" | 21 #include "google/cacheinvalidation/include/invalidation-listener.h" |
| 22 #include "google/cacheinvalidation/include/types.h" | 22 #include "google/cacheinvalidation/include/types.h" |
| 23 | 23 |
| 24 namespace syncer { | 24 namespace syncer { |
| 25 | 25 |
| 26 using ::invalidation::InvalidationListener; | 26 using ::invalidation::InvalidationListener; |
| 27 | 27 |
| 28 // Manages the details of registering types for invalidation. | 28 // Manages the details of registering types for invalidation. |
| 29 // Implements exponential backoff for repeated registration attempts | 29 // Implements exponential backoff for repeated registration attempts |
| 30 // to the invalidation client. | 30 // to the invalidation client. |
| 31 // | 31 // |
| 32 // TODO(akalin): Consolidate exponential backoff code. Other | 32 // TODO(akalin): Consolidate exponential backoff code. Other |
| 33 // implementations include the syncer thread (both versions) and XMPP | 33 // implementations include the syncer thread (both versions) and XMPP |
| 34 // retries. The most sophisticated one is URLRequestThrottler; making | 34 // retries. The most sophisticated one is URLRequestThrottler; making |
| 35 // that generic should work for everyone. | 35 // that generic should work for everyone. |
| 36 class INVALIDATION_EXPORT RegistrationManager : public base::NonThreadSafe { | 36 class INVALIDATION_EXPORT RegistrationManager { |
| 37 public: | 37 public: |
| 38 // Constants for exponential backoff (used by tests). | 38 // Constants for exponential backoff (used by tests). |
| 39 static const int kInitialRegistrationDelaySeconds; | 39 static const int kInitialRegistrationDelaySeconds; |
| 40 static const int kRegistrationDelayExponent; | 40 static const int kRegistrationDelayExponent; |
| 41 static const double kRegistrationDelayMaxJitter; | 41 static const double kRegistrationDelayMaxJitter; |
| 42 static const int kMinRegistrationDelaySeconds; | 42 static const int kMinRegistrationDelaySeconds; |
| 43 static const int kMaxRegistrationDelaySeconds; | 43 static const int kMaxRegistrationDelaySeconds; |
| 44 | 44 |
| 45 // Types used by testing functions. | 45 // Types used by testing functions. |
| 46 struct PendingRegistrationInfo { | 46 struct PendingRegistrationInfo { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Returns true iff the given object ID is registered. | 172 // Returns true iff the given object ID is registered. |
| 173 bool IsIdRegistered(const invalidation::ObjectId& id) const; | 173 bool IsIdRegistered(const invalidation::ObjectId& id) const; |
| 174 | 174 |
| 175 std::map<invalidation::ObjectId, | 175 std::map<invalidation::ObjectId, |
| 176 std::unique_ptr<RegistrationStatus>, | 176 std::unique_ptr<RegistrationStatus>, |
| 177 ObjectIdLessThan> | 177 ObjectIdLessThan> |
| 178 registration_statuses_; | 178 registration_statuses_; |
| 179 // Weak pointer. | 179 // Weak pointer. |
| 180 invalidation::InvalidationClient* invalidation_client_; | 180 invalidation::InvalidationClient* invalidation_client_; |
| 181 | 181 |
| 182 SEQUENCE_CHECKER(sequence_checker_); |
| 183 |
| 182 DISALLOW_COPY_AND_ASSIGN(RegistrationManager); | 184 DISALLOW_COPY_AND_ASSIGN(RegistrationManager); |
| 183 }; | 185 }; |
| 184 | 186 |
| 185 } // namespace syncer | 187 } // namespace syncer |
| 186 | 188 |
| 187 #endif // COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ | 189 #endif // COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ |
| OLD | NEW |