Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: sync/engine/syncer.cc

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Changed server_position to server_ordinal in DB Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_command.h" 14 #include "sync/engine/apply_updates_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/resolve_conflicts_command.h" 22 #include "sync/engine/resolve_conflicts_command.h"
23 #include "sync/engine/store_timestamps_command.h" 23 #include "sync/engine/store_timestamps_command.h"
24 #include "sync/engine/syncer_types.h" 24 #include "sync/engine/syncer_types.h"
25 #include "sync/engine/throttled_data_type_tracker.h" 25 #include "sync/engine/throttled_data_type_tracker.h"
26 #include "sync/engine/verify_updates_command.h" 26 #include "sync/engine/verify_updates_command.h"
27 #include "sync/syncable/mutable_entry.h" 27 #include "sync/syncable/mutable_entry.h"
28 #include "sync/syncable/syncable-inl.h" 28 #include "sync/syncable/syncable-inl.h"
29 29
30 //TODO(vishwath) Remove this include after node positions have
akalin 2012/10/05 00:57:59 same
vishwath 2012/10/05 18:34:49 Done.
31 // shifted to completely uing Ordinals.
32 // See crbug.com/145412
33 #include "sync/internal_api/public/base/node_ordinal.h"
34
30 using base::Time; 35 using base::Time;
31 using base::TimeDelta; 36 using base::TimeDelta;
32 using sync_pb::ClientCommand; 37 using sync_pb::ClientCommand;
33 38
34 namespace syncer { 39 namespace syncer {
35 40
36 using sessions::ScopedSessionContextConflictResolver; 41 using sessions::ScopedSessionContextConflictResolver;
37 using sessions::StatusController; 42 using sessions::StatusController;
38 using sessions::SyncSession; 43 using sessions::SyncSession;
39 using sessions::ConflictProgress; 44 using sessions::ConflictProgress;
40 using syncable::IS_UNAPPLIED_UPDATE; 45 using syncable::IS_UNAPPLIED_UPDATE;
41 using syncable::SERVER_CTIME; 46 using syncable::SERVER_CTIME;
42 using syncable::SERVER_IS_DEL; 47 using syncable::SERVER_IS_DEL;
43 using syncable::SERVER_IS_DIR; 48 using syncable::SERVER_IS_DIR;
44 using syncable::SERVER_MTIME; 49 using syncable::SERVER_MTIME;
45 using syncable::SERVER_NON_UNIQUE_NAME; 50 using syncable::SERVER_NON_UNIQUE_NAME;
46 using syncable::SERVER_PARENT_ID; 51 using syncable::SERVER_PARENT_ID;
47 using syncable::SERVER_POSITION_IN_PARENT; 52 using syncable::SERVER_ORDINAL_IN_PARENT;
48 using syncable::SERVER_SPECIFICS; 53 using syncable::SERVER_SPECIFICS;
49 using syncable::SERVER_VERSION; 54 using syncable::SERVER_VERSION;
50 55
51 #define ENUM_CASE(x) case x: return #x 56 #define ENUM_CASE(x) case x: return #x
52 const char* SyncerStepToString(const SyncerStep step) 57 const char* SyncerStepToString(const SyncerStep step)
53 { 58 {
54 switch (step) { 59 switch (step) {
55 ENUM_CASE(SYNCER_BEGIN); 60 ENUM_CASE(SYNCER_BEGIN);
56 ENUM_CASE(DOWNLOAD_UPDATES); 61 ENUM_CASE(DOWNLOAD_UPDATES);
57 ENUM_CASE(VERIFY_UPDATES); 62 ENUM_CASE(VERIFY_UPDATES);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) { 240 void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) {
236 dest->Put(SERVER_NON_UNIQUE_NAME, src->Get(SERVER_NON_UNIQUE_NAME)); 241 dest->Put(SERVER_NON_UNIQUE_NAME, src->Get(SERVER_NON_UNIQUE_NAME));
237 dest->Put(SERVER_PARENT_ID, src->Get(SERVER_PARENT_ID)); 242 dest->Put(SERVER_PARENT_ID, src->Get(SERVER_PARENT_ID));
238 dest->Put(SERVER_MTIME, src->Get(SERVER_MTIME)); 243 dest->Put(SERVER_MTIME, src->Get(SERVER_MTIME));
239 dest->Put(SERVER_CTIME, src->Get(SERVER_CTIME)); 244 dest->Put(SERVER_CTIME, src->Get(SERVER_CTIME));
240 dest->Put(SERVER_VERSION, src->Get(SERVER_VERSION)); 245 dest->Put(SERVER_VERSION, src->Get(SERVER_VERSION));
241 dest->Put(SERVER_IS_DIR, src->Get(SERVER_IS_DIR)); 246 dest->Put(SERVER_IS_DIR, src->Get(SERVER_IS_DIR));
242 dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL)); 247 dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL));
243 dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE)); 248 dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE));
244 dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS)); 249 dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS));
245 dest->Put(SERVER_POSITION_IN_PARENT, src->Get(SERVER_POSITION_IN_PARENT)); 250 dest->Put(SERVER_ORDINAL_IN_PARENT, src->Get(SERVER_ORDINAL_IN_PARENT));
246 } 251 }
247 252
248 void ClearServerData(syncable::MutableEntry* entry) { 253 void ClearServerData(syncable::MutableEntry* entry) {
249 entry->Put(SERVER_NON_UNIQUE_NAME, ""); 254 entry->Put(SERVER_NON_UNIQUE_NAME, "");
250 entry->Put(SERVER_PARENT_ID, syncable::GetNullId()); 255 entry->Put(SERVER_PARENT_ID, syncable::GetNullId());
251 entry->Put(SERVER_MTIME, Time()); 256 entry->Put(SERVER_MTIME, Time());
252 entry->Put(SERVER_CTIME, Time()); 257 entry->Put(SERVER_CTIME, Time());
253 entry->Put(SERVER_VERSION, 0); 258 entry->Put(SERVER_VERSION, 0);
254 entry->Put(SERVER_IS_DIR, false); 259 entry->Put(SERVER_IS_DIR, false);
255 entry->Put(SERVER_IS_DEL, false); 260 entry->Put(SERVER_IS_DEL, false);
256 entry->Put(IS_UNAPPLIED_UPDATE, false); 261 entry->Put(IS_UNAPPLIED_UPDATE, false);
257 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 262 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
258 entry->Put(SERVER_POSITION_IN_PARENT, 0); 263 entry->Put(SERVER_ORDINAL_IN_PARENT, Int64ToNodeOrdinal(0));
259 } 264 }
260 265
261 } // namespace syncer 266 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698