Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/invalidation/impl/registration_manager.h

Issue 2464903003: Revert of Remove stl_util's deletion function use from components/invalidation/. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/invalidation/impl/registration_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
13 12
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
16 #include "base/time/time.h" 15 #include "base/time/time.h"
17 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
18 // For invalidation::InvalidationListener::RegistrationState. 17 // For invalidation::InvalidationListener::RegistrationState.
19 #include "components/invalidation/public/invalidation_export.h" 18 #include "components/invalidation/public/invalidation_export.h"
20 #include "components/invalidation/public/invalidation_util.h" 19 #include "components/invalidation/public/invalidation_util.h"
21 #include "google/cacheinvalidation/include/invalidation-listener.h" 20 #include "google/cacheinvalidation/include/invalidation-listener.h"
22 #include "google/cacheinvalidation/include/types.h" 21 #include "google/cacheinvalidation/include/types.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // negative). 140 // negative).
142 base::TimeDelta delay; 141 base::TimeDelta delay;
143 // The minimum time to wait until any next registration attempt. 142 // The minimum time to wait until any next registration attempt.
144 // Increased after each consecutive failure. 143 // Increased after each consecutive failure.
145 base::TimeDelta next_delay; 144 base::TimeDelta next_delay;
146 // The actual timer for registration. 145 // The actual timer for registration.
147 base::OneShotTimer registration_timer; 146 base::OneShotTimer registration_timer;
148 147
149 DISALLOW_COPY_AND_ASSIGN(RegistrationStatus); 148 DISALLOW_COPY_AND_ASSIGN(RegistrationStatus);
150 }; 149 };
150 typedef std::map<invalidation::ObjectId,
151 RegistrationStatus*,
152 ObjectIdLessThan>
153 RegistrationStatusMap;
151 154
152 // Does nothing if the given id is disabled. Otherwise, if 155 // Does nothing if the given id is disabled. Otherwise, if
153 // |is_retry| is not set, registers the given type immediately and 156 // |is_retry| is not set, registers the given type immediately and
154 // resets all backoff parameters. If |is_retry| is set, registers 157 // resets all backoff parameters. If |is_retry| is set, registers
155 // the given type at some point in the future and increases the 158 // the given type at some point in the future and increases the
156 // delay until the next retry. 159 // delay until the next retry.
157 void TryRegisterId(const invalidation::ObjectId& id, 160 void TryRegisterId(const invalidation::ObjectId& id,
158 bool is_retry); 161 bool is_retry);
159 162
160 // Registers the given id, which must be valid, immediately. 163 // Registers the given id, which must be valid, immediately.
161 // Updates |last_registration| in the appropriate 164 // Updates |last_registration| in the appropriate
162 // RegistrationStatus. Should only be called by 165 // RegistrationStatus. Should only be called by
163 // RegistrationStatus::DoRegister(). 166 // RegistrationStatus::DoRegister().
164 void DoRegisterId(const invalidation::ObjectId& id); 167 void DoRegisterId(const invalidation::ObjectId& id);
165 168
166 // Unregisters the given object ID. 169 // Unregisters the given object ID.
167 void UnregisterId(const invalidation::ObjectId& id); 170 void UnregisterId(const invalidation::ObjectId& id);
168 171
169 // Gets all currently registered ids. 172 // Gets all currently registered ids.
170 ObjectIdSet GetRegisteredIds() const; 173 ObjectIdSet GetRegisteredIds() const;
171 174
172 // Returns true iff the given object ID is registered. 175 // Returns true iff the given object ID is registered.
173 bool IsIdRegistered(const invalidation::ObjectId& id) const; 176 bool IsIdRegistered(const invalidation::ObjectId& id) const;
174 177
175 std::map<invalidation::ObjectId, 178 RegistrationStatusMap registration_statuses_;
176 std::unique_ptr<RegistrationStatus>,
177 ObjectIdLessThan>
178 registration_statuses_;
179 // Weak pointer. 179 // Weak pointer.
180 invalidation::InvalidationClient* invalidation_client_; 180 invalidation::InvalidationClient* invalidation_client_;
181 181
182 DISALLOW_COPY_AND_ASSIGN(RegistrationManager); 182 DISALLOW_COPY_AND_ASSIGN(RegistrationManager);
183 }; 183 };
184 184
185 } // namespace syncer 185 } // namespace syncer
186 186
187 #endif // COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_ 187 #endif // COMPONENTS_INVALIDATION_IMPL_REGISTRATION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | components/invalidation/impl/registration_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698