| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef SYNC_ENGINE_SYNCER_H_ | 5 #ifndef SYNC_ENGINE_SYNCER_H_ |
| 6 #define SYNC_ENGINE_SYNCER_H_ | 6 #define SYNC_ENGINE_SYNCER_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 typedef std::vector<int64> UnsyncedMetaHandles; | 36 typedef std::vector<int64> UnsyncedMetaHandles; |
| 37 | 37 |
| 38 Syncer(); | 38 Syncer(); |
| 39 virtual ~Syncer(); | 39 virtual ~Syncer(); |
| 40 | 40 |
| 41 // Called by other threads to tell the syncer to stop what it's doing | 41 // Called by other threads to tell the syncer to stop what it's doing |
| 42 // and return early from SyncShare, if possible. | 42 // and return early from SyncShare, if possible. |
| 43 bool ExitRequested(); | 43 bool ExitRequested(); |
| 44 void RequestEarlyExit(); | 44 void RequestEarlyExit(); |
| 45 | 45 |
| 46 // Fetches and applies updates, resolves conflicts and commits local changes |
| 47 // for |request_types| as necessary until client and server states are in |
| 48 // sync. The |nudge_tracker| contains state that describes why the client is |
| 49 // out of sync and what must be done to bring it back into sync. |
| 46 virtual bool NormalSyncShare(ModelTypeSet request_types, | 50 virtual bool NormalSyncShare(ModelTypeSet request_types, |
| 47 const sessions::NudgeTracker& nudge_tracker, | 51 const sessions::NudgeTracker& nudge_tracker, |
| 48 sessions::SyncSession* session); | 52 sessions::SyncSession* session); |
| 49 virtual bool ConfigureSyncShare(ModelTypeSet request_types, | 53 |
| 50 sessions::SyncSession* session); | 54 // Performs an initial download for the |request_types|. It is assumed that |
| 55 // the specified types have no local state, and that their associated change |
| 56 // processors are in "passive" mode, so none of the downloaded updates will be |
| 57 // applied to the model. The |source| is sent up to the server for debug |
| 58 // purposes. It describes the reson for performing this initial download. |
| 59 virtual bool ConfigureSyncShare( |
| 60 ModelTypeSet request_types, |
| 61 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 62 sessions::SyncSession* session); |
| 63 |
| 64 // Requests to download updates for the |request_types|. For a well-behaved |
| 65 // client with a working connection to the invalidations server, this should |
| 66 // be unnecessary. It may be invoked periodically to try to keep the client |
| 67 // in sync despite bugs or transient failures. |
| 51 virtual bool PollSyncShare(ModelTypeSet request_types, | 68 virtual bool PollSyncShare(ModelTypeSet request_types, |
| 52 sessions::SyncSession* session); | 69 sessions::SyncSession* session); |
| 53 | 70 |
| 54 private: | 71 private: |
| 55 void ApplyUpdates(sessions::SyncSession* session); | 72 void ApplyUpdates(sessions::SyncSession* session); |
| 56 bool DownloadAndApplyUpdates( | 73 bool DownloadAndApplyUpdates( |
| 57 sessions::SyncSession* session, | 74 sessions::SyncSession* session, |
| 58 base::Callback<SyncerError(void)> download_fn); | 75 base::Callback<SyncerError(void)> download_fn); |
| 59 | 76 |
| 60 void HandleCycleBegin(sessions::SyncSession* session); | 77 void HandleCycleBegin(sessions::SyncSession* session); |
| 61 bool HandleCycleEnd(sessions::SyncSession* session); | 78 bool HandleCycleEnd( |
| 79 sessions::SyncSession* session, |
| 80 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 62 | 81 |
| 63 bool early_exit_requested_; | 82 bool early_exit_requested_; |
| 64 base::Lock early_exit_requested_lock_; | 83 base::Lock early_exit_requested_lock_; |
| 65 | 84 |
| 66 friend class SyncerTest; | 85 friend class SyncerTest; |
| 67 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); | 86 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); |
| 68 FRIEND_TEST_ALL_PREFIXES(SyncerTest, IllegalAndLegalUpdates); | 87 FRIEND_TEST_ALL_PREFIXES(SyncerTest, IllegalAndLegalUpdates); |
| 69 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingAndNewParent); | 88 FRIEND_TEST_ALL_PREFIXES(SyncerTest, TestCommitListOrderingAndNewParent); |
| 70 FRIEND_TEST_ALL_PREFIXES(SyncerTest, | 89 FRIEND_TEST_ALL_PREFIXES(SyncerTest, |
| 71 TestCommitListOrderingAndNewParentAndChild); | 90 TestCommitListOrderingAndNewParentAndChild); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); | 103 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); |
| 85 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, | 104 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, |
| 86 EntryCreatedInNewFolderMidSync); | 105 EntryCreatedInNewFolderMidSync); |
| 87 | 106 |
| 88 DISALLOW_COPY_AND_ASSIGN(Syncer); | 107 DISALLOW_COPY_AND_ASSIGN(Syncer); |
| 89 }; | 108 }; |
| 90 | 109 |
| 91 } // namespace syncer | 110 } // namespace syncer |
| 92 | 111 |
| 93 #endif // SYNC_ENGINE_SYNCER_H_ | 112 #endif // SYNC_ENGINE_SYNCER_H_ |
| OLD | NEW |