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

Side by Side Diff: chrome/browser/sync/engine/syncer_proto_util.cc

Issue 8851006: [Sync] Replace all instances of ModelTypeSet with ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup pass #2 Created 9 years 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 | Annotate | Revision Log
OLDNEW
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/syncer_proto_util.h" 5 #include "chrome/browser/sync/engine/syncer_proto_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 9 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
10 #include "chrome/browser/sync/engine/syncer.h" 10 #include "chrome/browser/sync/engine/syncer.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 return throttle_delay; 188 return throttle_delay;
189 } 189 }
190 190
191 void SyncerProtoUtil::HandleThrottleError( 191 void SyncerProtoUtil::HandleThrottleError(
192 const SyncProtocolError& error, 192 const SyncProtocolError& error,
193 const base::TimeTicks& throttled_until, 193 const base::TimeTicks& throttled_until,
194 sessions::SyncSessionContext* context, 194 sessions::SyncSessionContext* context,
195 sessions::SyncSession::Delegate* delegate) { 195 sessions::SyncSession::Delegate* delegate) {
196 DCHECK_EQ(error.error_type, browser_sync::THROTTLED); 196 DCHECK_EQ(error.error_type, browser_sync::THROTTLED);
197 if (error.error_data_types.size() > 0) { 197 if (error.error_data_types.Empty()) {
198 context->SetUnthrottleTime(error.error_data_types, throttled_until);
199 } else {
200 // No datatypes indicates the client should be completely throttled. 198 // No datatypes indicates the client should be completely throttled.
201 delegate->OnSilencedUntil(throttled_until); 199 delegate->OnSilencedUntil(throttled_until);
200 } else {
201 context->SetUnthrottleTime(error.error_data_types, throttled_until);
202 } 202 }
203 } 203 }
204 204
205 namespace { 205 namespace {
206 206
207 // Helper function for an assertion in PostClientToServerMessage. 207 // Helper function for an assertion in PostClientToServerMessage.
208 bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) { 208 bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) {
209 if (!message.has_get_updates()) 209 if (!message.has_get_updates())
210 return false; 210 return false;
211 DCHECK_LT(0, message.get_updates().from_progress_marker_size()); 211 DCHECK_LT(0, message.get_updates().from_progress_marker_size());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 error.error_type()); 271 error.error_type());
272 sync_protocol_error.error_description = error.error_description(); 272 sync_protocol_error.error_description = error.error_description();
273 sync_protocol_error.url = error.url(); 273 sync_protocol_error.url = error.url();
274 sync_protocol_error.action = ConvertClientActionPBToLocalClientAction( 274 sync_protocol_error.action = ConvertClientActionPBToLocalClientAction(
275 error.action()); 275 error.action());
276 276
277 if (error.error_data_type_ids_size() > 0) { 277 if (error.error_data_type_ids_size() > 0) {
278 // THROTTLED is currently the only error code that uses |error_data_types|. 278 // THROTTLED is currently the only error code that uses |error_data_types|.
279 DCHECK_EQ(error.error_type(), ClientToServerResponse::THROTTLED); 279 DCHECK_EQ(error.error_type(), ClientToServerResponse::THROTTLED);
280 for (int i = 0; i < error.error_data_type_ids_size(); ++i) { 280 for (int i = 0; i < error.error_data_type_ids_size(); ++i) {
281 sync_protocol_error.error_data_types.insert( 281 sync_protocol_error.error_data_types.Put(
282 syncable::GetModelTypeFromExtensionFieldNumber( 282 syncable::GetModelTypeFromExtensionFieldNumber(
283 error.error_data_type_ids(i))); 283 error.error_data_type_ids(i)));
284 } 284 }
285 } 285 }
286 286
287 return sync_protocol_error; 287 return sync_protocol_error;
288 } 288 }
289 289
290 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. 290 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067.
291 browser_sync::SyncProtocolError ConvertLegacyErrorCodeToNewError( 291 browser_sync::SyncProtocolError ConvertLegacyErrorCodeToNewError(
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 499 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
500 const sync_pb::ClientToServerResponse& response) { 500 const sync_pb::ClientToServerResponse& response) {
501 // Add more handlers as needed. 501 // Add more handlers as needed.
502 std::string output; 502 std::string output;
503 if (response.has_get_updates()) 503 if (response.has_get_updates())
504 output.append(GetUpdatesResponseString(response.get_updates())); 504 output.append(GetUpdatesResponseString(response.get_updates()));
505 return output; 505 return output;
506 } 506 }
507 507
508 } // namespace browser_sync 508 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/nigori_util_unittest.cc ('k') | chrome/browser/sync/engine/syncer_proto_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698