Chromium Code Reviews| 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; |