Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: sync/engine/download.cc

Issue 61213009: Don't drop debug_info when posting to sync server fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed debug_info_sent/set_debug_info_sent. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_util.h" 10 #include "sync/engine/process_updates_util.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 message->set_share(session->context()->account_name()); 87 message->set_share(session->context()->account_name());
88 message->set_message_contents(sync_pb::ClientToServerMessage::GET_UPDATES); 88 message->set_message_contents(sync_pb::ClientToServerMessage::GET_UPDATES);
89 89
90 sync_pb::GetUpdatesMessage* get_updates = message->mutable_get_updates(); 90 sync_pb::GetUpdatesMessage* get_updates = message->mutable_get_updates();
91 91
92 // We want folders for our associated types, always. If we were to set 92 // We want folders for our associated types, always. If we were to set
93 // this to false, the server would send just the non-container items 93 // this to false, the server would send just the non-container items
94 // (e.g. Bookmark URLs but not their containing folders). 94 // (e.g. Bookmark URLs but not their containing folders).
95 get_updates->set_fetch_folders(true); 95 get_updates->set_fetch_folders(true);
96 96
97 sync_pb::DebugInfo* debug_info = message->mutable_debug_info();
98 AppendClientDebugInfoIfNeeded(session->context()->debug_info_getter(),
99 session->mutable_status_controller(),
100 debug_info);
101
102 get_updates->set_create_mobile_bookmarks_folder( 97 get_updates->set_create_mobile_bookmarks_folder(
103 create_mobile_bookmarks_folder); 98 create_mobile_bookmarks_folder);
104 bool need_encryption_key = ShouldRequestEncryptionKey(session->context()); 99 bool need_encryption_key = ShouldRequestEncryptionKey(session->context());
105 get_updates->set_need_encryption_key(need_encryption_key); 100 get_updates->set_need_encryption_key(need_encryption_key);
106 101
107 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. 102 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information.
108 get_updates->mutable_caller_info()->set_notifications_enabled( 103 get_updates->mutable_caller_info()->set_notifications_enabled(
109 session->context()->notifications_enabled()); 104 session->context()->notifications_enabled());
110 } 105 }
111 106
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 332 }
338 333
339 SyncerError ExecuteDownloadUpdates( 334 SyncerError ExecuteDownloadUpdates(
340 ModelTypeSet request_types, 335 ModelTypeSet request_types,
341 SyncSession* session, 336 SyncSession* session,
342 sync_pb::ClientToServerMessage* msg) { 337 sync_pb::ClientToServerMessage* msg) {
343 sync_pb::ClientToServerResponse update_response; 338 sync_pb::ClientToServerResponse update_response;
344 StatusController* status = session->mutable_status_controller(); 339 StatusController* status = session->mutable_status_controller();
345 bool need_encryption_key = ShouldRequestEncryptionKey(session->context()); 340 bool need_encryption_key = ShouldRequestEncryptionKey(session->context());
346 341
342 if (session->context()->debug_info_getter()) {
343 sync_pb::DebugInfo* debug_info = msg->mutable_debug_info();
344 CopyClientDebugInfo(session->context()->debug_info_getter(), debug_info);
345 }
346
347 SyncerError result = SyncerProtoUtil::PostClientToServerMessage( 347 SyncerError result = SyncerProtoUtil::PostClientToServerMessage(
348 msg, 348 msg,
349 &update_response, 349 &update_response,
350 session); 350 session);
351 351
352 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( 352 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString(
353 update_response); 353 update_response);
354 354
355 if (result != SYNCER_OK) { 355 if (result != SYNCER_OK) {
356 status->mutable_updates_response()->Clear(); 356 status->mutable_updates_response()->Clear();
357 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; 357 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates";
358 return result; 358 return result;
359 } 359 }
360 360
361 status->mutable_updates_response()->CopyFrom(update_response); 361 status->mutable_updates_response()->CopyFrom(update_response);
362 362
363 DVLOG(1) << "GetUpdates " 363 DVLOG(1) << "GetUpdates "
364 << " returned " << update_response.get_updates().entries_size() 364 << " returned " << update_response.get_updates().entries_size()
365 << " updates and indicated " 365 << " updates and indicated "
366 << update_response.get_updates().changes_remaining() 366 << update_response.get_updates().changes_remaining()
367 << " updates left on server."; 367 << " updates left on server.";
368 368
369 if (session->context()->debug_info_getter()) {
370 // Clear debug info now that we have successfully sent it to the server.
371 DVLOG(1) << "Clearing client debug info.";
372 session->context()->debug_info_getter()->ClearDebugInfo();
373 }
374
369 if (need_encryption_key || 375 if (need_encryption_key ||
370 update_response.get_updates().encryption_keys_size() > 0) { 376 update_response.get_updates().encryption_keys_size() > 0) {
371 syncable::Directory* dir = session->context()->directory(); 377 syncable::Directory* dir = session->context()->directory();
372 status->set_last_get_key_result( 378 status->set_last_get_key_result(
373 HandleGetEncryptionKeyResponse(update_response, dir)); 379 HandleGetEncryptionKeyResponse(update_response, dir));
374 } 380 }
375 381
376 const sync_pb::GetUpdatesResponse& gu_response = 382 const sync_pb::GetUpdatesResponse& gu_response =
377 update_response.get_updates(); 383 update_response.get_updates();
378 status->increment_num_updates_downloaded_by(gu_response.entries_size()); 384 status->increment_num_updates_downloaded_by(gu_response.entries_size());
379 DCHECK(gu_response.has_changes_remaining()); 385 DCHECK(gu_response.has_changes_remaining());
380 status->set_num_server_changes_remaining(gu_response.changes_remaining()); 386 status->set_num_server_changes_remaining(gu_response.changes_remaining());
381 387
382 const ModelTypeSet proto_request_types = 388 const ModelTypeSet proto_request_types =
383 Intersection(request_types, ProtocolTypes()); 389 Intersection(request_types, ProtocolTypes());
384 390
385 if (!ProcessUpdateResponseMessage(gu_response, 391 if (!ProcessUpdateResponseMessage(gu_response,
386 proto_request_types, 392 proto_request_types,
387 session->context()->update_handler_map(), 393 session->context()->update_handler_map(),
388 status)) { 394 status)) {
389 return SERVER_RESPONSE_VALIDATION_FAILED; 395 return SERVER_RESPONSE_VALIDATION_FAILED;
390 } else { 396 } else {
391 return result; 397 return result;
392 } 398 }
393 } 399 }
394 400
395 void AppendClientDebugInfoIfNeeded( 401 void CopyClientDebugInfo(
396 sessions::DebugInfoGetter* debug_info_getter, 402 sessions::DebugInfoGetter* debug_info_getter,
397 StatusController* status,
398 sync_pb::DebugInfo* debug_info) { 403 sync_pb::DebugInfo* debug_info) {
399 // We want to send the debug info only once per sync cycle. Check if it has 404 // Could be null in some unit tests.
400 // already been sent. 405 if (debug_info_getter) {
Nicolas Zea 2013/11/19 23:43:04 nit: you're already checking debug_info_getter bef
maniscalco 2013/11/20 01:03:32 Done. Now relying on caller's check.
401 if (!status->debug_info_sent()) { 406 DVLOG(1) << "Copying client debug info to send.";
402 DVLOG(1) << "Sending client debug info ..."; 407 debug_info_getter->GetDebugInfo(debug_info);
403 // Could be null in some unit tests.
404 if (debug_info_getter) {
405 debug_info_getter->GetAndClearDebugInfo(debug_info);
406 }
407 status->set_debug_info_sent();
408 } 408 }
409 } 409 }
410 410
411 } // namespace download 411 } // namespace download
412 412
413 } // namespace syncer 413 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698