| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/engine/download.h" | 5 #include "sync/engine/download.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "sync/engine/process_updates_command.h" | 10 #include "sync/engine/process_updates_command.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 type, | 207 type, |
| 208 progress_marker->mutable_get_update_triggers()); | 208 progress_marker->mutable_get_update_triggers()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 return ExecuteDownloadUpdates(session, &client_to_server_message); | 211 return ExecuteDownloadUpdates(session, &client_to_server_message); |
| 212 } | 212 } |
| 213 | 213 |
| 214 SyncerError DownloadUpdatesForConfigure( | 214 SyncerError DownloadUpdatesForConfigure( |
| 215 SyncSession* session, | 215 SyncSession* session, |
| 216 bool create_mobile_bookmarks_folder, | 216 bool create_mobile_bookmarks_folder, |
| 217 const syncer::sessions::SyncSourceInfo& source, | 217 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 218 ModelTypeSet request_types) { | 218 ModelTypeSet request_types) { |
| 219 sync_pb::ClientToServerMessage client_to_server_message; | 219 sync_pb::ClientToServerMessage client_to_server_message; |
| 220 InitDownloadUpdatesRequest( | 220 InitDownloadUpdatesRequest( |
| 221 session, | 221 session, |
| 222 create_mobile_bookmarks_folder, | 222 create_mobile_bookmarks_folder, |
| 223 &client_to_server_message, | 223 &client_to_server_message, |
| 224 request_types); | 224 request_types); |
| 225 sync_pb::GetUpdatesMessage* get_updates = | 225 sync_pb::GetUpdatesMessage* get_updates = |
| 226 client_to_server_message.mutable_get_updates(); | 226 client_to_server_message.mutable_get_updates(); |
| 227 | 227 |
| 228 // Request updates for all enabled types. | 228 // Request updates for all enabled types. |
| 229 DVLOG(1) << "Initial download for types " | 229 DVLOG(1) << "Initial download for types " |
| 230 << ModelTypeSetToString(request_types); | 230 << ModelTypeSetToString(request_types); |
| 231 DCHECK(!request_types.Empty()); | 231 DCHECK(!request_types.Empty()); |
| 232 | 232 |
| 233 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. | 233 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. |
| 234 get_updates->mutable_caller_info()->set_source(source.updates_source); | 234 get_updates->mutable_caller_info()->set_source(source); |
| 235 | 235 |
| 236 // Set the new and improved version of source, too. | 236 // Set the new and improved version of source, too. |
| 237 sync_pb::SyncEnums::GetUpdatesOrigin origin = | 237 sync_pb::SyncEnums::GetUpdatesOrigin origin = |
| 238 ConvertConfigureSourceToOrigin(source.updates_source); | 238 ConvertConfigureSourceToOrigin(source); |
| 239 get_updates->set_get_updates_origin(origin); | 239 get_updates->set_get_updates_origin(origin); |
| 240 | 240 |
| 241 return ExecuteDownloadUpdates(session, &client_to_server_message); | 241 return ExecuteDownloadUpdates(session, &client_to_server_message); |
| 242 } | 242 } |
| 243 | 243 |
| 244 SyncerError DownloadUpdatesForPoll( | 244 SyncerError DownloadUpdatesForPoll( |
| 245 SyncSession* session, | 245 SyncSession* session, |
| 246 bool create_mobile_bookmarks_folder, | 246 bool create_mobile_bookmarks_folder, |
| 247 ModelTypeSet request_types) { | 247 ModelTypeSet request_types) { |
| 248 sync_pb::ClientToServerMessage client_to_server_message; | 248 sync_pb::ClientToServerMessage client_to_server_message; |
| 249 InitDownloadUpdatesRequest( | 249 InitDownloadUpdatesRequest( |
| 250 session, | 250 session, |
| 251 create_mobile_bookmarks_folder, | 251 create_mobile_bookmarks_folder, |
| 252 &client_to_server_message, | 252 &client_to_server_message, |
| 253 request_types); | 253 request_types); |
| 254 sync_pb::GetUpdatesMessage* get_updates = | 254 sync_pb::GetUpdatesMessage* get_updates = |
| 255 client_to_server_message.mutable_get_updates(); | 255 client_to_server_message.mutable_get_updates(); |
| 256 | 256 |
| 257 DVLOG(1) << "Polling for types " | 257 DVLOG(1) << "Polling for types " |
| 258 << ModelTypeSetToString(request_types); | 258 << ModelTypeSetToString(request_types); |
| 259 DCHECK(!request_types.Empty()); | 259 DCHECK(!request_types.Empty()); |
| 260 DCHECK_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC, | |
| 261 session->source().updates_source); | |
| 262 | 260 |
| 263 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. | 261 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. |
| 264 get_updates->mutable_caller_info()->set_source( | 262 get_updates->mutable_caller_info()->set_source( |
| 265 sync_pb::GetUpdatesCallerInfo::PERIODIC); | 263 sync_pb::GetUpdatesCallerInfo::PERIODIC); |
| 266 | 264 |
| 267 // Set the new and improved version of source, too. | 265 // Set the new and improved version of source, too. |
| 268 get_updates->set_get_updates_origin(sync_pb::SyncEnums::PERIODIC); | 266 get_updates->set_get_updates_origin(sync_pb::SyncEnums::PERIODIC); |
| 269 | 267 |
| 270 return ExecuteDownloadUpdates(session, &client_to_server_message); | 268 return ExecuteDownloadUpdates(session, &client_to_server_message); |
| 271 } | 269 } |
| 272 | 270 |
| 273 void AppendClientDebugInfoIfNeeded( | 271 void AppendClientDebugInfoIfNeeded( |
| 274 SyncSession* session, | 272 SyncSession* session, |
| 275 DebugInfo* debug_info) { | 273 DebugInfo* debug_info) { |
| 276 // We want to send the debug info only once per sync cycle. Check if it has | 274 // We want to send the debug info only once per sync cycle. Check if it has |
| 277 // already been sent. | 275 // already been sent. |
| 278 if (!session->status_controller().debug_info_sent()) { | 276 if (!session->status_controller().debug_info_sent()) { |
| 279 DVLOG(1) << "Sending client debug info ..."; | 277 DVLOG(1) << "Sending client debug info ..."; |
| 280 // could be null in some unit tests. | 278 // could be null in some unit tests. |
| 281 if (session->context()->debug_info_getter()) { | 279 if (session->context()->debug_info_getter()) { |
| 282 session->context()->debug_info_getter()->GetAndClearDebugInfo( | 280 session->context()->debug_info_getter()->GetAndClearDebugInfo( |
| 283 debug_info); | 281 debug_info); |
| 284 } | 282 } |
| 285 session->mutable_status_controller()->set_debug_info_sent(); | 283 session->mutable_status_controller()->set_debug_info_sent(); |
| 286 } | 284 } |
| 287 } | 285 } |
| 288 | 286 |
| 289 } // namespace syncer | 287 } // namespace syncer |
| OLD | NEW |