OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 AppendClientDebugInfoIfNeeded(session, debug_info); | 90 AppendClientDebugInfoIfNeeded(session, debug_info); |
91 | 91 |
92 bool ok = SyncerProtoUtil::PostClientToServerMessage( | 92 bool ok = SyncerProtoUtil::PostClientToServerMessage( |
93 client_to_server_message, | 93 client_to_server_message, |
94 &update_response, | 94 &update_response, |
95 session); | 95 session); |
96 | 96 |
97 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( | 97 VLOG(2) << SyncerProtoUtil::ClientToServerResponseDebugString( |
98 update_response); | 98 update_response); |
99 | 99 |
100 StatusController* status = session->status_controller(); | 100 StatusController* status = session->mutable_status_controller(); |
101 status->set_updates_request_types(enabled_types); | 101 status->set_updates_request_types(enabled_types); |
102 if (!ok) { | 102 if (!ok) { |
103 status->increment_num_consecutive_errors(); | 103 status->increment_num_consecutive_errors(); |
104 status->mutable_updates_response()->Clear(); | 104 status->mutable_updates_response()->Clear(); |
105 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; | 105 LOG(ERROR) << "PostClientToServerMessage() failed during GetUpdates"; |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 status->mutable_updates_response()->CopyFrom(update_response); | 109 status->mutable_updates_response()->CopyFrom(update_response); |
110 | 110 |
111 VLOG(1) << "GetUpdates " | 111 VLOG(1) << "GetUpdates " |
112 << " returned " << update_response.get_updates().entries_size() | 112 << " returned " << update_response.get_updates().entries_size() |
113 << " updates and indicated " | 113 << " updates and indicated " |
114 << update_response.get_updates().changes_remaining() | 114 << update_response.get_updates().changes_remaining() |
115 << " updates left on server."; | 115 << " updates left on server."; |
116 } | 116 } |
117 | 117 |
118 void DownloadUpdatesCommand::SetRequestedTypes( | |
119 const syncable::ModelTypeBitSet& target_datatypes, | |
120 sync_pb::EntitySpecifics* filter_protobuf) { | |
121 // The datatypes which should be synced are dictated by the value of the | |
122 // ModelSafeRoutingInfo. If a datatype is in the routing info map, it | |
123 // should be synced (even if it's GROUP_PASSIVE). | |
124 int requested_type_count = 0; | |
125 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | |
126 if (target_datatypes[i]) { | |
127 requested_type_count++; | |
128 syncable::AddDefaultExtensionValue(syncable::ModelTypeFromInt(i), | |
129 filter_protobuf); | |
130 } | |
131 } | |
132 DCHECK_LT(0, requested_type_count) << "Doing GetUpdates with empty filter."; | |
133 } | |
134 | |
135 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( | 118 void DownloadUpdatesCommand::AppendClientDebugInfoIfNeeded( |
136 sessions::SyncSession* session, | 119 sessions::SyncSession* session, |
137 DebugInfo* debug_info) { | 120 DebugInfo* debug_info) { |
138 // We want to send the debug info only once per sync cycle. Check if it has | 121 // We want to send the debug info only once per sync cycle. Check if it has |
139 // already been sent. | 122 // already been sent. |
140 if (!session->status_controller()->debug_info_sent()) { | 123 if (!session->status_controller().debug_info_sent()) { |
141 VLOG(1) << "Sending client debug info ..."; | 124 VLOG(1) << "Sending client debug info ..."; |
142 // could be null in some unit tests. | 125 // could be null in some unit tests. |
143 if (session->context()->debug_info_getter()) { | 126 if (session->context()->debug_info_getter()) { |
144 session->context()->debug_info_getter()->GetAndClearDebugInfo( | 127 session->context()->debug_info_getter()->GetAndClearDebugInfo( |
145 debug_info); | 128 debug_info); |
146 } | 129 } |
147 session->status_controller()->set_debug_info_sent(); | 130 session->mutable_status_controller()->set_debug_info_sent(); |
148 } | 131 } |
149 } | 132 } |
150 | 133 |
151 | 134 |
152 } // namespace browser_sync | 135 } // namespace browser_sync |
OLD | NEW |