OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/get_updates_processor.h" | 5 #include "sync/engine/get_updates_processor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "sync/engine/get_updates_delegate.h" | 10 #include "sync/engine/get_updates_delegate.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 if (result != SYNCER_OK) { | 235 if (result != SYNCER_OK) { |
236 GetUpdatesResponseEvent response_event( | 236 GetUpdatesResponseEvent response_event( |
237 base::Time::Now(), update_response, result); | 237 base::Time::Now(), update_response, result); |
238 session->SendProtocolEvent(response_event); | 238 session->SendProtocolEvent(response_event); |
239 | 239 |
240 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; | 240 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; |
241 return result; | 241 return result; |
242 } | 242 } |
243 | 243 |
244 DVLOG(1) << "GetUpdates " | 244 DVLOG(1) << "GetUpdates returned " |
245 << " returned " << update_response.get_updates().entries_size() | 245 << update_response.get_updates().entries_size() |
246 << " updates and indicated " | 246 << " updates."; |
247 << update_response.get_updates().changes_remaining() | 247 |
248 << " updates left on server."; | |
249 | 248 |
250 if (session->context()->debug_info_getter()) { | 249 if (session->context()->debug_info_getter()) { |
251 // Clear debug info now that we have successfully sent it to the server. | 250 // Clear debug info now that we have successfully sent it to the server. |
252 DVLOG(1) << "Clearing client debug info."; | 251 DVLOG(1) << "Clearing client debug info."; |
253 session->context()->debug_info_getter()->ClearDebugInfo(); | 252 session->context()->debug_info_getter()->ClearDebugInfo(); |
254 } | 253 } |
255 | 254 |
256 if (need_encryption_key || | 255 if (need_encryption_key || |
257 update_response.get_updates().encryption_keys_size() > 0) { | 256 update_response.get_updates().encryption_keys_size() > 0) { |
258 syncable::Directory* dir = session->context()->directory(); | 257 syncable::Directory* dir = session->context()->directory(); |
259 status->set_last_get_key_result( | 258 status->set_last_get_key_result( |
260 HandleGetEncryptionKeyResponse(update_response, dir)); | 259 HandleGetEncryptionKeyResponse(update_response, dir)); |
261 } | 260 } |
262 | 261 |
263 SyncerError process_result = ProcessResponse(update_response.get_updates(), | 262 SyncerError process_result = ProcessResponse(update_response.get_updates(), |
264 request_types, | 263 request_types, |
265 status); | 264 status); |
266 | 265 |
267 GetUpdatesResponseEvent response_event( | 266 GetUpdatesResponseEvent response_event( |
268 base::Time::Now(), update_response, process_result); | 267 base::Time::Now(), update_response, process_result); |
269 session->SendProtocolEvent(response_event); | 268 session->SendProtocolEvent(response_event); |
270 | 269 |
| 270 DVLOG(1) << "GetUpdates result: " << process_result; |
| 271 |
271 return process_result; | 272 return process_result; |
272 } | 273 } |
273 | 274 |
274 SyncerError GetUpdatesProcessor::ProcessResponse( | 275 SyncerError GetUpdatesProcessor::ProcessResponse( |
275 const sync_pb::GetUpdatesResponse& gu_response, | 276 const sync_pb::GetUpdatesResponse& gu_response, |
276 ModelTypeSet request_types, | 277 ModelTypeSet request_types, |
277 sessions::StatusController* status) { | 278 sessions::StatusController* status) { |
278 status->increment_num_updates_downloaded_by(gu_response.entries_size()); | 279 status->increment_num_updates_downloaded_by(gu_response.entries_size()); |
279 | 280 |
280 // The changes remaining field is used to prevent the client from looping. If | 281 // The changes remaining field is used to prevent the client from looping. If |
281 // that field is being set incorrectly, we're in big trouble. | 282 // that field is being set incorrectly, we're in big trouble. |
282 if (!gu_response.has_changes_remaining()) { | 283 if (!gu_response.has_changes_remaining()) { |
283 return SERVER_RESPONSE_VALIDATION_FAILED; | 284 return SERVER_RESPONSE_VALIDATION_FAILED; |
284 } | 285 } |
285 status->set_num_server_changes_remaining(gu_response.changes_remaining()); | |
286 | 286 |
287 syncer::SyncerError result = | 287 syncer::SyncerError result = |
288 ProcessGetUpdatesResponse(request_types, gu_response, status); | 288 ProcessGetUpdatesResponse(request_types, gu_response, status); |
289 if (result != syncer::SYNCER_OK) | 289 if (result != syncer::SYNCER_OK) |
290 return result; | 290 return result; |
291 | 291 |
292 if (gu_response.changes_remaining() == 0) { | 292 if (gu_response.changes_remaining() == 0) { |
293 return SYNCER_OK; | 293 return SYNCER_OK; |
294 } else { | 294 } else { |
295 return SERVER_MORE_TO_DOWNLOAD; | 295 return SERVER_MORE_TO_DOWNLOAD; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 void GetUpdatesProcessor::CopyClientDebugInfo( | 365 void GetUpdatesProcessor::CopyClientDebugInfo( |
366 sessions::DebugInfoGetter* debug_info_getter, | 366 sessions::DebugInfoGetter* debug_info_getter, |
367 sync_pb::DebugInfo* debug_info) { | 367 sync_pb::DebugInfo* debug_info) { |
368 DVLOG(1) << "Copying client debug info to send."; | 368 DVLOG(1) << "Copying client debug info to send."; |
369 debug_info_getter->GetDebugInfo(debug_info); | 369 debug_info_getter->GetDebugInfo(debug_info); |
370 } | 370 } |
371 | 371 |
372 } // namespace syncer | 372 } // namespace syncer |
OLD | NEW |