summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclamy@chromium.org <clamy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 11:38:31 +0000
committerclamy@chromium.org <clamy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 11:38:31 +0000
commitf8f05be2bc70a238e66b143de9597b356e69f914 (patch)
tree737db30396eb4950241a524de44dd365ff43a8b2
parente327c75806edcd5587abec67b99089a66aac8427 (diff)
downloadchromium_src-f8f05be2bc70a238e66b143de9597b356e69f914.zip
chromium_src-f8f05be2bc70a238e66b143de9597b356e69f914.tar.gz
chromium_src-f8f05be2bc70a238e66b143de9597b356e69f914.tar.bz2
Added a funtion to translate net errors in a ServerConnectionCode in sync.
Presently, only the ERR_ABORTED is being translated into a CONNECTION_UNAVAILABLE error. However, on certain Android devices, the error received when having no connectivity is ERR_NAME_NOT_RESOLVED. It is classified as an IO_ERROR. The rest of sync treats CONNECTION_UNAVAILABLE and IO_ERRORS differently, with having to wait 1s before retry in one case and 750 in the other case. This can cause sync startup to fail and not retry for more than 10mn, even when the network is back. This fix allows a better translation of net errors into ServerConnectionCodes, which allows for sync to start when the network is back in a more reliable way. BUG=169790 Review URL: https://chromiumcodereview.appspot.com/11953072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179593 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--sync/engine/net/server_connection_manager.cc18
-rw-r--r--sync/engine/net/server_connection_manager.h3
-rw-r--r--sync/internal_api/syncapi_server_connection_manager.cc7
3 files changed, 24 insertions, 4 deletions
diff --git a/sync/engine/net/server_connection_manager.cc b/sync/engine/net/server_connection_manager.cc
index 2e1f1f8..228dbb9 100644
--- a/sync/engine/net/server_connection_manager.cc
+++ b/sync/engine/net/server_connection_manager.cc
@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "build/build_config.h"
#include "googleurl/src/gurl.h"
+#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "sync/engine/net/url_translator.h"
#include "sync/engine/syncer.h"
@@ -57,6 +58,23 @@ const char* HttpResponse::GetServerConnectionCodeString(
#undef ENUM_CASE
+// TODO(clamy): check if all errors are in the right category.
+HttpResponse::ServerConnectionCode
+HttpResponse::ServerConnectionCodeFromNetError(int error_code) {
+ switch (error_code) {
+ case net::ERR_ABORTED:
+ case net::ERR_SOCKET_NOT_CONNECTED:
+ case net::ERR_NETWORK_CHANGED:
+ case net::ERR_CONNECTION_FAILED:
+ case net::ERR_NAME_NOT_RESOLVED:
+ case net::ERR_INTERNET_DISCONNECTED:
+ case net::ERR_NETWORK_ACCESS_DENIED:
+ case net::ERR_NETWORK_IO_SUSPENDED:
+ return CONNECTION_UNAVAILABLE;
+ }
+ return IO_ERROR;
+}
+
ServerConnectionManager::Connection::Connection(
ServerConnectionManager* scm) : scm_(scm) {
}
diff --git a/sync/engine/net/server_connection_manager.h b/sync/engine/net/server_connection_manager.h
index 05619dd..a074d47 100644
--- a/sync/engine/net/server_connection_manager.h
+++ b/sync/engine/net/server_connection_manager.h
@@ -88,6 +88,9 @@ struct SYNC_EXPORT_PRIVATE HttpResponse {
static const char* GetServerConnectionCodeString(
ServerConnectionCode code);
+
+ static ServerConnectionCode ServerConnectionCodeFromNetError(
+ int error_code);
};
struct ServerConnectionEvent {
diff --git a/sync/internal_api/syncapi_server_connection_manager.cc b/sync/internal_api/syncapi_server_connection_manager.cc
index 91900b2..6b99ed1 100644
--- a/sync/internal_api/syncapi_server_connection_manager.cc
+++ b/sync/internal_api/syncapi_server_connection_manager.cc
@@ -51,10 +51,9 @@ bool SyncAPIBridgedConnection::Init(const char* path,
int error_code = 0;
int response_code = 0;
if (!http->MakeSynchronousPost(&error_code, &response_code)) {
- response->server_status = error_code == net::ERR_ABORTED ?
- HttpResponse::CONNECTION_UNAVAILABLE : HttpResponse::IO_ERROR;
- LOG_IF(WARNING, error_code != net::ERR_ABORTED)
- << "Net error during post: " << error_code;
+ DVLOG(1) << "Http POST failed, error returns: " << error_code;
+ response->server_status = HttpResponse::ServerConnectionCodeFromNetError(
+ error_code);
return false;
}