summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 15:08:12 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 15:08:12 +0000
commit8a26854e8842101aba84364ff2cb35ec80a51e73 (patch)
treed1bfc914a8d2ee8b87a11285ff200d738dc7ec98
parent63ef3238923a628e3eb191e9ff1cdc4b2ee072af (diff)
downloadchromium_src-8a26854e8842101aba84364ff2cb35ec80a51e73.zip
chromium_src-8a26854e8842101aba84364ff2cb35ec80a51e73.tar.gz
chromium_src-8a26854e8842101aba84364ff2cb35ec80a51e73.tar.bz2
sync: Update sync.proto to match the server's and handle new error codes.
BUG=b/17777403 TEST=none Review URL: http://codereview.chromium.org/4017004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63893 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/engine/syncer_proto_util.cc7
-rw-r--r--chrome/browser/sync/protocol/sync.proto43
-rw-r--r--chrome/test/sync/engine/mock_connection_manager.cc1
3 files changed, 36 insertions, 15 deletions
diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc
index ffc00d8..2603b0a 100644
--- a/chrome/browser/sync/engine/syncer_proto_util.cc
+++ b/chrome/browser/sync/engine/syncer_proto_util.cc
@@ -195,6 +195,10 @@ bool SyncerProtoUtil::PostClientToServerMessage(
}
switch (response->error_code()) {
+ case ClientToServerResponse::UNKNOWN:
+ LOG(WARNING) << "Sync protocol out-of-date. The server is using a more "
+ << "recent version.";
+ return false;
case ClientToServerResponse::SUCCESS:
LogResponseProfilingData(*response);
return true;
@@ -203,11 +207,14 @@ bool SyncerProtoUtil::PostClientToServerMessage(
session->delegate()->OnSilencedUntil(base::TimeTicks::Now() +
base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled));
return false;
+ case ClientToServerResponse::TRANSIENT_ERROR:
+ return false;
case ClientToServerResponse::USER_NOT_ACTIVATED:
case ClientToServerResponse::AUTH_INVALID:
case ClientToServerResponse::ACCESS_DENIED:
// WARNING: PostAndProcessHeaders contains a hack for this case.
LOG(WARNING) << "SyncerProtoUtil: Authentication expired.";
+ // TODO(sync): Was this meant to be a fall-through?
default:
NOTREACHED();
return false;
diff --git a/chrome/browser/sync/protocol/sync.proto b/chrome/browser/sync/protocol/sync.proto
index 40e9906..1ada951 100644
--- a/chrome/browser/sync/protocol/sync.proto
+++ b/chrome/browser/sync/protocol/sync.proto
@@ -363,7 +363,7 @@ message ClearUserDataResponse {
message ClientToServerMessage {
required string share = 1;
- optional int32 protocol_version = 2 [default = 24];
+ optional int32 protocol_version = 2 [default = 25];
enum Contents {
COMMIT = 1;
GET_UPDATES = 2;
@@ -512,21 +512,34 @@ message ClientToServerResponse {
enum ErrorType {
SUCCESS = 0;
- ACCESS_DENIED = 1; // Returned when the user doesn't have access to
- // store (instead of HTTP 401).
- NOT_MY_BIRTHDAY = 2; // Returned when the server and client disagree on
- // the store birthday.
- THROTTLED = 3; // Returned when the store has exceeded the allowed
- // bandwidth utilization.
- AUTH_EXPIRED = 4; // Auth token or cookie has expired.
- USER_NOT_ACTIVATED = 5; // User doesn't have the Chrome bit set on that
- // Google Account.
- AUTH_INVALID = 6; // Auth token or cookie is otherwise invalid.
- CLEAR_PENDING = 7; // A clear of the user data is pending (e.g.
- // initiated by privacy request). Client should
- // come back later.
+ ACCESS_DENIED = 1; // Returned when the user doesn't have access to
+ // store (instead of HTTP 401).
+ NOT_MY_BIRTHDAY = 2; // Returned when the server and client disagree on
+ // the store birthday.
+ THROTTLED = 3; // Returned when the store has exceeded the
+ // allowed bandwidth utilization.
+ AUTH_EXPIRED = 4; // Auth token or cookie has expired.
+ USER_NOT_ACTIVATED = 5; // User doesn't have the Chrome bit set on that
+ // Google Account.
+ AUTH_INVALID = 6; // Auth token or cookie is otherwise invalid.
+ CLEAR_PENDING = 7; // A clear of the user data is pending (e.g.
+ // initiated by privacy request). Client should
+ // come back later.
+ TRANSIENT_ERROR = 8; // A transient error occured (eg. backend
+ // timeout). Client should try again later.
+ UNKNOWN = 100; // Unknown value. This should never be explicitly
+ // used; it is the default value when an
+ // out-of-date client parses a value it doesn't
+ // recognize.
}
- optional ErrorType error_code = 4 [default = SUCCESS];
+ // Up until protocol_version 24, the default was SUCCESS which made it
+ // impossible to add new enum values since older clients would parse any
+ // out-of-range value as SUCCESS. Starting with 25, unless explicitly set,
+ // the error_code will be UNKNOWN so that clients know when they're
+ // out-of-date. Note also that when using protocol_version < 25,
+ // TRANSIENT_ERROR is not supported. Instead, the server sends back a HTTP
+ // 400 error code.
+ optional ErrorType error_code = 4 [default = UNKNOWN];
optional string error_message = 5;
// Opaque store ID; if it changes, the contents of the client's cache
diff --git a/chrome/test/sync/engine/mock_connection_manager.cc b/chrome/test/sync/engine/mock_connection_manager.cc
index b22a8e1..ade90a6 100644
--- a/chrome/test/sync/engine/mock_connection_manager.cc
+++ b/chrome/test/sync/engine/mock_connection_manager.cc
@@ -105,6 +105,7 @@ bool MockConnectionManager::PostBufferToPath(const PostBufferParams* params,
// Default to an ok connection.
params->response->server_status = HttpResponse::SERVER_CONNECTION_OK;
+ response.set_error_code(ClientToServerResponse::SUCCESS);
const string current_store_birthday = store_birthday();
response.set_store_birthday(current_store_birthday);
if (post.has_store_birthday() && post.store_birthday() !=