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

Side by Side Diff: chrome/browser/sync/sessions/status_controller.h

Issue 7477004: Simulate transient error and verify exponential backoff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 years, 4 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // StatusController handles all counter and status related number crunching and 5 // StatusController handles all counter and status related number crunching and
6 // state tracking on behalf of a SyncSession. It 'controls' the model data 6 // state tracking on behalf of a SyncSession. It 'controls' the model data
7 // defined in session_state.h. The most important feature of StatusController 7 // defined in session_state.h. The most important feature of StatusController
8 // is the ScopedModelSafetyRestriction. When one of these is active, the 8 // is the ScopedModelSafetyRestriction. When one of these is active, the
9 // underlying data set exposed via accessors is swapped out to the appropriate 9 // underlying data set exposed via accessors is swapped out to the appropriate
10 // set for the restricted ModelSafeGroup behind the scenes. For example, if 10 // set for the restricted ModelSafeGroup behind the scenes. For example, if
(...skipping 19 matching lines...) Expand all
30 // notifications if no changes occurred. 30 // notifications if no changes occurred.
31 31
32 #ifndef CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ 32 #ifndef CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_
33 #define CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ 33 #define CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_
34 #pragma once 34 #pragma once
35 35
36 #include <vector> 36 #include <vector>
37 #include <map> 37 #include <map>
38 38
39 #include "base/stl_util.h" 39 #include "base/stl_util.h"
40 #include "base/time.h"
40 #include "chrome/browser/sync/sessions/ordered_commit_set.h" 41 #include "chrome/browser/sync/sessions/ordered_commit_set.h"
41 #include "chrome/browser/sync/sessions/session_state.h" 42 #include "chrome/browser/sync/sessions/session_state.h"
42 43
43 namespace browser_sync { 44 namespace browser_sync {
44 namespace sessions { 45 namespace sessions {
45 46
46 class StatusController { 47 class StatusController {
47 public: 48 public:
48 explicit StatusController(const ModelSafeRoutingInfo& routes); 49 explicit StatusController(const ModelSafeRoutingInfo& routes);
49 ~StatusController(); 50 ~StatusController();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // the server said there WAS more to download, or it could mean that we 186 // the server said there WAS more to download, or it could mean that we
186 // were unable to reach the server. If we didn't request every enabled 187 // were unable to reach the server. If we didn't request every enabled
187 // datatype, then we can't say for sure that there's nothing left to 188 // datatype, then we can't say for sure that there's nothing left to
188 // download: in that case, this also returns false. 189 // download: in that case, this also returns false.
189 bool ServerSaysNothingMoreToDownload() const; 190 bool ServerSaysNothingMoreToDownload() const;
190 191
191 ModelSafeGroup group_restriction() const { 192 ModelSafeGroup group_restriction() const {
192 return group_restriction_; 193 return group_restriction_;
193 } 194 }
194 195
196 base::Time sync_start_time() const {
197 // The time at which we sent the first GetUpdates command for this sync.
198 return sync_start_time_;
199 }
200
195 // Check whether a particular model is included by the active group 201 // Check whether a particular model is included by the active group
196 // restriction. 202 // restriction.
197 bool ActiveGroupRestrictionIncludesModel(syncable::ModelType model) const { 203 bool ActiveGroupRestrictionIncludesModel(syncable::ModelType model) const {
198 if (!group_restriction_in_effect_) 204 if (!group_restriction_in_effect_)
199 return true; 205 return true;
200 ModelSafeRoutingInfo::const_iterator it = routing_info_.find(model); 206 ModelSafeRoutingInfo::const_iterator it = routing_info_.find(model);
201 if (it == routing_info_.end()) 207 if (it == routing_info_.end())
202 return false; 208 return false;
203 return group_restriction() == it->second; 209 return group_restriction() == it->second;
204 } 210 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // Reset to false by TestAndClearIsDirty. 258 // Reset to false by TestAndClearIsDirty.
253 bool is_dirty_; 259 bool is_dirty_;
254 260
255 // Used to fail read/write operations on state that don't obey the current 261 // Used to fail read/write operations on state that don't obey the current
256 // active ModelSafeWorker contract. 262 // active ModelSafeWorker contract.
257 bool group_restriction_in_effect_; 263 bool group_restriction_in_effect_;
258 ModelSafeGroup group_restriction_; 264 ModelSafeGroup group_restriction_;
259 265
260 const ModelSafeRoutingInfo routing_info_; 266 const ModelSafeRoutingInfo routing_info_;
261 267
268 base::Time sync_start_time_;
269
262 DISALLOW_COPY_AND_ASSIGN(StatusController); 270 DISALLOW_COPY_AND_ASSIGN(StatusController);
263 }; 271 };
264 272
265 // A utility to restrict access to only those parts of the given 273 // A utility to restrict access to only those parts of the given
266 // StatusController that pertain to the specified ModelSafeGroup. 274 // StatusController that pertain to the specified ModelSafeGroup.
267 class ScopedModelSafeGroupRestriction { 275 class ScopedModelSafeGroupRestriction {
268 public: 276 public:
269 ScopedModelSafeGroupRestriction(StatusController* to_restrict, 277 ScopedModelSafeGroupRestriction(StatusController* to_restrict,
270 ModelSafeGroup restriction) 278 ModelSafeGroup restriction)
271 : status_(to_restrict) { 279 : status_(to_restrict) {
272 DCHECK(!status_->group_restriction_in_effect_); 280 DCHECK(!status_->group_restriction_in_effect_);
273 status_->group_restriction_ = restriction; 281 status_->group_restriction_ = restriction;
274 status_->group_restriction_in_effect_ = true; 282 status_->group_restriction_in_effect_ = true;
275 } 283 }
276 ~ScopedModelSafeGroupRestriction() { 284 ~ScopedModelSafeGroupRestriction() {
277 DCHECK(status_->group_restriction_in_effect_); 285 DCHECK(status_->group_restriction_in_effect_);
278 status_->group_restriction_in_effect_ = false; 286 status_->group_restriction_in_effect_ = false;
279 } 287 }
280 private: 288 private:
281 StatusController* status_; 289 StatusController* status_;
282 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); 290 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction);
283 }; 291 };
284 292
285 } 293 }
286 } 294 }
287 295
288 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ 296 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698