| Index: sync/syncable/directory.cc
|
| diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
|
| index 68774df644bc94e5b8d25b9a341d245cfd55143f..6601da53abc22d60bfdc425c909fd3ed781e49e4 100644
|
| --- a/sync/syncable/directory.cc
|
| +++ b/sync/syncable/directory.cc
|
| @@ -925,6 +925,11 @@ void Directory::SetDownloadProgress(
|
| kernel_->info_status = KERNEL_SHARE_INFO_DIRTY;
|
| }
|
|
|
| +bool Directory::HasEmptyDownloadProgress(ModelType type) const {
|
| + ScopedKernelLock lock(this);
|
| + return kernel_->persisted_info.HasEmptyDownloadProgress(type);
|
| +}
|
| +
|
| int64 Directory::GetTransactionVersion(ModelType type) const {
|
| kernel_->transaction_mutex.AssertAcquired();
|
| return kernel_->persisted_info.transaction_version[type];
|
| @@ -951,6 +956,7 @@ void Directory::SetDataTypeContext(
|
| kernel_->info_status = KERNEL_SHARE_INFO_DIRTY;
|
| }
|
|
|
| +// TODO(stanisc): crbug.com/438313: change these to not rely on the folders.
|
| ModelTypeSet Directory::InitialSyncEndedTypes() {
|
| syncable::ReadTransaction trans(FROM_HERE, this);
|
| ModelTypeSet protocol_types = ProtocolTypes();
|
| @@ -1175,8 +1181,7 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
|
| "Entry should be root",
|
| trans))
|
| return false;
|
| - if (!SyncAssert(!e.GetIsUnsynced(), FROM_HERE,
|
| - "Entry should be sycned",
|
| + if (!SyncAssert(!e.GetIsUnsynced(), FROM_HERE, "Entry should be synced",
|
| trans))
|
| return false;
|
| continue;
|
| @@ -1194,7 +1199,6 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
|
|
|
| if (!parentid.IsNull()) {
|
| int safety_count = handles.size() + 1;
|
| - // TODO(stanisc): handle items with Null parentid
|
| while (!parentid.IsRoot()) {
|
| Entry parent(trans, GET_BY_ID, parentid);
|
| if (!SyncAssert(parent.good(), FROM_HERE,
|
| @@ -1222,14 +1226,16 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
|
| int64 base_version = e.GetBaseVersion();
|
| int64 server_version = e.GetServerVersion();
|
| bool using_unique_client_tag = !e.GetUniqueClientTag().empty();
|
| + bool is_type_root_folder =
|
| + parentid.IsRoot() &&
|
| + e.GetUniqueServerTag() == ModelTypeToRootTag(e.GetModelType());
|
| if (CHANGES_VERSION == base_version || 0 == base_version) {
|
| if (e.GetIsUnappliedUpdate()) {
|
| // Must be a new item, or a de-duplicated unique client tag
|
| // that was created both locally and remotely.
|
| - if (!using_unique_client_tag) {
|
| + if (!(using_unique_client_tag || is_type_root_folder)) {
|
| if (!SyncAssert(e.GetIsDel(), FROM_HERE,
|
| - "The entry should not have been deleted.",
|
| - trans))
|
| + "The entry should have been deleted.", trans))
|
| return false;
|
| }
|
| // It came from the server, so it must have a server ID.
|
| @@ -1246,12 +1252,26 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
|
| trans))
|
| return false;
|
| }
|
| - // Should be an uncomitted item, or a successfully deleted one.
|
| - if (!e.GetIsDel()) {
|
| - if (!SyncAssert(e.GetIsUnsynced(), FROM_HERE,
|
| - "The item should be unsynced.",
|
| - trans))
|
| + if (is_type_root_folder) {
|
| + // This must be a locally created type root folder
|
| + if (!SyncAssert(
|
| + !e.GetIsUnsynced(), FROM_HERE,
|
| + "Locally created type root folders should not be unsynced.",
|
| + trans))
|
| + return false;
|
| +
|
| + if (!SyncAssert(
|
| + !e.GetIsDel(), FROM_HERE,
|
| + "Locally created type root folders should not be deleted.",
|
| + trans))
|
| return false;
|
| + } else {
|
| + // Should be an uncomitted item, or a successfully deleted one.
|
| + if (!e.GetIsDel()) {
|
| + if (!SyncAssert(e.GetIsUnsynced(), FROM_HERE,
|
| + "The item should be unsynced.", trans))
|
| + return false;
|
| + }
|
| }
|
| // If the next check failed, it would imply that an item exists
|
| // on the server, isn't waiting for application locally, but either
|
| @@ -1463,7 +1483,6 @@ void Directory::AppendChildHandles(const ScopedKernelLock& lock,
|
|
|
| for (OrderedChildSet::const_iterator i = children->begin();
|
| i != children->end(); ++i) {
|
| - DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID));
|
| result->push_back((*i)->ref(META_HANDLE));
|
| }
|
| }
|
|
|