Chromium Code Reviews| Index: chrome/browser/sync/engine/syncer_proto_util.cc |
| diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc |
| index 84abca64ffba9062664e5ee4d9e1e17648c3ac8d..63a7fbc09c12f5c54c21790844ac95fb7cd6c726 100644 |
| --- a/chrome/browser/sync/engine/syncer_proto_util.cc |
| +++ b/chrome/browser/sync/engine/syncer_proto_util.cc |
| @@ -187,6 +187,19 @@ base::TimeDelta SyncerProtoUtil::GetThrottleDelay( |
| return throttle_delay; |
| } |
| +void SyncerProtoUtil::HandleThrottling( |
| + const SyncProtocolError& error, |
| + const base::TimeTicks& throttled_until, |
| + sessions::SyncSessionContext* context, |
| + sessions::SyncSession::Delegate* delegate) { |
| + DCHECK_EQ(error.error_type, browser_sync::THROTTLED); |
| + if (error.error_data_types.size() > 0) { |
| + context->AddUnthrottleTime(error.error_data_types, throttled_until); |
| + } else { |
| + delegate->OnSilencedUntil(throttled_until); |
|
akalin
2011/11/21 22:36:04
add comment saying that no data types means we're
lipalani1
2011/11/22 00:47:36
Done.
|
| + } |
| +} |
| + |
| namespace { |
| // Helper function for an assertion in PostClientToServerMessage. |
| @@ -258,6 +271,16 @@ browser_sync::SyncProtocolError ConvertErrorPBToLocalType( |
| sync_protocol_error.url = error.url(); |
| sync_protocol_error.action = ConvertClientActionPBToLocalClientAction( |
| error.action()); |
| + |
| + if (error.error_data_type_ids_size() > 0) { |
| + DCHECK(error.error_type() == ClientToServerResponse::THROTTLED); |
|
akalin
2011/11/21 22:36:04
DCHECK_EQ
Also add comment saying that THROTTLED
lipalani1
2011/11/22 00:47:36
Done.
|
| + for (int i = 0; i < error.error_data_type_ids_size(); ++i) { |
| + sync_protocol_error.error_data_types.insert( |
| + syncable::GetModelTypeFromExtensionFieldNumber( |
| + error.error_data_type_ids(i))); |
| + } |
| + } |
| + |
| return sync_protocol_error; |
| } |
| @@ -331,8 +354,10 @@ bool SyncerProtoUtil::PostClientToServerMessage( |
| return true; |
| case browser_sync::THROTTLED: |
| LOG(WARNING) << "Client silenced by server."; |
| - session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + |
| - GetThrottleDelay(*response)); |
| + HandleThrottling(sync_protocol_error, |
| + base::TimeTicks::Now() + GetThrottleDelay(*response), |
| + session->context(), |
| + session->delegate()); |
| return false; |
| case browser_sync::TRANSIENT_ERROR: |
| return false; |