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 27 matching lines...) Expand all Loading... | |
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 virtual bool RetrySyncShare(ModelTypeSet request_types, | 70 virtual bool RetrySyncShare(ModelTypeSet request_types, |
69 sessions::SyncSession* session); | 71 sessions::SyncSession* session); |
70 | 72 |
71 private: | 73 private: |
72 void ApplyUpdates(sessions::SyncSession* session); | 74 void ApplyUpdates(sessions::SyncSession* session, |
75 GetUpdatesProcessor* get_updates_processor); | |
73 bool DownloadAndApplyUpdates( | 76 bool DownloadAndApplyUpdates( |
74 ModelTypeSet request_types, | 77 ModelTypeSet request_types, |
75 sessions::SyncSession* session, | 78 sessions::SyncSession* session, |
79 GetUpdatesProcessor* get_updates_processor, | |
76 base::Callback<void(sync_pb::ClientToServerMessage*)> build_fn); | 80 base::Callback<void(sync_pb::ClientToServerMessage*)> build_fn); |
77 | 81 |
78 // This function will commit batches of unsynced items to the server until the | 82 // This function will commit batches of unsynced items to the server until the |
79 // number of unsynced and ready to commit items reaches zero or an error is | 83 // number of unsynced and ready to commit items reaches zero or an error is |
80 // encountered. A request to exit early will be treated as an error and will | 84 // encountered. A request to exit early will be treated as an error and will |
81 // abort any blocking operations. | 85 // abort any blocking operations. |
82 SyncerError BuildAndPostCommits( | 86 SyncerError BuildAndPostCommits( |
83 ModelTypeSet request_types, | 87 ModelTypeSet request_types, |
84 sessions::SyncSession* session); | 88 sessions::SyncSession* session, |
89 CommitProcessor* committer_list); | |
Nicolas Zea
2014/01/16 21:08:26
update name
rlarocque
2014/01/16 21:51:29
Done.
| |
85 | 90 |
86 void HandleCycleBegin(sessions::SyncSession* session); | 91 void HandleCycleBegin(sessions::SyncSession* session); |
87 bool HandleCycleEnd( | 92 bool HandleCycleEnd( |
88 sessions::SyncSession* session, | 93 sessions::SyncSession* session, |
89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 94 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
90 | 95 |
91 syncer::CancelationSignal* const cancelation_signal_; | 96 syncer::CancelationSignal* const cancelation_signal_; |
92 | 97 |
93 friend class SyncerTest; | 98 friend class SyncerTest; |
94 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); | 99 FRIEND_TEST_ALL_PREFIXES(SyncerTest, NameClashWithResolver); |
(...skipping 16 matching lines...) Expand all Loading... | |
111 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); | 116 FRIEND_TEST_ALL_PREFIXES(SyncerTest, DeletingEntryWithLocalEdits); |
112 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, | 117 FRIEND_TEST_ALL_PREFIXES(EntryCreatedInNewFolderTest, |
113 EntryCreatedInNewFolderMidSync); | 118 EntryCreatedInNewFolderMidSync); |
114 | 119 |
115 DISALLOW_COPY_AND_ASSIGN(Syncer); | 120 DISALLOW_COPY_AND_ASSIGN(Syncer); |
116 }; | 121 }; |
117 | 122 |
118 } // namespace syncer | 123 } // namespace syncer |
119 | 124 |
120 #endif // SYNC_ENGINE_SYNCER_H_ | 125 #endif // SYNC_ENGINE_SYNCER_H_ |
OLD | NEW |