Commit 79bb11c5 authored by tim@chromium.org's avatar tim@chromium.org

sync: remove IncrementErrorCount from ServerConnectionManager.

It's not used for a real purpose anymore, and it was causing the SCM to have
multiple active_connection_ objects in certain cases, which is bad.

This is mostly covered by SyncAPIServerConnectionManagerTest

BUG=101639
TEST=On a debug build, no DCHECKs if the server is unreachable on sync startup.


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110443 0039d316-1c4b-4281-b951-d872f2087c98
parent 5b9652b3
......@@ -180,7 +180,6 @@ ServerConnectionManager::ServerConnectionManager(
use_ssl_(use_ssl),
proto_sync_path_(kSyncServerSyncPath),
get_time_path_(kSyncServerGetTimePath),
error_count_(0),
server_status_(HttpResponse::NONE),
server_reachable_(false),
terminated_(false),
......@@ -252,14 +251,11 @@ bool ServerConnectionManager::PostBufferToPath(PostBufferParams* params,
bool ok = post.get()->Init(
path.c_str(), auth_token, params->buffer_in, &params->response);
if (params->response.server_status == HttpResponse::SYNC_AUTH_ERROR) {
if (params->response.server_status == HttpResponse::SYNC_AUTH_ERROR)
InvalidateAndClearAuthToken();
}
if (!ok || RC_REQUEST_OK != params->response.response_code) {
IncrementErrorCount();
if (!ok || RC_REQUEST_OK != params->response.response_code)
return false;
}
if (post.get()->ReadBufferResponse(
&params->buffer_out, &params->response, true)) {
......@@ -311,7 +307,6 @@ bool ServerConnectionManager::CheckTime(int32* out_time) {
VLOG(1) << "Server was reachable.";
return true;
}
IncrementErrorCount();
return false;
}
......@@ -336,25 +331,6 @@ bool ServerConnectionManager::CheckServerReachable() {
return server_is_reachable;
}
bool ServerConnectionManager::IncrementErrorCount() {
DCHECK(thread_checker_.CalledOnValidThread());
error_count_++;
if (error_count_ > kMaxConnectionErrorsBeforeReset) {
error_count_ = 0;
if (!IsServerReachable()) {
LOG(WARNING) << "Too many connection failures, server is not reachable. "
<< "Resetting connections.";
} else {
LOG(WARNING) << "Multiple connection failures while server is reachable.";
}
return false;
}
return true;
}
void ServerConnectionManager::SetServerParameters(const string& server_url,
int port,
bool use_ssl) {
......
......@@ -31,10 +31,6 @@ namespace browser_sync {
class ClientToServerMessage;
// How many connection errors are accepted before network handles are closed
// and reopened.
static const int32 kMaxConnectionErrorsBeforeReset = 10;
static const int32 kUnsetResponseCode = -1;
static const int32 kUnsetContentLength = -1;
static const int32 kUnsetPayloadLength = -1;
......@@ -299,10 +295,6 @@ class ServerConnectionManager {
return get_time_path_;
}
// Called wherever a failure should be taken as an indication that we may
// be experiencing connection difficulties.
virtual bool IncrementErrorCount();
// NOTE: Tests rely on this protected function being virtual.
//
// Internal PostBuffer base function.
......@@ -345,8 +337,6 @@ class ServerConnectionManager {
// The previous auth token that is invalid now.
std::string previously_invalidated_token;
int error_count_; // Tracks the number of connection errors.
ObserverList<ServerConnectionEventListener> listeners_;
HttpResponse::ServerConnectionCode server_status_;
......
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