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

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 extra comment about existing type root folder. 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
« no previous file with comments | « sync/engine/directory_update_handler.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..04c83da8b76514464615df3803ac042a814c69c0 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_) &&
+ IsValidProgressMarker(progress_marker)) {
+ 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, for example
+ // if the type gets disabled and its progress marker gets cleared,
+ // then the type gets re-enabled again.
+ DVLOG(1) << "Type root folder " << ModelTypeToRootTag(type_)
+ << " already exists.";
+ return;
+ }
+
+ entry.PutServerIsDir(true);
+ entry.PutUniqueServerTag(ModelTypeToRootTag(type_));
+}
+
void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
if (!IsApplyUpdatesRequired()) {
return;
@@ -205,6 +232,9 @@ void DirectoryUpdateHandler::UpdateSyncEntities(
bool DirectoryUpdateHandler::IsValidProgressMarker(
const sync_pb::DataTypeProgressMarker& progress_marker) const {
+ if (progress_marker.token().empty()) {
+ return false;
+ }
int field_number = progress_marker.data_type_id();
ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
if (!IsRealDataType(model_type) || type_ != model_type) {
« no previous file with comments | « sync/engine/directory_update_handler.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698