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

Unified Diff: sync/syncable/directory.cc

Issue 1393633003: Sync: fix for the code that checks whether the initial download has completed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/syncable/directory.h ('k') | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory.cc
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 3b735e9eccfd7255fa9046b607c2feef11ba005b..33cb6d4bd9bd0b83632bdc25c96c7f670663859d 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -19,6 +19,7 @@
#include "sync/syncable/entry.h"
#include "sync/syncable/entry_kernel.h"
#include "sync/syncable/in_memory_directory_backing_store.h"
+#include "sync/syncable/model_neutral_mutable_entry.h"
#include "sync/syncable/on_disk_directory_backing_store.h"
#include "sync/syncable/scoped_kernel_lock.h"
#include "sync/syncable/scoped_parent_child_index_updater.h"
@@ -985,9 +986,29 @@ bool Directory::InitialSyncEndedForType(ModelType type) {
bool Directory::InitialSyncEndedForType(
BaseTransaction* trans, ModelType type) {
- // True iff the type's root node has been created.
- syncable::Entry entry(trans, syncable::GET_TYPE_ROOT, type);
- return entry.good();
+ // True iff the type's root node has been created and changes
+ // for the type have been applied at least once.
+ Entry root(trans, GET_TYPE_ROOT, type);
+ return root.good() && root.GetBaseVersion() != CHANGES_VERSION;
+}
+
+void Directory::MarkInitialSyncEndedForType(BaseWriteTransaction* trans,
+ ModelType type) {
+ // If the root folder is downloaded for the server, the root's base version
+ // get updated automatically at the end of update cycle when the update gets
+ // applied. However if this is a type with client generated root, the root
+ // node gets created locally and never goes through the update cycle. In that
+ // case its base version has to be explictly changed from CHANGES_VERSION
+ // at the end of the initial update cycle to mark the type as downloaded.
+ // See Directory::InitialSyncEndedForType
+ DCHECK(IsTypeWithClientGeneratedRoot(type));
+ ModelNeutralMutableEntry root(trans, GET_TYPE_ROOT, type);
+
+ // Some tests don't bother creating type root. Need to check if the root
+ // exists before clearing its base version.
+ if (root.good() && root.GetBaseVersion() == CHANGES_VERSION) {
+ root.PutBaseVersion(0);
+ }
}
string Directory::store_birthday() const {
« no previous file with comments | « sync/syncable/directory.h ('k') | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698