Commit 70c68bb7 authored by lipalani@chromium.org's avatar lipalani@chromium.org

Make the throttle delay configurable by the server.

BUG=
TEST=


Review URL: http://codereview.chromium.org/7605021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96312 0039d316-1c4b-4281-b951-d872f2087c98
parent bb0d7560
......@@ -11,6 +11,7 @@
#include "chrome/browser/sync/engine/syncer_types.h"
#include "chrome/browser/sync/engine/syncer_util.h"
#include "chrome/browser/sync/protocol/service_constants.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/sessions/sync_session.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
......@@ -182,6 +183,20 @@ bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm,
return false;
}
base::TimeDelta SyncerProtoUtil::GetThrottleDelay(
const sync_pb::ClientToServerResponse& response) {
base::TimeDelta throttle_delay =
base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled);
if (response.has_client_command()) {
const sync_pb::ClientCommand& command = response.client_command();
if (command.has_throttle_delay_seconds()) {
throttle_delay =
base::TimeDelta::FromSeconds(command.throttle_delay_seconds());
}
}
return throttle_delay;
}
namespace {
// Helper function for an assertion in PostClientToServerMessage.
......@@ -236,7 +251,7 @@ bool SyncerProtoUtil::PostClientToServerMessage(
case ClientToServerResponse::THROTTLED:
LOG(WARNING) << "Client silenced by server.";
session->delegate()->OnSilencedUntil(base::TimeTicks::Now() +
base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled));
GetThrottleDelay(*response));
return false;
case ClientToServerResponse::TRANSIENT_ERROR:
return false;
......
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -115,6 +115,9 @@ class SyncerProtoUtil {
const ClientToServerMessage& msg,
sync_pb::ClientToServerResponse* response);
static base::TimeDelta GetThrottleDelay(
const sync_pb::ClientToServerResponse& response);
friend class SyncerProtoUtilTest;
FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday);
FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders);
......
......@@ -586,6 +586,9 @@ message ClientCommand {
// action and sending a commit message to the
// server
optional int32 sessions_commit_delay_seconds = 4;
// Number of seconds to delay before the throttled client should retry.
optional int32 throttle_delay_seconds = 5;
};
message ClientToServerResponse {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment