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

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

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Ordinal default ctor now creates invalid Ordinals 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_util.h" 5 #include "sync/engine/syncer_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 #include "sync/syncable/entry.h" 22 #include "sync/syncable/entry.h"
23 #include "sync/syncable/mutable_entry.h" 23 #include "sync/syncable/mutable_entry.h"
24 #include "sync/syncable/read_transaction.h" 24 #include "sync/syncable/read_transaction.h"
25 #include "sync/syncable/syncable_changes_version.h" 25 #include "sync/syncable/syncable_changes_version.h"
26 #include "sync/syncable/syncable_proto_util.h" 26 #include "sync/syncable/syncable_proto_util.h"
27 #include "sync/syncable/syncable_util.h" 27 #include "sync/syncable/syncable_util.h"
28 #include "sync/syncable/write_transaction.h" 28 #include "sync/syncable/write_transaction.h"
29 #include "sync/util/cryptographer.h" 29 #include "sync/util/cryptographer.h"
30 #include "sync/util/time.h" 30 #include "sync/util/time.h"
31 31
32 //TODO(vishwath): Remove this include after node positions have
akalin 2012/10/05 22:40:27 space after //
33 // shifted to completely uing Ordinals.
34 // See http://crbug.com/145412 .
35 #include "sync/internal_api/public/base/node_ordinal.h"
36
32 namespace syncer { 37 namespace syncer {
33 38
34 using syncable::BASE_VERSION; 39 using syncable::BASE_VERSION;
35 using syncable::CHANGES_VERSION; 40 using syncable::CHANGES_VERSION;
36 using syncable::CREATE_NEW_UPDATE_ITEM; 41 using syncable::CREATE_NEW_UPDATE_ITEM;
37 using syncable::CTIME; 42 using syncable::CTIME;
38 using syncable::Directory; 43 using syncable::Directory;
39 using syncable::Entry; 44 using syncable::Entry;
40 using syncable::GET_BY_HANDLE; 45 using syncable::GET_BY_HANDLE;
41 using syncable::GET_BY_ID; 46 using syncable::GET_BY_ID;
42 using syncable::ID; 47 using syncable::ID;
43 using syncable::IS_DEL; 48 using syncable::IS_DEL;
44 using syncable::IS_DIR; 49 using syncable::IS_DIR;
45 using syncable::IS_UNAPPLIED_UPDATE; 50 using syncable::IS_UNAPPLIED_UPDATE;
46 using syncable::IS_UNSYNCED; 51 using syncable::IS_UNSYNCED;
47 using syncable::Id; 52 using syncable::Id;
48 using syncable::META_HANDLE; 53 using syncable::META_HANDLE;
49 using syncable::MTIME; 54 using syncable::MTIME;
50 using syncable::MutableEntry; 55 using syncable::MutableEntry;
51 using syncable::NON_UNIQUE_NAME; 56 using syncable::NON_UNIQUE_NAME;
52 using syncable::BASE_SERVER_SPECIFICS; 57 using syncable::BASE_SERVER_SPECIFICS;
53 using syncable::PARENT_ID; 58 using syncable::PARENT_ID;
54 using syncable::PREV_ID; 59 using syncable::PREV_ID;
55 using syncable::SERVER_CTIME; 60 using syncable::SERVER_CTIME;
56 using syncable::SERVER_IS_DEL; 61 using syncable::SERVER_IS_DEL;
57 using syncable::SERVER_IS_DIR; 62 using syncable::SERVER_IS_DIR;
58 using syncable::SERVER_MTIME; 63 using syncable::SERVER_MTIME;
59 using syncable::SERVER_NON_UNIQUE_NAME; 64 using syncable::SERVER_NON_UNIQUE_NAME;
60 using syncable::SERVER_PARENT_ID; 65 using syncable::SERVER_PARENT_ID;
61 using syncable::SERVER_POSITION_IN_PARENT; 66 using syncable::SERVER_ORDINAL_IN_PARENT;
62 using syncable::SERVER_SPECIFICS; 67 using syncable::SERVER_SPECIFICS;
63 using syncable::SERVER_VERSION; 68 using syncable::SERVER_VERSION;
64 using syncable::UNIQUE_CLIENT_TAG; 69 using syncable::UNIQUE_CLIENT_TAG;
65 using syncable::UNIQUE_SERVER_TAG; 70 using syncable::UNIQUE_SERVER_TAG;
66 using syncable::SPECIFICS; 71 using syncable::SPECIFICS;
67 using syncable::SYNCER; 72 using syncable::SYNCER;
68 using syncable::WriteTransaction; 73 using syncable::WriteTransaction;
69 74
70 syncable::Id FindLocalIdToUpdate( 75 syncable::Id FindLocalIdToUpdate(
71 syncable::BaseTransaction* trans, 76 syncable::BaseTransaction* trans,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 target->Put(SERVER_SPECIFICS, update.specifics()); 349 target->Put(SERVER_SPECIFICS, update.specifics());
345 } else if (update.has_bookmarkdata()) { 350 } else if (update.has_bookmarkdata()) {
346 // Legacy protocol response for bookmark data. 351 // Legacy protocol response for bookmark data.
347 const sync_pb::SyncEntity::BookmarkData& bookmark = update.bookmarkdata(); 352 const sync_pb::SyncEntity::BookmarkData& bookmark = update.bookmarkdata();
348 UpdateBookmarkSpecifics(update.server_defined_unique_tag(), 353 UpdateBookmarkSpecifics(update.server_defined_unique_tag(),
349 bookmark.bookmark_url(), 354 bookmark.bookmark_url(),
350 bookmark.bookmark_favicon(), 355 bookmark.bookmark_favicon(),
351 target); 356 target);
352 } 357 }
353 if (update.has_position_in_parent()) 358 if (update.has_position_in_parent())
354 target->Put(SERVER_POSITION_IN_PARENT, update.position_in_parent()); 359 target->Put(SERVER_ORDINAL_IN_PARENT,
360 Int64ToNodeOrdinal(update.position_in_parent()));
355 361
356 target->Put(SERVER_IS_DEL, update.deleted()); 362 target->Put(SERVER_IS_DEL, update.deleted());
357 // We only mark the entry as unapplied if its version is greater than the 363 // We only mark the entry as unapplied if its version is greater than the
358 // local data. If we're processing the update that corresponds to one of our 364 // local data. If we're processing the update that corresponds to one of our
359 // commit we don't apply it as time differences may occur. 365 // commit we don't apply it as time differences may occur.
360 if (update.version() > target->Get(BASE_VERSION)) { 366 if (update.version() > target->Get(BASE_VERSION)) {
361 target->Put(IS_UNAPPLIED_UPDATE, true); 367 target->Put(IS_UNAPPLIED_UPDATE, true);
362 } 368 }
363 } 369 }
364 370
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 if (update.version() < target->Get(SERVER_VERSION)) { 650 if (update.version() < target->Get(SERVER_VERSION)) {
645 LOG(WARNING) << "Update older than current server version for " 651 LOG(WARNING) << "Update older than current server version for "
646 << *target << " Update:" 652 << *target << " Update:"
647 << SyncerProtoUtil::SyncEntityDebugString(update); 653 << SyncerProtoUtil::SyncEntityDebugString(update);
648 return VERIFY_SUCCESS; // Expected in new sync protocol. 654 return VERIFY_SUCCESS; // Expected in new sync protocol.
649 } 655 }
650 return VERIFY_UNDECIDED; 656 return VERIFY_UNDECIDED;
651 } 657 }
652 658
653 } // namespace syncer 659 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698