summaryrefslogtreecommitdiffstats
path: root/sync/sessions/status_controller.cc
Commit message (Collapse)AuthorAgeFilesLines
* Remove some members from SyncSessionrlarocque@chromium.org2013-03-151-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is part of the effort to shrink the size of the SyncSession and SyncSessionJob. One of the members to be removed was the write transaction. This was stored in the session in order to share it among various functions that prepare a commit message. The same goal can be accomplished by passing the transaction in to the constructors of the SyncerCommands. There was one complication in this change. The new constructor meant that it was impossible to instantiate a BuildCommitCommand without a transaction, which made it somewhat harder to unit test. Making some of its methods static made it unnecessary to instantiate a BuildCommitCommand object in the test. In addition to giving us better control of the scope of the transaction, this change allows BuildCommitCommand and GetCommitIdsCommand to use a BaseTransaction rather than a WriteTransaction. The other member removed from SyncSession is the ExtensionsActivityMonitor's records. This member was used to buffer the ExtensionsActivityMonitor's records which were pending for commit and to re-add them to the monitor if the commit failed. Since it is only used within the context of a commit, it is safer and simpler to declare it on the stack in BuildAndPostCommitsImpl(). The change should have no noticeable impact on behaviour, though it does move some of the interactions with the ExtensionsActivityMonitor from the UI thread to the sync thread. This should be safe; the monitor's internal data structures are protected with a lock. The move also allows us to remove some of the code from StatusController that was used to trigger the UI-thread-specific processing. BUG=175024 Review URL: https://chromiumcodereview.appspot.com/12314103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188266 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Follow-up to conflict resolution refactorrlarocque@chromium.org2012-11-011-64/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is part two of r164286. That commit refactored the way we handle conflict resolution. This commit takes advantage of those changes to delete lots of code. Because this change deletes session_state.cc, I decided to move the two remaining useful tests session_state_unittest.cc into their own files, sync_session_snapshot_unittest.cc and sync_source_info_unittest.cc. The tests were not modified in any way. None of these changes should have any effect on syncer behaviour: - We can remove the simple conflict counters and related code, since we now assert that all conflicts will be resolved by the end of a successful sync cycle. - We can remove the PerModelSafeGroupState because that struct no longer has any members. - The 'conflicts_resolved' indicators are no longer set, so we can remove them. - Without those indicators, it's no longer possible to have any SYNC_CYCLE_CONTINUATION sync cycles. We can remove a few counters associated with them, as well as the 'has_more_to_sync' flag in the snapshot. - Without SYNC_CYCLE_CONTINUATION cycles, there's no longer any need for code that loops around SyncShare() in SyncSchedulerImpl. The SyncSession::PrepareForAnotherSyncCycle() function is no longer used, either. - The ScopedConflictResolver installed on the session during a sync cycle is no longer used, so all the code related to it can be deleted. BUG=147681,111280,156238 Review URL: https://chromiumcodereview.appspot.com/11314008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165474 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Merge apply updates and resolve conflictsrlarocque@chromium.org2012-10-261-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The conflict resolution code was executed after the commit for reasons which no longer apply. Because we no longer have to worry about resolving hierarchy conflicts or nigori node conflicts, we have the opportunity to move conflict resolution closer to update application. One advantage of resolving conflicts early is that we no longer require an extra sync cycle to commit any 'local wins' conflict resolutions. This makes SYNC_CYCLE_CONTINUATION sync cycles obsolete. Another advantage is that update application and conflict resolution can be performed without releasing the sync lock, which eliminates several types of races that we used to have to worry about. It's probably more efficient, too. It allows us to guarantee that there are no simple conflicts remaining after the update application step is completed. The effects might not be very noticeable to end users, but it will be nice to remove some of the conflict tracking code. Finally, it removes the last use PerModelSafeGroupState. This will let us delete some unused code and hopefully simplify StatusController. This patch does not pursue these cleanups as agressively as it could. The idea here is to keep the complex logic changes in one small CL, and perform the cleanups in a larger, but simpler, follow-up CL. BUG=147681,11280,156238 Review URL: https://chromiumcodereview.appspot.com/11192071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164286 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Remove UpdateProgress and related coderlarocque@chromium.org2012-10-171-32/+5
| | | | | | | | | | | | | | | | | | Following the merge of the process updates and verify updates step, there is no longer any need for the UpdateProgress class. Its only use outside of tests was to pass data between the verify and update steps during a sync cycle. The class had some use in tests, but most of the assertions based on it were somewhat redundant. They can be replaced by assertions on similar, but non-ModelSafe, counts. BUG=156238 Review URL: https://chromiumcodereview.appspot.com/11190013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162576 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Remove ConflictProgressrlarocque@chromium.org2012-10-061-56/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | This change removes the ConflictProgress struct from the PerModelSafeGroupState. The struct was intended to pass state between the update application and conflict resolution commands. This part of its functionality has been replaced with a vector of simple conflict item IDs. The ConflictProgress struct also had an important role to play in stats gathering and unit tests. To replace it, the update applicator has been updated to store its counts directly in the StatusController. Unlike ConflictProgress, this state is not thread-local. That's acceptable because we can guarantee it will only be read or written by one thread at a time and those threads use appropriate thread-safety mechanisms to transfer control to each other. This change is another step towards merging update application and conflict resolution. BUG=147681 Review URL: https://chromiumcodereview.appspot.com/11049002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160530 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Add support for performing a GetKey on startup.zea@chromium.org2012-07-311-0/+8
| | | | | | | | | | | | | | | | | The functionality is behind the --sync-keystore-encryption flag, and the key is not currently consumed by anything, but this lays the groundwork for testing the server and client interaction. We request a key anytime we perform a GetUpdates while the cryptographer does not have a keystore key. But, it is considered an error to request a key and not receive one, putting us into a state of backoff. BUG=129665 TEST=sync_unit_tests, running against python server Review URL: https://chromiumcodereview.appspot.com/10455012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149248 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopingsakalin@chromium.org2012-07-201-2/+1
| | | | | | | | | | | | | | | | | Since (almost) everything in sync/ is now in the 'syncer' namespace, all of these are redundant. Clean up indentation. Put sync_{client,listen_notifications} into syncer namespace. BUG=128060 TEST= Review URL: https://chromiumcodereview.appspot.com/10795018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147675 0039d316-1c4b-4281-b951-d872f2087c98
* Remove syncproto.hrlarocque@chromium.org2012-07-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | Replace sync/engine/syncproto.h with sync/syncable/syncable_proto_util.h and .cc. The tasks that used to be performed by member functions of the syncer:: proto wrapper classes are now handled by static member functions. Unfortunately, serialization and de-serialization of syncable::Id to/from proto fields has gotten a bit uglier. On the other hand, it's now much less magical and mysterious. The test intended to prevent regressions of crbug.com/134715 has been replaced with a DCHECK. We'll have to rely on it to ensure that the protocol_version field is always explicitly set. BUG=136454 TEST= Review URL: https://chromiumcodereview.appspot.com/10735041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146393 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Move ModelType and related classes to 'syncer' namespaceakalin@chromium.org2012-07-031-4/+1
| | | | | | | | | | | | | | Previously they were in 'syncer::syncable'. Also remove aliases to those classes from 'syncable'. BUG=128060 TEST= TBR=pkasting@chromium.org,jhawkins@chromium.org, Review URL: https://chromiumcodereview.appspot.com/10696087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145399 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Move model_type* from syncable/ to base/akalin@chromium.org2012-07-031-1/+1
| | | | | | | | | | | | | | | | | | | Also move enum_set* to base/. This is the first step in moving ModelType et al. to the syncer namespace (from syncer::syncable). Move PurgeStalePayload() back to sync_session.cc. Move ModelTypePayloadMapFromRoutingInfo() to model_safe_worker.* and rename it to ModelSafeRoutingInfoToPayloadMap(). BUG=128060 TEST= Review URL: https://chromiumcodereview.appspot.com/10690071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145236 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Rename csync namespace to syncerakalin@chromium.org2012-06-281-2/+2
| | | | | | | | | | | | | | | Everyone was confused by 'csync'. 'syncer' seems more understandable. (Note that we can't use the 'sync' namespace since sync() is a function from unistd.h.) BUG=10662035 TEST= TBR=jhawkins@chromium.org,pkasting@chromium.org Review URL: https://chromiumcodereview.appspot.com/10698014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144820 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Refactor session tracking rlarocque@chromium.org2012-06-221-38/+20
| | | | | | | | | | | | | | | | | | | | | | | This change refactors the related structs ErrorCounters, SyncerStatus, and SyncCycleControlParameters. Their values have all been merged into AllModelTypeState, which has been renamed to ModelNeutralState. All the functions which depend on this data have been updated to use the new struct. This change also removes the DirtyOnWrite template class, the is_dirty flag, and the SyncerCommand logic to send change events if it detects a change in the syncer's status. The changes are so frequent and predictable that it's easier to just send the snapshots manually after any major syncer steps. Finally, this change removes the 'invalid_store' status member, which was never set nor read outside of unit tests. BUG=132630 TEST= Review URL: https://chromiumcodereview.appspot.com/10636010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143675 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Rename browser_sync to csync in sync/akalin@chromium.org2012-06-211-2/+2
| | | | | | | | | | | | | | | Update all references from chrome. Leave possibly-extraneous csync:: qualifications in sync/ for now. (This will be cleaned up once everything in sync/ is in csync::.) BUG=128060 TEST= TBR=jhawkins@chromium.org Review URL: https://chromiumcodereview.appspot.com/10600002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143449 0039d316-1c4b-4281-b951-d872f2087c98
* Refactor following sync commit loop changerlarocque@chromium.org2012-06-081-15/+2
| | | | | | | | | | | | | | | | | | | | | | | This change includes some cleanups of the code introduced in r139519. They have been kept separate from that CL in the hopes of making both CLs easiser to read. This commit moves some error-detection functionality from ProcessCommitResponse's ModelNeutralExecuteImpl() into BuildAndPostCommits(). This simplifies some of the error handling and allows us to remove ModelChangingSyncerCommand's ModelNeutralExecuteImpl(). This CL also combines both commit error indicators into a single variable. BUG=91696,36594 TEST= Review URL: https://chromiumcodereview.appspot.com/10523003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141321 0039d316-1c4b-4281-b951-d872f2087c98
* sync: create internal_api/public to house sync/ files needed by ↵tim@chromium.org2012-06-071-1/+1
| | | | | | | | | | | | | | | | | chrome/browser/sync. Note on sync.gyp changes and .cc file moves: most files in /public have .h and their .cc side by side, as they are simple implementations. In some cases like model_type.cc (and others in a follow up patch, like sync_manager.cc) have only their header exposed in /public while the impl stays behind, because it needs to include things from within sync/, and /public has a strict include DEPS policy. This is in accordance with other /public folders (like content/). Cleans up DEPS files in sync + c/b/sync. Adds sync/{engine, sessions, syncable} to public/. There is more to come (moving things in internal_api/ into public). Not touching /notifier as that is in flux at the moment. BUG=131130 TEST= Review URL: https://chromiumcodereview.appspot.com/10532019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141038 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Loop committing items without downloading updatesrlarocque@chromium.org2012-05-261-19/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since its inception sync has required all commits to be preceded by a GetUpdates request. This was done to try to ensure we detect and resolve conflicts on the client, rather than having two conflicting commits collide at the server. It could never work perfectly, but it was likely to work in most cases and the server would bounce the commit if it didn't. Now we have a new server that doesn't always give us the latest version of a node when we ask for it, especially when the request was not solicited by the server (ie. not triggered by notification). The update before commit is now much less likely to detect conflicts. Even worse, the useless update requests can be surprisingly expensive in certain scenarios. This change allows us to avoid fetching updates between 'batches' of commits. This should improve performance in the case where we have lots of items to commit (ie. first time sync) and reduce load on the server. This CL has some far-reaching effects. This is in part because I decided to refactor the commit code, but major changes would have been required with or without the refactor. Highlights include: - The commit-related SyncerCommands are now paramaterized with local variables, allowing us to remove many members from the SyncSession classes. - Several syncer states have been collapsed into one COMMIT state which redirects to the new BuildAndPostCommits() function. - The PostCommitMessageCommand had been reduced to one line, which has now been inlined into the BuildAndPostCommits() function. - The unsynced_handles counter has been removed for now. Following this change, it would have always been zero unless an error was encountered during the commit. The functions that reference it expect different behaviour and would have been broken by this change. - The code to put extensions activity data back into the ExtensionsActivityMonitor in case of failure has been moved around to avoid double-counting if we have to post many commit messages. - A CONFLICT response from the server is now treated as a transient error. If we had continued to treat it as a success we might risk going into an infinite loop. See comment in code for details. - The "purposeless anachronism" conflicting_new_folder_ids_ has been removed. Review URL: https://chromiumcodereview.appspot.com/10210009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139159 0039d316-1c4b-4281-b951-d872f2087c98
* sync: Count and report reflected updatesrlarocque@chromium.org2012-03-241-0/+6
| | | | | | | | | | | | | | | | | | | Many of the updates a sync client receives are echoes of its own changes. This patch attempts to count how often these updates are received by comparing the version of downloaded updates against the local version. These counts are exposed locally through AllStatus/about:sync. We also upload this information to the server through the ClientDebugInfo mechanism. BUG=117565 TEST= Review URL: http://codereview.chromium.org/9702083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128659 0039d316-1c4b-4281-b951-d872f2087c98
* [Sync] Move 'sync' target to sync/akalin@chromium.org2012-03-151-0/+310
Also move related test files. Move WriteNode::UpdateEntryWithEncryption to nigori_util.h. Clean up defines and dependencies. In particular, get rid of SYNC_ENGINE_VERSION_STRING and hard-code the string in the single place it's used. Rename data_encryption.* to data_encryption_win.* and add a pragma for crypt32.lib. Clean up exit-time constructor warnings in sync{able,er}_unittest.cc. Remove some unused files. BUG=117585 TEST= TBR=jhawkins@chromium.org Review URL: https://chromiumcodereview.appspot.com/9699057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126872 0039d316-1c4b-4281-b951-d872f2087c98