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

Unified Diff: chrome/browser/sync/engine/syncer_proto_util.cc

Issue 8595023: [Sync] Parse and save per-data type throttle data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload for committing. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..a1caafa15c706e872f4639ed493859af04de2d38 100644
--- a/chrome/browser/sync/engine/syncer_proto_util.cc
+++ b/chrome/browser/sync/engine/syncer_proto_util.cc
@@ -187,6 +187,20 @@ base::TimeDelta SyncerProtoUtil::GetThrottleDelay(
return throttle_delay;
}
+void SyncerProtoUtil::HandleThrottleError(
+ 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->SetUnthrottleTime(error.error_data_types, throttled_until);
+ } else {
+ // No datatypes indicates the client should be completely throttled.
+ delegate->OnSilencedUntil(throttled_until);
+ }
+}
+
namespace {
// Helper function for an assertion in PostClientToServerMessage.
@@ -258,6 +272,17 @@ 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) {
+ // THROTTLED is currently the only error code that uses |error_data_types|.
+ DCHECK_EQ(error.error_type(), ClientToServerResponse::THROTTLED);
+ 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 +356,10 @@ bool SyncerProtoUtil::PostClientToServerMessage(
return true;
case browser_sync::THROTTLED:
LOG(WARNING) << "Client silenced by server.";
- session->delegate()->OnSilencedUntil(base::TimeTicks::Now() +
- GetThrottleDelay(*response));
+ HandleThrottleError(sync_protocol_error,
+ base::TimeTicks::Now() + GetThrottleDelay(*response),
+ session->context(),
+ session->delegate());
return false;
case browser_sync::TRANSIENT_ERROR:
return false;
« no previous file with comments | « chrome/browser/sync/engine/syncer_proto_util.h ('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