| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "sync/base/sync_export.h" | 15 #include "sync/base/sync_export.h" |
| 16 #include "sync/engine/conflict_resolver.h" | 16 #include "sync/engine/conflict_resolver.h" |
| 17 #include "sync/engine/syncer_types.h" | 17 #include "sync/engine/syncer_types.h" |
| 18 #include "sync/internal_api/public/base/model_type.h" | 18 #include "sync/internal_api/public/base/model_type.h" |
| 19 #include "sync/sessions/sync_session.h" | 19 #include "sync/sessions/sync_session.h" |
| 20 #include "sync/util/extensions_activity.h" | 20 #include "sync/util/extensions_activity.h" |
| 21 | 21 |
| 22 namespace syncer { | 22 namespace syncer { |
| 23 | 23 |
| 24 class CancelationSignal; | 24 class CancelationSignal; |
| 25 class CommitProcessor; |
| 26 class GetUpdatesProcessor; |
| 25 | 27 |
| 26 // A Syncer provides a control interface for driving the sync cycle. These | 28 // A Syncer provides a control interface for driving the sync cycle. These |
| 27 // cycles consist of downloading updates, parsing the response (aka. process | 29 // cycles consist of downloading updates, parsing the response (aka. process |
| 28 // updates), applying updates while resolving conflicts, and committing local | 30 // updates), applying updates while resolving conflicts, and committing local |
| 29 // changes. Some of these steps may be skipped if they're deemed to be | 31 // changes. Some of these steps may be skipped if they're deemed to be |
| 30 // unnecessary. | 32 // unnecessary. |
| 31 // | 33 // |
| 32 // A Syncer instance expects to run on a dedicated thread. Calls to SyncShare() | 34 // A Syncer instance expects to run on a dedicated thread. Calls to SyncShare() |
| 33 // may take an unbounded amount of time because it may block on network I/O, on | 35 // may take an unbounded amount of time because it may block on network I/O, on |
| 34 // lock contention, or on tasks posted to other threads. | 36 // lock contention, or on tasks posted to other threads. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 sessions::SyncSession* session); | 62 sessions::SyncSession* session); |
| 61 | 63 |
| 62 // Requests to download updates for the |request_types|. For a well-behaved | 64 // Requests to download updates for the |request_types|. For a well-behaved |
| 63 // client with a working connection to the invalidations server, this should | 65 // client with a working connection to the invalidations server, this should |
| 64 // be unnecessary. It may be invoked periodically to try to keep the client | 66 // be unnecessary. It may be invoked periodically to try to keep the client |
| 65 // in sync despite bugs or transient failures. | 67 // in sync despite bugs or transient failures. |
| 66 virtual bool PollSyncShare(ModelTypeSet request_types, | 68 virtual bool PollSyncShare(ModelTypeSet request_types, |
| 67 sessions::SyncSession* session); | 69 sessions::SyncSession* session); |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 void ApplyUpdates(sessions::SyncSession* session); | 72 void ApplyUpdates(sessions::SyncSession* session, |
| 73 GetUpdatesProcessor* get_updates_processor); |
| 71 bool DownloadAndApplyUpdates( | 74 bool DownloadAndApplyUpdates( |
| 72 ModelTypeSet request_types, | 75 ModelTypeSet request_types, |
| 73 sessions::SyncSession* session, | 76 sessions::SyncSession* session, |
| 77 GetUpdatesProcessor* get_updates_processor, |
| 74 base::Callback<void(sync_pb::ClientToServerMessage*)> build_fn); | 78 base::Callback<void(sync_pb::ClientToServerMessage*)> build_fn); |
| 75 | 79 |
| 76 // This function will commit batches of unsynced items to the server until the | 80 // This function will commit batches of unsynced items to the server until the |
| 77 // number of unsynced and ready to commit items reaches zero or an error is | 81 // number of unsynced and ready to commit items reaches zero or an error is |
| 78 // encountered. A request to exit early will be treated as an error and will | 82 // encountered. A request to exit early will be treated as an error and will |
| 79 // abort any blocking operations. | 83 // abort any blocking operations. |
| 80 SyncerError BuildAndPostCommits( | 84 SyncerError BuildAndPostCommits( |
| 81 ModelTypeSet request_types, | 85 ModelTypeSet request_types, |
| 82 sessions::SyncSession* session); | 86 sessions::SyncSession* session, |
| 87 CommitProcessor* committer_list); |
| 83 | 88 |
| 84 void HandleCycleBegin(sessions::SyncSession* session); | 89 void HandleCycleBegin(sessions::SyncSession* session); |
| 85 bool HandleCycleEnd( | 90 bool HandleCycleEnd( |
| 86 sessions::SyncSession* session, | 91 sessions::SyncSession* session, |
| 87 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 92 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 88 | 93 |
| 89 syncer::CancelationSignal* const cancelation_signal_; | 94 syncer::CancelationSignal* const cancelation_signal_; |
| 90 | 95 |
| 91 friend class SyncerTest; | 96 friend class SyncerTest; |
| 92 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); | 97 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 109 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); | 114 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); |
| 110 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, | 115 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, |
| 111 EntryCreatedInNewFolderMidSync); | 116 EntryCreatedInNewFolderMidSync); |
| 112 | 117 |
| 113 DISALLOW_COPY_AND_ASSIGN(Syncer); | 118 DISALLOW_COPY_AND_ASSIGN(Syncer); |
| 114 }; | 119 }; |
| 115 | 120 |
| 116 } // namespace syncer | 121 } // namespace syncer |
| 117 | 122 |
| 118 #endif // SYNC_ENGINE_SYNCER_H_ | 123 #endif // SYNC_ENGINE_SYNCER_H_ |
| OLD | NEW |