| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/engine/download_updates_command.h" | 5 #include "chrome/browser/sync/engine/download_updates_command.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 "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 session->TestAndSetSource().updates_source); | 84 session->TestAndSetSource().updates_source); |
| 85 get_updates->mutable_caller_info()->set_notifications_enabled( | 85 get_updates->mutable_caller_info()->set_notifications_enabled( |
| 86 session->context()->notifications_enabled()); | 86 session->context()->notifications_enabled()); |
| 87 | 87 |
| 88 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); | 88 SyncerProtoUtil::AddRequestBirthday(dir, &client_to_server_message); |
| 89 | 89 |
| 90 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); | 90 DebugInfo* debug_info = client_to_server_message.mutable_debug_info(); |
| 91 | 91 |
| 92 AppendClientDebugInfoIfNeeded(session, debug_info); | 92 AppendClientDebugInfoIfNeeded(session, debug_info); |
| 93 | 93 |
| 94 bool ok = SyncerProtoUtil::PostClientToServerMessage( | 94 SyncerError result = SyncerProtoUtil::PostClientToServerMessage( |
| 95 client_to_server_message, | 95 client_to_server_message, |
| 96 &update_response, | 96 &update_response, |
| 97 session); | 97 session); |
| 98 | 98 |
| 99 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( | 99 DVLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( |
| 100 update_response); | 100 update_response); |
| 101 | 101 |
| 102 StatusController* status = session->mutable_status_controller(); | 102 StatusController* status = session->mutable_status_controller(); |
| 103 status->set_updates_request_types(enabled_types); | 103 status->set_updates_request_types(enabled_types); |
| 104 if (!ok) { | 104 if (result != SYNCER_OK) { |
| 105 status->increment_num_consecutive_errors(); | 105 status->increment_num_consecutive_errors(); |
| 106 status->mutable_updates_response()->Clear(); | 106 status->mutable_updates_response()->Clear(); |
| 107 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; | 107 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; |
| 108 return SYNCER_OK; // TODO(rlarocque): Return an error here. | 108 return result; |
| 109 } | 109 } |
| 110 | 110 |
| 111 status->mutable_updates_response()->CopyFrom(update_response); | 111 status->mutable_updates_response()->CopyFrom(update_response); |
| 112 | 112 |
| 113 DVLOG(1) << "GetUpdates " | 113 DVLOG(1) << "GetUpdates " |
| 114 << " returned " << update_response.get_updates().entries_size() | 114 << " returned " << update_response.get_updates().entries_size() |
| 115 << " updates and indicated " | 115 << " updates and indicated " |
| 116 << update_response.get_updates().changes_remaining() | 116 << update_response.get_updates().changes_remaining() |
| 117 << " updates left on server."; | 117 << " updates left on server."; |
| 118 return SYNCER_OK; | 118 return result; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( | 121 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( |
| 122 sessions::SyncSession* session, | 122 sessions::SyncSession* session, |
| 123 DebugInfo* debug_info) { | 123 DebugInfo* debug_info) { |
| 124 // We want to send the debug info only once per sync cycle. Check if it has | 124 // We want to send the debug info only once per sync cycle. Check if it has |
| 125 // already been sent. | 125 // already been sent. |
| 126 if (!session->status_controller().debug_info_sent()) { | 126 if (!session->status_controller().debug_info_sent()) { |
| 127 DVLOG(1) << "Sending client debug info ..."; | 127 DVLOG(1) << "Sending client debug info ..."; |
| 128 // could be null in some unit tests. | 128 // could be null in some unit tests. |
| 129 if (session->context()->debug_info_getter()) { | 129 if (session->context()->debug_info_getter()) { |
| 130 session->context()->debug_info_getter()->GetAndClearDebugInfo( | 130 session->context()->debug_info_getter()->GetAndClearDebugInfo( |
| 131 debug_info); | 131 debug_info); |
| 132 } | 132 } |
| 133 session->mutable_status_controller()->set_debug_info_sent(); | 133 session->mutable_status_controller()->set_debug_info_sent(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 | 137 |
| 138 } // namespace browser_sync | 138 } // namespace browser_sync |
| OLD | NEW |