| 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)) {
|
| + 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 "
|
| + << ModelTypeToRootTag(type_)
|
| + << " already exists.";
|
| + return;
|
| + }
|
| +
|
| + entry.PutServerIsDir(true);
|
| + entry.PutUniqueServerTag(ModelTypeToRootTag(type_));
|
| +}
|
| +
|
| void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
|
| if (!IsApplyUpdatesRequired()) {
|
| return;
|
|
|