diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-16 02:49:56 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-16 02:49:56 +0000 |
commit | 43c5b440368df98a6b86addfec02b1a2be55b629 (patch) | |
tree | 4bcc7a487ae5b145d68828ab93b25f722545b4dc /sync/protocol | |
parent | bcd76261fdfb10b6d9cb813aa1c6140946ff79c7 (diff) | |
download | chromium_src-43c5b440368df98a6b86addfec02b1a2be55b629.zip chromium_src-43c5b440368df98a6b86addfec02b1a2be55b629.tar.gz chromium_src-43c5b440368df98a6b86addfec02b1a2be55b629.tar.bz2 |
Extend sync protocol to report hierarchy conflicts
This commit adds a new submessage to the protocol buffer that can be
used to report the client's status to the server. The first status
indicator to be implemented is 'hierarchy_conflict_detected', which is
an implicit call for help. In the future, the server should respond to
this flag by tring to resolve the hierarchy conflicts.
To help manually test the new field, this change also modified the proto
to DictionaryValue conversion functions to no longer print unset fields.
This is important because the client must leave the
'hierarchy_conflict_detected' field unset until it has tried to apply
updates at least once. This also had some implications for the unit
tests.
BUG=152464
Review URL: https://chromiumcodereview.appspot.com/11090052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/protocol')
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 15 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 4 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 17 |
3 files changed, 31 insertions, 5 deletions
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index e5528b92..79deafa 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -71,7 +71,10 @@ ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) { // Helper macros to reduce the amount of boilerplate. -#define SET(field, fn) value->Set(#field, fn(proto.field())) +#define SET(field, fn) \ + if (proto.has_##field()) { \ + value->Set(#field, fn(proto.field())); \ + } #define SET_REP(field, fn) \ value->Set(#field, MakeRepeatedValue(proto.field(), fn)) #define SET_ENUM(field, fn) \ @@ -166,7 +169,7 @@ DictionaryValue* TabNavigationToValue( SET_INT32(unique_id); SET_INT64(timestamp); SET_BOOL(navigation_forward_back); - SET_BOOL(navigation_from_address_bar), + SET_BOOL(navigation_from_address_bar); SET_BOOL(navigation_home_page); SET_BOOL(navigation_chain_start); SET_BOOL(navigation_chain_end); @@ -503,6 +506,13 @@ DictionaryValue* GetUpdatesMessageToValue( return value; } +DictionaryValue* ClientStatusToValue( + const sync_pb::ClientStatus& proto) { + DictionaryValue* value = new DictionaryValue(); + SET_BOOL(hierarchy_conflict_detected); + return value; +} + DictionaryValue* EntryResponseToValue( const sync_pb::CommitResponse::EntryResponse& proto) { DictionaryValue* value = new DictionaryValue(); @@ -589,6 +599,7 @@ DictionaryValue* ClientToServerMessageToValue( SET(get_updates, GetUpdatesMessageToValue); SET_STR(store_birthday); SET_BOOL(sync_problem_detected); + SET(client_status, ClientStatusToValue); return value; } diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index d927d2d..c98023c 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -40,9 +40,7 @@ class ProtoValueConversionsTest : public testing::Test { DictionaryValue* (*specifics_to_value)(const T&)) { const T& specifics(T::default_instance()); scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); - // We can't do much but make sure that the returned value has - // something in it. - EXPECT_FALSE(value->empty()); + // We can't do much but make sure that this doesn't crash. } }; diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index a0ee10b..ed4871b 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -469,6 +469,18 @@ message AuthenticateMessage { message ChipBag { }; +// Information about the syncer's state. +message ClientStatus { + // Flag to indicate if the client has detected hierarchy conflcits. The flag + // is left unset if update application has not been attempted yet. + // + // The server should attempt to resolve any hierarchy conflicts when this flag + // is set. The client may not assume that any particular action will be + // taken. There is no guarantee the problem will be addressed in a reasonable + // amount of time. + optional bool hierarchy_conflict_detected = 1; +} + message ClientToServerMessage { required string share = 1; optional int32 protocol_version = 2 [default = 31]; @@ -504,6 +516,11 @@ message ClientToServerMessage { // Google API key. optional string api_key = 12; + + // Client's self-reported state. + // The client should set this on every message sent to the server, though its + // member fields may often be unset. + optional ClientStatus client_status = 13; }; message CommitResponse { |