Chromium Code Reviews| Index: sync/engine/download_updates_command.cc |
| diff --git a/sync/engine/download_updates_command.cc b/sync/engine/download_updates_command.cc |
| index 329fab1fc3b7caf1dbb07d840456142fa6cfd0c6..ea39ac7e886aaa99ec5961af2f9983e7cd17fe61 100644 |
| --- a/sync/engine/download_updates_command.cc |
| +++ b/sync/engine/download_updates_command.cc |
| @@ -10,6 +10,7 @@ |
| #include "sync/engine/syncer.h" |
| #include "sync/engine/syncer_proto_util.h" |
| #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
| +#include "sync/sessions/nudge_tracker.h" |
| #include "sync/syncable/directory.h" |
| #include "sync/syncable/nigori_handler.h" |
| #include "sync/syncable/syncable_read_transaction.h" |
| @@ -50,6 +51,37 @@ SyncerError HandleGetEncryptionKeyResponse( |
| return (success ? SYNCER_OK : SERVER_RESPONSE_VALIDATION_FAILED); |
| } |
| +sync_pb::SyncEnums::GetUpdatesOrigin ConvertGetUpdateSourceToOrigin( |
| + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { |
| + switch (source) { |
| + // Configurations: |
| + case sync_pb::GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE: |
| + return sync_pb::SyncEnums::NEWLY_SUPPORTED_DATATYPE; |
| + case sync_pb::GetUpdatesCallerInfo::MIGRATION: |
| + return sync_pb::SyncEnums::MIGRATION; |
| + case sync_pb::GetUpdatesCallerInfo::RECONFIGURATION: |
| + return sync_pb::SyncEnums::RECONFIGURATION; |
| + |
| + // Poll, which never overlaps with anything else: |
| + case sync_pb::GetUpdatesCallerInfo::PERIODIC: |
| + return sync_pb::SyncEnums::PERIODIC; |
| + |
| + // Overlapping normal-mode sources (fall-through is intentional): |
| + case sync_pb::GetUpdatesCallerInfo::LOCAL: |
| + case sync_pb::GetUpdatesCallerInfo::NOTIFICATION: |
| + case sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH: |
| + return sync_pb::SyncEnums::GU_TRIGGER; |
| + |
| + // Deprecated or invalid (fall-through is intentional): |
| + case sync_pb::GetUpdatesCallerInfo::UNKNOWN: |
| + case sync_pb::GetUpdatesCallerInfo::FIRST_UPDATE: |
| + case sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION: |
| + case sync_pb::GetUpdatesCallerInfo::NEW_CLIENT: |
| + NOTREACHED(); |
| + return sync_pb::SyncEnums::UNKNOWN_ORIGIN; |
| + } |
| +} |
| + |
| } // namespace |
| SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
| @@ -64,6 +96,9 @@ SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
| get_updates->set_create_mobile_bookmarks_folder( |
| create_mobile_bookmarks_folder_); |
| + sync_pb::SyncEnums::GetUpdatesOrigin origin = |
| + ConvertGetUpdateSourceToOrigin(session->source().updates_source); |
| + |
| syncable::Directory* dir = session->context()->directory(); |
| // Request updates for all enabled types. |
| @@ -89,6 +124,15 @@ SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
| if (find_it != invalidation_map.end()) { |
| progress_marker->set_notification_hint(find_it->second.payload); |
| } |
| + |
| + if (session->nudge_tracker()) { |
| + DCHECK_EQ(sync_pb::SyncEnums::GU_TRIGGER, origin); |
|
tim (not reviewing)
2013/05/06 21:29:04
The real question we're asking is "What kind of GU
rlarocque
2013/05/07 18:45:39
Done.
|
| + session->nudge_tracker()->FillProtoMessage( |
| + it.Get(), |
| + progress_marker->mutable_get_update_triggers()); |
| + } else { |
| + DCHECK_NE(sync_pb::SyncEnums::GU_TRIGGER, origin); |
| + } |
| } |
| bool need_encryption_key = false; |
| @@ -112,6 +156,9 @@ SyncerError DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) { |
| get_updates->mutable_caller_info()->set_notifications_enabled( |
| session->context()->notifications_enabled()); |
| + // Set the new and improved version of source, too. |
| + get_updates->set_get_updates_origin(origin); |
| + |
| DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); |
| AppendClientDebugInfoIfNeeded(session, debug_info); |