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 #include "sync/engine/syncer.h" | 5 #include "sync/engine/syncer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "sync/engine/apply_control_data_updates.h" | 13 #include "sync/engine/apply_control_data_updates.h" |
14 #include "sync/engine/apply_updates_and_resolve_conflicts_command.h" | 14 #include "sync/engine/apply_updates_and_resolve_conflicts_command.h" |
15 #include "sync/engine/build_commit_command.h" | 15 #include "sync/engine/build_commit_command.h" |
16 #include "sync/engine/commit.h" | 16 #include "sync/engine/commit.h" |
17 #include "sync/engine/conflict_resolver.h" | 17 #include "sync/engine/conflict_resolver.h" |
18 #include "sync/engine/download_updates_command.h" | 18 #include "sync/engine/download_updates_command.h" |
19 #include "sync/engine/net/server_connection_manager.h" | 19 #include "sync/engine/net/server_connection_manager.h" |
20 #include "sync/engine/process_commit_response_command.h" | 20 #include "sync/engine/process_commit_response_command.h" |
21 #include "sync/engine/process_updates_command.h" | 21 #include "sync/engine/process_updates_command.h" |
22 #include "sync/engine/store_timestamps_command.h" | 22 #include "sync/engine/store_timestamps_command.h" |
23 #include "sync/engine/syncer_types.h" | 23 #include "sync/engine/syncer_types.h" |
24 #include "sync/engine/throttled_data_type_tracker.h" | 24 #include "sync/engine/throttled_data_type_tracker.h" |
| 25 #include "sync/internal_api/public/base/unique_position.h" |
25 #include "sync/syncable/mutable_entry.h" | 26 #include "sync/syncable/mutable_entry.h" |
26 #include "sync/syncable/syncable-inl.h" | 27 #include "sync/syncable/syncable-inl.h" |
27 | 28 |
28 // TODO(vishwath): Remove this include after node positions have | |
29 // shifted to completely using Ordinals. | |
30 // See http://crbug.com/145412 . | |
31 #include "sync/internal_api/public/base/node_ordinal.h" | |
32 | |
33 using base::Time; | 29 using base::Time; |
34 using base::TimeDelta; | 30 using base::TimeDelta; |
35 using sync_pb::ClientCommand; | 31 using sync_pb::ClientCommand; |
36 | 32 |
37 namespace syncer { | 33 namespace syncer { |
38 | 34 |
39 using sessions::StatusController; | 35 using sessions::StatusController; |
40 using sessions::SyncSession; | 36 using sessions::SyncSession; |
41 using syncable::IS_UNAPPLIED_UPDATE; | 37 using syncable::IS_UNAPPLIED_UPDATE; |
42 using syncable::SERVER_CTIME; | 38 using syncable::SERVER_CTIME; |
43 using syncable::SERVER_IS_DEL; | 39 using syncable::SERVER_IS_DEL; |
44 using syncable::SERVER_IS_DIR; | 40 using syncable::SERVER_IS_DIR; |
45 using syncable::SERVER_MTIME; | 41 using syncable::SERVER_MTIME; |
46 using syncable::SERVER_NON_UNIQUE_NAME; | 42 using syncable::SERVER_NON_UNIQUE_NAME; |
47 using syncable::SERVER_PARENT_ID; | 43 using syncable::SERVER_PARENT_ID; |
48 using syncable::SERVER_ORDINAL_IN_PARENT; | |
49 using syncable::SERVER_SPECIFICS; | 44 using syncable::SERVER_SPECIFICS; |
| 45 using syncable::SERVER_UNIQUE_POSITION; |
50 using syncable::SERVER_VERSION; | 46 using syncable::SERVER_VERSION; |
51 | 47 |
52 #define ENUM_CASE(x) case x: return #x | 48 #define ENUM_CASE(x) case x: return #x |
53 const char* SyncerStepToString(const SyncerStep step) | 49 const char* SyncerStepToString(const SyncerStep step) |
54 { | 50 { |
55 switch (step) { | 51 switch (step) { |
56 ENUM_CASE(SYNCER_BEGIN); | 52 ENUM_CASE(SYNCER_BEGIN); |
57 ENUM_CASE(DOWNLOAD_UPDATES); | 53 ENUM_CASE(DOWNLOAD_UPDATES); |
58 ENUM_CASE(PROCESS_UPDATES); | 54 ENUM_CASE(PROCESS_UPDATES); |
59 ENUM_CASE(STORE_TIMESTAMPS); | 55 ENUM_CASE(STORE_TIMESTAMPS); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) { | 187 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) { |
192 dest->Put(SERVER_NON_UNIQUE_NAME, src->Get(SERVER_NON_UNIQUE_NAME)); | 188 dest->Put(SERVER_NON_UNIQUE_NAME, src->Get(SERVER_NON_UNIQUE_NAME)); |
193 dest->Put(SERVER_PARENT_ID, src->Get(SERVER_PARENT_ID)); | 189 dest->Put(SERVER_PARENT_ID, src->Get(SERVER_PARENT_ID)); |
194 dest->Put(SERVER_MTIME, src->Get(SERVER_MTIME)); | 190 dest->Put(SERVER_MTIME, src->Get(SERVER_MTIME)); |
195 dest->Put(SERVER_CTIME, src->Get(SERVER_CTIME)); | 191 dest->Put(SERVER_CTIME, src->Get(SERVER_CTIME)); |
196 dest->Put(SERVER_VERSION, src->Get(SERVER_VERSION)); | 192 dest->Put(SERVER_VERSION, src->Get(SERVER_VERSION)); |
197 dest->Put(SERVER_IS_DIR, src->Get(SERVER_IS_DIR)); | 193 dest->Put(SERVER_IS_DIR, src->Get(SERVER_IS_DIR)); |
198 dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL)); | 194 dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL)); |
199 dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE)); | 195 dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE)); |
200 dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS)); | 196 dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS)); |
201 dest->Put(SERVER_ORDINAL_IN_PARENT, src->Get(SERVER_ORDINAL_IN_PARENT)); | 197 dest->Put(SERVER_UNIQUE_POSITION, src->Get(SERVER_UNIQUE_POSITION)); |
202 } | |
203 | |
204 void ClearServerData(syncable::MutableEntry* entry) { | |
205 entry->Put(SERVER_NON_UNIQUE_NAME, ""); | |
206 entry->Put(SERVER_PARENT_ID, syncable::GetNullId()); | |
207 entry->Put(SERVER_MTIME, Time()); | |
208 entry->Put(SERVER_CTIME, Time()); | |
209 entry->Put(SERVER_VERSION, 0); | |
210 entry->Put(SERVER_IS_DIR, false); | |
211 entry->Put(SERVER_IS_DEL, false); | |
212 entry->Put(IS_UNAPPLIED_UPDATE, false); | |
213 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); | |
214 entry->Put(SERVER_ORDINAL_IN_PARENT, Int64ToNodeOrdinal(0)); | |
215 } | 198 } |
216 | 199 |
217 } // namespace syncer | 200 } // namespace syncer |
OLD | NEW |