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

Unified Diff: sync/syncable/directory.cc

Issue 867793003: Remove dependency on server generated type root folders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ScopedKernelLock to Directory::HasEmptyDownloadProgress Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: sync/syncable/directory.cc
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 68774df644bc94e5b8d25b9a341d245cfd55143f..1d7aa5cf24354f6593896e4152f3b2ad1ec740a3 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -61,8 +61,8 @@ void Directory::PersistedKernelInfo::ResetDownloadProgress(
bool Directory::PersistedKernelInfo::HasEmptyDownloadProgress(
ModelType model_type) {
- const sync_pb::DataTypeProgressMarker& progress_marker =
- download_progress[model_type];
+ const sync_pb::DataTypeProgressMarker& progress_marker =
+ download_progress[model_type];
return progress_marker.token().empty();
}
@@ -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: change these to not rely on the folders
Nicolas Zea 2015/01/26 23:21:53 nit: TODO's typically have an owner and a bug, e.g
stanisc 2015/01/29 00:27:37 Done.
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,13 +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.",
+ "The entry should have been deleted.",
trans))
return false;
}
@@ -1246,12 +1253,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 +1484,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));
}
}

Powered by Google App Engine
This is Rietveld 408576698