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

Unified Diff: sync/engine/directory_update_handler.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/engine/directory_update_handler.cc
diff --git a/sync/engine/directory_update_handler.cc b/sync/engine/directory_update_handler.cc
index 0a4ec856d820bc44709e10ae2b3a8dc632d99d52..c22030c24218fa4ef47bef81c416c712fa4506c3 100644
--- a/sync/engine/directory_update_handler.cc
+++ b/sync/engine/directory_update_handler.cc
@@ -9,6 +9,7 @@
#include "sync/engine/update_applicator.h"
#include "sync/sessions/directory_type_debug_info_emitter.h"
#include "sync/syncable/directory.h"
+#include "sync/syncable/model_neutral_mutable_entry.h"
#include "sync/syncable/syncable_model_neutral_write_transaction.h"
#include "sync/syncable/syncable_write_transaction.h"
@@ -65,16 +66,42 @@ SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse(
}
}
+ // Auto-create permanent folder for the type if the progress marker
+ // changes from empty to non-empty.
+ if (!IsTypeWithServerGeneratedRoot(type_) &&
+ dir_->HasEmptyDownloadProgress(type_) &&
+ !progress_marker.token().empty() &&
+ IsValidProgressMarker(progress_marker)) {
Nicolas Zea 2015/01/26 23:21:53 Should IsValidProgressMarker be performing the che
stanisc 2015/01/28 07:30:05 I guess that should be OK. I'll change this.
stanisc 2015/01/29 00:27:37 Done.
+ CreateTypeRoot(&trans);
+ }
+
UpdateSyncEntities(&trans, applicable_updates, status);
if (IsValidProgressMarker(progress_marker)) {
ExpireEntriesIfNeeded(&trans, progress_marker);
UpdateProgressMarker(progress_marker);
}
+
debug_info_emitter_->EmitUpdateCountersUpdate();
return SYNCER_OK;
}
+void DirectoryUpdateHandler::CreateTypeRoot(
+ syncable::ModelNeutralWriteTransaction* trans) {
+ syncable::ModelNeutralMutableEntry entry(
+ trans, syncable::CREATE_NEW_TYPE_ROOT, type_);
+ if (!entry.good()) {
+ // This will fail only if matching entry already exists.
+ DVLOG(1) << "Type root folder "
Nicolas Zea 2015/01/26 23:21:53 Comment that this is expected for older versions o
stanisc 2015/01/28 07:30:05 Actually for an older version of the server this w
Nicolas Zea 2015/01/30 00:07:21 Was there a comment you meant to put here?
+ << ModelTypeToRootTag(type_)
+ << " already exists.";
+ return;
+ }
+
+ entry.PutServerIsDir(true);
+ entry.PutUniqueServerTag(ModelTypeToRootTag(type_));
+}
+
void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
if (!IsApplyUpdatesRequired()) {
return;

Powered by Google App Engine
This is Rietveld 408576698