diff options
author | stanisc <stanisc@chromium.org> | 2015-07-10 14:26:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-10 21:27:55 +0000 |
commit | c2b13973453530ab01e92fee880e14b34c0c420b (patch) | |
tree | 64f6b262691629a7f10d8282fd5a12be84acd018 /sync/syncable/entry_kernel.cc | |
parent | c3c3b7ad436e9232ca6dbcd43c6c0ed682080993 (diff) | |
download | chromium_src-c2b13973453530ab01e92fee880e14b34c0c420b.zip chromium_src-c2b13973453530ab01e92fee880e14b34c0c420b.tar.gz chromium_src-c2b13973453530ab01e92fee880e14b34c0c420b.tar.bz2 |
Sync: Support nodes with implicit permanent folders:
Node Browser and out-of-order loading from DB
The fix contains two parts:
1) Changed Sync Node Browser code to handle nodes with unset
PARENT_ID. The parent ID would be unset only for nodes with
flat hierarchy where all the nodes are under the same type
root folder. In that case the parent-child relationship is
determined based on the node's model type.
EntryKernel::ToValue already generated serverModelType field,
although it would be unset for nodes that never synced to
the server. To make it more reliable I changed the field to
modelType and added the code to set it based on combination
of both server and client model type. Most of the change
deals with renaming serverModelType to modelType.
2) When testing the issue #1 with an older account I noticed
issues with ParentChildIndex not associating a few
nodes (with implicit Parent ID) correctly with their
corresponding permanent folders.
The issue turned out to be caused by an arbitrary out-of-order
loading of nodes from the database. When a node with unset Parent ID
was inserted before its permanent folder, ParentChildIndex
would place it in the OrderedChildSet associated with empty ("")
ParentID and this node would essentially be invisible
for the rest of the code querying the index.
To handle this out-of-order insertion correctly, I changed
data organization in ParentChildIndex. There now two data
structures:
a) Parent ID to OrderedChildSet map is still used to organize
collections of children for types with explicit
Parent ID like bookmarks.
b) There is also an array of OrderedChildSet indexed by
model type which contains flat collections of entries for
non-hierarchical types.
c) The latter type of collections are also shared with the
Parent ID to OrderedChildSet map so that querying by
Parent ID still works non-hierarchical types.
The sharing occurs when the index sees an entry that it
recognizes as a type root folder.
BUG=438313
TBR=nkostylev@chromium.org
Review URL: https://codereview.chromium.org/1226213002
Cr-Commit-Position: refs/heads/master@{#338364}
Diffstat (limited to 'sync/syncable/entry_kernel.cc')
-rw-r--r-- | sync/syncable/entry_kernel.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sync/syncable/entry_kernel.cc b/sync/syncable/entry_kernel.cc index 52481f2..d73acaf 100644 --- a/sync/syncable/entry_kernel.cc +++ b/sync/syncable/entry_kernel.cc @@ -52,16 +52,16 @@ ModelType EntryKernel::GetServerModelType() const { bool EntryKernel::ShouldMaintainPosition() const { // We maintain positions for all bookmarks, except those that are // server-created top-level folders. - return (GetModelTypeFromSpecifics(ref(SPECIFICS)) == syncer::BOOKMARKS) - && !(!ref(UNIQUE_SERVER_TAG).empty() && ref(IS_DIR)); + return TypeSupportsOrdering(GetModelTypeFromSpecifics(ref(SPECIFICS))) && + !(!ref(UNIQUE_SERVER_TAG).empty() && ref(IS_DIR)); } bool EntryKernel::ShouldMaintainHierarchy() const { // We maintain hierarchy for bookmarks and top-level folders, // but no other types. Note that the Nigori node consists of a single // top-level folder, so it's included in this set. - return (GetModelTypeFromSpecifics(ref(SPECIFICS)) == syncer::BOOKMARKS) - || (!ref(UNIQUE_SERVER_TAG).empty()); + return TypeSupportsHierarchy(GetModelTypeFromSpecifics(ref(SPECIFICS))) || + (!ref(UNIQUE_SERVER_TAG).empty()); } namespace { @@ -148,7 +148,10 @@ base::DictionaryValue* EntryKernel::ToValue( Cryptographer* cryptographer) const { base::DictionaryValue* kernel_info = new base::DictionaryValue(); kernel_info->SetBoolean("isDirty", is_dirty()); - kernel_info->Set("serverModelType", ModelTypeToValue(GetServerModelType())); + ModelType dataType = GetServerModelType(); + if (!IsRealDataType(dataType)) + dataType = GetModelType(); + kernel_info->Set("modelType", ModelTypeToValue(dataType)); // Int64 fields. SetFieldValues(*this, kernel_info, |