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/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 Loading... | |
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.Size() > 0) { |
Nicolas Zea
2011/12/08 01:49:37
!Empty()
akalin
2011/12/09 19:10:10
Done.
| |
198 context->SetUnthrottleTime(error.error_data_types, throttled_until); | 198 context->SetUnthrottleTime(error.error_data_types, throttled_until); |
199 } else { | 199 } else { |
200 // No datatypes indicates the client should be completely throttled. | 200 // No datatypes indicates the client should be completely throttled. |
201 delegate->OnSilencedUntil(throttled_until); | 201 delegate->OnSilencedUntil(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. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 |
OLD | NEW |