diff options
author | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-04 16:15:46 +0000 |
---|---|---|
committer | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-04 16:15:46 +0000 |
commit | c0df3036624b650979221359ee74dc3bba46b838 (patch) | |
tree | 492ddc2e6241fd28439c97329d2afc25fd58e295 /chrome/browser/sync | |
parent | f18c31ca4e30f85f90174d407e22c6c84229fce3 (diff) | |
download | chromium_src-c0df3036624b650979221359ee74dc3bba46b838.zip chromium_src-c0df3036624b650979221359ee74dc3bba46b838.tar.gz chromium_src-c0df3036624b650979221359ee74dc3bba46b838.tar.bz2 |
sync: Merge the server-side protocol changes.
R=ncarter
BUG=b/3051801
TEST=it builds
Review URL: http://codereview.chromium.org/8966034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
18 files changed, 249 insertions, 194 deletions
diff --git a/chrome/browser/sync/engine/clear_data_command.cc b/chrome/browser/sync/engine/clear_data_command.cc index ebb95d8..932c624 100644 --- a/chrome/browser/sync/engine/clear_data_command.cc +++ b/chrome/browser/sync/engine/clear_data_command.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -57,8 +57,7 @@ void ClearDataCommand::ExecuteImpl(SyncSession* session) { // Clear pending indicates that the server has received our clear message if (!ok || !client_to_server_response.has_error_code() || - client_to_server_response.error_code() != - sync_pb::ClientToServerResponse::SUCCESS) { + client_to_server_response.error_code() != sync_pb::SyncEnums::SUCCESS) { // On failure, subsequent requests to the server will cause it to attempt // to resume the clear. The client will handle disabling of sync in // response to a store birthday error from the server. @@ -79,4 +78,3 @@ void ClearDataCommand::ExecuteImpl(SyncSession* session) { } } // namespace browser_sync - diff --git a/chrome/browser/sync/engine/clear_data_command_unittest.cc b/chrome/browser/sync/engine/clear_data_command_unittest.cc index f4739a2..473b4d8 100644 --- a/chrome/browser/sync/engine/clear_data_command_unittest.cc +++ b/chrome/browser/sync/engine/clear_data_command_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -106,8 +106,7 @@ TEST_F(ClearDataCommandTest, ClearDataCommandExpectSuccess) { TestScopedSessionEventListener reg(context(), handler.get()); dir->set_store_birthday(mock_server()->store_birthday()); - mock_server()->SetClearUserDataResponseStatus( - sync_pb::ClientToServerResponse::SUCCESS); + mock_server()->SetClearUserDataResponseStatus(sync_pb::SyncEnums::SUCCESS); on_should_stop_syncing_permanently_called_ = false; command_.Execute(session()); @@ -124,4 +123,3 @@ TEST_F(ClearDataCommandTest, ClearDataCommandExpectSuccess) { } } // namespace browser_sync - diff --git a/chrome/browser/sync/engine/process_commit_response_command_unittest.cc b/chrome/browser/sync/engine/process_commit_response_command_unittest.cc index b22963c..b58a6ff 100644 --- a/chrome/browser/sync/engine/process_commit_response_command_unittest.cc +++ b/chrome/browser/sync/engine/process_commit_response_command_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -164,7 +164,7 @@ class ProcessCommitResponseCommandTestWithParam sync_pb::ClientToServerResponse* response = sync_state->mutable_commit_response(); - response->set_error_code(sync_pb::ClientToServerResponse::SUCCESS); + response->set_error_code(sync_pb::SyncEnums::SUCCESS); sync_pb::CommitResponse_EntryResponse* entry_response = response->mutable_commit()->add_entryresponse(); entry_response->set_response_type(CommitResponse::SUCCESS); diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc index b70f0cc..f516926 100644 --- a/chrome/browser/sync/engine/syncer_proto_util.cc +++ b/chrome/browser/sync/engine/syncer_proto_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,6 +11,7 @@ #include "chrome/browser/sync/engine/syncer_types.h" #include "chrome/browser/sync/protocol/service_constants.h" #include "chrome/browser/sync/protocol/sync.pb.h" +#include "chrome/browser/sync/protocol/sync_enums.pb.h" #include "chrome/browser/sync/protocol/sync_protocol_error.h" #include "chrome/browser/sync/sessions/sync_session.h" #include "chrome/browser/sync/syncable/directory_manager.h" @@ -160,9 +161,9 @@ bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm, if (response->ParseFromString(params.buffer_out)) { // TODO(tim): This is an egregious layering violation (bug 35060). switch (response->error_code()) { - case ClientToServerResponse::ACCESS_DENIED: - case ClientToServerResponse::AUTH_INVALID: - case ClientToServerResponse::USER_NOT_ACTIVATED: + case sync_pb::SyncEnums::ACCESS_DENIED: + case sync_pb::SyncEnums::AUTH_INVALID: + case sync_pb::SyncEnums::USER_NOT_ACTIVATED: // Fires on ScopedServerStatusWatcher params.response.server_status = HttpResponse::SYNC_AUTH_ERROR; return false; @@ -217,25 +218,25 @@ bool IsVeryFirstGetUpdates(const ClientToServerMessage& message) { } SyncProtocolErrorType ConvertSyncProtocolErrorTypePBToLocalType( - const sync_pb::ClientToServerResponse::ErrorType& error_type) { + const sync_pb::SyncEnums::ErrorType& error_type) { switch (error_type) { - case ClientToServerResponse::SUCCESS: + case sync_pb::SyncEnums::SUCCESS: return browser_sync::SYNC_SUCCESS; - case ClientToServerResponse::NOT_MY_BIRTHDAY: + case sync_pb::SyncEnums::NOT_MY_BIRTHDAY: return browser_sync::NOT_MY_BIRTHDAY; - case ClientToServerResponse::THROTTLED: + case sync_pb::SyncEnums::THROTTLED: return browser_sync::THROTTLED; - case ClientToServerResponse::CLEAR_PENDING: + case sync_pb::SyncEnums::CLEAR_PENDING: return browser_sync::CLEAR_PENDING; - case ClientToServerResponse::TRANSIENT_ERROR: + case sync_pb::SyncEnums::TRANSIENT_ERROR: return browser_sync::TRANSIENT_ERROR; - case ClientToServerResponse::MIGRATION_DONE: + case sync_pb::SyncEnums::MIGRATION_DONE: return browser_sync::MIGRATION_DONE; - case ClientToServerResponse::UNKNOWN: + case sync_pb::SyncEnums::UNKNOWN: return browser_sync::UNKNOWN_ERROR; - case ClientToServerResponse::USER_NOT_ACTIVATED: - case ClientToServerResponse::AUTH_INVALID: - case ClientToServerResponse::ACCESS_DENIED: + case sync_pb::SyncEnums::USER_NOT_ACTIVATED: + case sync_pb::SyncEnums::AUTH_INVALID: + case sync_pb::SyncEnums::ACCESS_DENIED: return browser_sync::INVALID_CREDENTIAL; default: NOTREACHED(); @@ -276,7 +277,7 @@ browser_sync::SyncProtocolError ConvertErrorPBToLocalType( if (error.error_data_type_ids_size() > 0) { // THROTTLED is currently the only error code that uses |error_data_types|. - DCHECK_EQ(error.error_type(), ClientToServerResponse::THROTTLED); + DCHECK_EQ(error.error_type(), sync_pb::SyncEnums::THROTTLED); for (int i = 0; i < error.error_data_type_ids_size(); ++i) { sync_protocol_error.error_data_types.Put( syncable::GetModelTypeFromExtensionFieldNumber( @@ -289,11 +290,11 @@ browser_sync::SyncProtocolError ConvertErrorPBToLocalType( // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. browser_sync::SyncProtocolError ConvertLegacyErrorCodeToNewError( - const sync_pb::ClientToServerResponse::ErrorType& error_type) { + const sync_pb::SyncEnums::ErrorType& error_type) { browser_sync::SyncProtocolError error; error.error_type = ConvertSyncProtocolErrorTypePBToLocalType(error_type); - if (error_type == ClientToServerResponse::CLEAR_PENDING || - error_type == ClientToServerResponse::NOT_MY_BIRTHDAY) { + if (error_type == sync_pb::SyncEnums::CLEAR_PENDING || + error_type == sync_pb::SyncEnums::NOT_MY_BIRTHDAY) { error.action = browser_sync::DISABLE_SYNC_ON_CLIENT; } // There is no other action we can compute for legacy server. return error; diff --git a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc index f5cee2c..9373c0f 100644 --- a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc +++ b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -16,6 +16,7 @@ #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" #include "chrome/browser/sync/protocol/password_specifics.pb.h" #include "chrome/browser/sync/protocol/sync.pb.h" +#include "chrome/browser/sync/protocol/sync_enums.pb.h" #include "chrome/browser/sync/syncable/blob.h" #include "chrome/browser/sync/syncable/directory_manager.h" #include "chrome/browser/sync/syncable/model_type_test_util.h" @@ -196,7 +197,7 @@ TEST_F(SyncerProtoUtilTest, VerifyResponseBirthday) { response.set_store_birthday("meat"); EXPECT_FALSE(SyncerProtoUtil::VerifyResponseBirthday(lookup, &response)); - response.set_error_code(ClientToServerResponse::CLEAR_PENDING); + response.set_error_code(sync_pb::SyncEnums::CLEAR_PENDING); EXPECT_FALSE(SyncerProtoUtil::VerifyResponseBirthday(lookup, &response)); } @@ -231,7 +232,7 @@ class DummyConnectionManager : public browser_sync::ServerConnectionManager { ClientToServerResponse response; if (access_denied_) { - response.set_error_code(ClientToServerResponse::ACCESS_DENIED); + response.set_error_code(sync_pb::SyncEnums::ACCESS_DENIED); } response.SerializeToString(¶ms->buffer_out); diff --git a/chrome/browser/sync/protocol/app_notification_specifics.proto b/chrome/browser/sync/protocol/app_notification_specifics.proto index b2cdf71..46d0426 100644 --- a/chrome/browser/sync/protocol/app_notification_specifics.proto +++ b/chrome/browser/sync/protocol/app_notification_specifics.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -16,12 +16,16 @@ package sync_pb; import "sync.proto"; -// Properties of ann app notification. +// Properties of an app notification. // An App Notification, to be delivered from Chrome Apps to the // Chrome browser through the Notification API. -message AppNotificationSpecifics { - // Globally unique id. +message AppNotification { + // Globally unique id. This is more robust for uniquely identifying each + // notification and hence gives us flexibility in the future. In absence + // of this, unique id would be (app_id, creation_timestamp_ms). But that + // relies on creation_timestamp_ms being high resolution and is not + // globally unique - only unique for a given user. optional string guid = 1; // Metadata, not shown directly to the user. // The unique App Id, as created by the webstore and used to @@ -41,5 +45,5 @@ message AppNotificationSpecifics { } extend EntitySpecifics { - optional AppNotificationSpecifics app_notification = 45184; + optional AppNotification app_notification = 45184; } diff --git a/chrome/browser/sync/protocol/client_commands.proto b/chrome/browser/sync/protocol/client_commands.proto new file mode 100644 index 0000000..e574255 --- /dev/null +++ b/chrome/browser/sync/protocol/client_commands.proto @@ -0,0 +1,31 @@ +// Copyright (c) 2012 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. +// +// Sync protocol for communication between sync client and server. + +// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +message ClientCommand { + // Time to wait before sending any requests to the server. + optional int32 set_sync_poll_interval = 1; // in seconds + optional int32 set_sync_long_poll_interval = 2; // in seconds + + optional int32 max_commit_batch_size = 3; + + // Number of seconds to delay between a sessions + // 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; +}; diff --git a/chrome/browser/sync/protocol/nigori_specifics.proto b/chrome/browser/sync/protocol/nigori_specifics.proto index 9a5f9147..b154e12 100644 --- a/chrome/browser/sync/protocol/nigori_specifics.proto +++ b/chrome/browser/sync/protocol/nigori_specifics.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -84,4 +84,3 @@ message NigoriSpecifics { extend EntitySpecifics { optional NigoriSpecifics nigori = 47745; } - diff --git a/chrome/browser/sync/protocol/proto_value_conversions.cc b/chrome/browser/sync/protocol/proto_value_conversions.cc index c66c586..58b4c1d 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions.cc +++ b/chrome/browser/sync/protocol/proto_value_conversions.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -185,8 +185,8 @@ DictionaryValue* DeviceInformationToValue( return value; } -DictionaryValue* AppNotificationSpecificsToValue( - const sync_pb::AppNotificationSpecifics& proto) { +DictionaryValue* AppNotificationToValue( + const sync_pb::AppNotification& proto) { DictionaryValue* value = new DictionaryValue(); SET_STR(guid); SET_STR(app_id); @@ -374,7 +374,7 @@ DictionaryValue* EntitySpecificsToValue( const sync_pb::EntitySpecifics& specifics) { DictionaryValue* value = new DictionaryValue(); SET_EXTENSION(sync_pb, app, AppSpecificsToValue); - SET_EXTENSION(sync_pb, app_notification, AppNotificationSpecificsToValue); + SET_EXTENSION(sync_pb, app_notification, AppNotificationToValue); SET_EXTENSION(sync_pb, app_setting, AppSettingSpecificsToValue); SET_EXTENSION(sync_pb, autofill, AutofillSpecificsToValue); SET_EXTENSION(sync_pb, autofill_profile, AutofillProfileSpecificsToValue); diff --git a/chrome/browser/sync/protocol/proto_value_conversions.h b/chrome/browser/sync/protocol/proto_value_conversions.h index a23e8fa..f15b06f 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions.h +++ b/chrome/browser/sync/protocol/proto_value_conversions.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,8 +13,8 @@ class DictionaryValue; } namespace sync_pb { +class AppNotification; class AppNotificationSettings; -class AppNotificationSpecifics; class AppSettingSpecifics; class AppSpecifics; class AutofillProfileSpecifics; @@ -87,8 +87,8 @@ base::DictionaryValue* DeviceInformationToValue( // Main *SpecificsToValue functions. -base::DictionaryValue* AppNotificationSpecificsToValue( - const sync_pb::AppNotificationSpecifics& app_notification_specifics); +base::DictionaryValue* AppNotificationToValue( + const sync_pb::AppNotification& app_notification_specifics); base::DictionaryValue* AppSettingSpecificsToValue( const sync_pb::AppSettingSpecifics& app_setting_specifics); diff --git a/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc b/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc index 2e9db42..de61897 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc +++ b/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -86,8 +86,8 @@ TEST_F(ProtoValueConversionsTest, PasswordSpecificsData) { EXPECT_EQ("<redacted>", password_value); } -TEST_F(ProtoValueConversionsTest, AppNotificationSpecificsToValue) { - TestSpecificsToValue(AppNotificationSpecificsToValue); +TEST_F(ProtoValueConversionsTest, AppNotificationToValue) { + TestSpecificsToValue(AppNotificationToValue); } TEST_F(ProtoValueConversionsTest, AppSettingSpecificsToValue) { diff --git a/chrome/browser/sync/protocol/search_engine_specifics.proto b/chrome/browser/sync/protocol/search_engine_specifics.proto index 92f8f76..b593b1c 100644 --- a/chrome/browser/sync/protocol/search_engine_specifics.proto +++ b/chrome/browser/sync/protocol/search_engine_specifics.proto @@ -1,66 +1,66 @@ -// 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.
-//
-// Sync protocol datatype extension for custom search engines.
-
-// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change
-// any fields in this file.
-
-syntax = "proto2";
-
-option optimize_for = LITE_RUNTIME;
-option retain_unknown_fields = true;
-
-package sync_pb;
-
-import "sync.proto";
-
-// Properties of custom search engine sync objects.
-message SearchEngineSpecifics {
- // The description of the search engine.
- optional string short_name = 1;
- // The search engine keyword for omnibox access.
- optional string keyword = 2;
- // A URL to the favicon to show in the search engines options page.
- optional string favicon_url = 3;
- // The actual parameterized search engine query URL.
- optional string url = 4;
- // A flag signifying whether it is safe to automatically modify this search
- // engine entry or not.
- optional bool safe_for_autoreplace = 5;
- // The URL to the OSD file this search engine entry came from.
- optional string originating_url = 6;
- // The date this search engine entry was created. A UTC timestamp with units
- // in microseconds.
- optional int64 date_created = 7;
- // A list of supported input encodings.
- optional string input_encodings = 8;
- // Whether this entry is shown in the list of default search engines or not.
- optional bool show_in_default_list = 9;
- // The parameterized URL that provides suggestions as the user types.
- optional string suggestions_url = 10;
- // The ID associated with the prepopulate data this search engine comes from.
- // Set to zero if it was not prepopulated.
- optional int32 prepopulate_id = 11;
- // Whether to autogenerate a keyword for the search engine or not.
- optional bool autogenerate_keyword = 12;
- // ID 13 reserved - previously used by |logo_id|, now deprecated.
- // Obsolete field. This used to represent whether or not this search engine
- // entry was created automatically by an administrator via group policy. This
- // notion no longer exists amongst synced search engines as we do not want to
- // sync managed search engines.
- // optional bool deprecated_created_by_policy = 14;
- // The parameterized URL that is used for Instant results.
- optional string instant_url = 15;
- // ID 16 reserved - previously used by |id|, now deprecated.
- // The last time this entry was modified by a user. A UTC timestamp with units
- // in microseconds.
- optional int64 last_modified = 17;
- // The primary identifier of this search engine entry for Sync.
- optional string sync_guid = 18;
-}
-
-extend EntitySpecifics {
- optional SearchEngineSpecifics search_engine = 88610;
-}
+// Copyright (c) 2012 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. +// +// Sync protocol datatype extension for custom search engines. + +// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +import "sync.proto"; + +// Properties of custom search engine sync objects. +message SearchEngineSpecifics { + // The description of the search engine. + optional string short_name = 1; + // The search engine keyword for omnibox access. + optional string keyword = 2; + // A URL to the favicon to show in the search engines options page. + optional string favicon_url = 3; + // The actual parameterized search engine query URL. + optional string url = 4; + // A flag signifying whether it is safe to automatically modify this search + // engine entry or not. + optional bool safe_for_autoreplace = 5; + // The URL to the OSD file this search engine entry came from. + optional string originating_url = 6; + // The date this search engine entry was created. A UTC timestamp with units + // in microseconds. + optional int64 date_created = 7; + // A list of supported input encodings. + optional string input_encodings = 8; + // Whether this entry is shown in the list of default search engines or not. + optional bool show_in_default_list = 9; + // The parameterized URL that provides suggestions as the user types. + optional string suggestions_url = 10; + // The ID associated with the prepopulate data this search engine comes from. + // Set to zero if it was not prepopulated. + optional int32 prepopulate_id = 11; + // Whether to autogenerate a keyword for the search engine or not. + optional bool autogenerate_keyword = 12; + // ID 13 reserved - previously used by |logo_id|, now deprecated. + // Obsolete field. This used to represent whether or not this search engine + // entry was created automatically by an administrator via group policy. This + // notion no longer exists amongst synced search engines as we do not want to + // sync managed search engines. + // optional bool deprecated_created_by_policy = 14; + // The parameterized URL that is used for Instant results. + optional string instant_url = 15; + // ID 16 reserved - previously used by |id|, now deprecated. + // The last time this entry was modified by a user. A UTC timestamp with units + // in microseconds. + optional int64 last_modified = 17; + // The primary identifier of this search engine entry for Sync. + optional string sync_guid = 18; +} + +extend EntitySpecifics { + optional SearchEngineSpecifics search_engine = 88610; +} diff --git a/chrome/browser/sync/protocol/sync.proto b/chrome/browser/sync/protocol/sync.proto index 9f46bcd..1c497ef 100644 --- a/chrome/browser/sync/protocol/sync.proto +++ b/chrome/browser/sync/protocol/sync.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -15,6 +15,8 @@ option retain_unknown_fields = true; package sync_pb; import "encryption.proto"; +import "sync_enums.proto"; +import "client_commands.proto"; import "client_debug_info.proto"; // Used for inspecting how long we spent performing operations in different @@ -180,7 +182,6 @@ message SyncEntity { // makes. optional int64 position_in_parent = 15; - // Contains the ID of the element (under the same parent) after which this // element resides. An empty string indicates that the element is the first // element in the parent. This value is used during commits to specify @@ -485,6 +486,9 @@ message CommitResponse { optional string error_message = 9; + // Last modification time (in java time milliseconds). Allows the server + // to override the client-supplied mtime during a commit operation. + optional int64 mtime = 10; } }; @@ -579,24 +583,6 @@ message ThrottleParameters { required double observation_window = 5; }; -// A command from the server instructing the client to update settings or -// perform some operation. -message ClientCommand { - // Time to wait before sending any requests to the server. - optional int32 set_sync_poll_interval = 1; // in seconds - optional int32 set_sync_long_poll_interval = 2; // in seconds - - optional int32 max_commit_batch_size = 3; - - // Number of seconds to delay between a sessions - // 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 { optional CommitResponse commit = 1; optional GetUpdatesResponse get_updates = 2; @@ -607,38 +593,10 @@ message ClientToServerResponse { // none of the other fields (error_code and etc) will be set. optional GetUpdatesStreamingResponse stream_data = 11; - 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. - TRANSIENT_ERROR = 8; // A transient error occured (eg. backend - // timeout). Client should try again later. - MIGRATION_DONE = 9; // Migration has finished for one or more data - // types. Client should clear the cache for - // these data types only and then re-sync with - // a server. The migrated datatypes are in the - // |migrated_datatype_ids| field. - 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. - } - message Error { - optional ErrorType error_type = 1 [default = UNKNOWN]; - optional string error_description = 2; - optional string url = 3; + optional SyncEnums.ErrorType error_type = 1 [default = UNKNOWN]; + optional string error_description = 2; + optional string url = 3; enum Action { UPGRADE_CLIENT = 0; // Upgrade the client to latest version. CLEAR_USER_DATA_AND_RESYNC = 1; // Clear user data from dashboard and @@ -666,7 +624,7 @@ message ClientToServerResponse { // 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. This is deprecated now. - optional ErrorType error_code = 4 [default = UNKNOWN]; + optional SyncEnums.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/browser/sync/protocol/sync_enums.proto b/chrome/browser/sync/protocol/sync_enums.proto new file mode 100644 index 0000000..d28023b --- /dev/null +++ b/chrome/browser/sync/protocol/sync_enums.proto @@ -0,0 +1,64 @@ +// Copyright (c) 2012 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. +// +// Sync protocol for communication between sync client and server. + +// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +message SyncEnums { + // These events are sent by |SyncManager| class. Note: In the code they each + // of these events have some additional info but we are not sending them to + // server. + enum EventType { + AUTH_ERROR = 1; // Auth error. Note this gets generated even during + // successful auth with the error set to none. + UPDATED_TOKEN = 2; // Client received an updated token. + PASSPHRASE_REQUIRED = 3; // Cryptographer needs passphrase. + PASSPHRASE_ACCEPTED = 4; // Passphrase was accepted by cryptographer. + INITIALIZATION_COMPLETE = 5; // Sync Initialization is complete. + + // |STOP_SYNCING_PERMANENTLY| event should never be seen by the server in + // the absence of bugs. + STOP_SYNCING_PERMANENTLY = 6; // Server sent stop syncing permanently. + + ENCRYPTED_TYPES_CHANGED = 9; // Set of encrypted types has changed. + ENCRYPTION_COMPLETE = 7; // Client has finished encrypting all data. + ACTIONABLE_ERROR = 8; // Client received an actionable error. + } + + 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. + TRANSIENT_ERROR = 8; // A transient error occured (eg. backend + // timeout). Client should try again later. + MIGRATION_DONE = 9; // Migration has finished for one or more data + // types. Client should clear the cache for + // these data types only and then re-sync with + // a server. + 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. + } +} diff --git a/chrome/browser/sync/protocol/sync_proto.gyp b/chrome/browser/sync/protocol/sync_proto.gyp index dcf302f..40b6ff1 100644 --- a/chrome/browser/sync/protocol/sync_proto.gyp +++ b/chrome/browser/sync/protocol/sync_proto.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 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. @@ -11,14 +11,14 @@ 'target_name': 'sync_proto', 'type': 'static_library', 'sources': [ - 'sync.proto', - 'encryption.proto', 'app_notification_specifics.proto', 'app_setting_specifics.proto', 'app_specifics.proto', 'autofill_specifics.proto', 'bookmark_specifics.proto', + 'client_commands.proto', 'client_debug_info.proto', + 'encryption.proto', 'extension_setting_specifics.proto', 'extension_specifics.proto', 'nigori_specifics.proto', @@ -26,6 +26,8 @@ 'preference_specifics.proto', 'search_engine_specifics.proto', 'session_specifics.proto', + 'sync.proto', + 'sync_enums.proto', 'test.proto', 'theme_specifics.proto', 'typed_url_specifics.proto', diff --git a/chrome/browser/sync/test/engine/mock_connection_manager.cc b/chrome/browser/sync/test/engine/mock_connection_manager.cc index 05a345fa..488f8373 100644 --- a/chrome/browser/sync/test/engine/mock_connection_manager.cc +++ b/chrome/browser/sync/test/engine/mock_connection_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -29,6 +29,7 @@ using sync_pb::CommitMessage; using sync_pb::CommitResponse; using sync_pb::CommitResponse_EntryResponse; using sync_pb::GetUpdatesMessage; +using sync_pb::SyncEnums; using sync_pb::SyncEntity; using syncable::DirectoryManager; using syncable::FIRST_REAL_MODEL_TYPE; @@ -114,12 +115,12 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, // Default to an ok connection. params->response.server_status = HttpResponse::SERVER_CONNECTION_OK; - response.set_error_code(ClientToServerResponse::SUCCESS); + response.set_error_code(SyncEnums::SUCCESS); const string current_store_birthday = store_birthday(); response.set_store_birthday(current_store_birthday); if (post.has_store_birthday() && post.store_birthday() != current_store_birthday) { - response.set_error_code(ClientToServerResponse::NOT_MY_BIRTHDAY); + response.set_error_code(SyncEnums::NOT_MY_BIRTHDAY); response.set_error_message("Merry Unbirthday!"); response.SerializeToString(¶ms->buffer_out); store_birthday_sent_ = true; @@ -149,12 +150,12 @@ bool MockConnectionManager::PostBufferToPath(PostBufferParams* params, { base::AutoLock lock(response_code_override_lock_); if (throttling_) { - response.set_error_code(ClientToServerResponse::THROTTLED); + response.set_error_code(SyncEnums::THROTTLED); throttling_ = false; } if (fail_with_auth_invalid_) - response.set_error_code(ClientToServerResponse::AUTH_INVALID); + response.set_error_code(SyncEnums::AUTH_INVALID); } response.SerializeToString(¶ms->buffer_out); @@ -451,7 +452,7 @@ void MockConnectionManager::ProcessGetUpdates(ClientToServerMessage* csm, } void MockConnectionManager::SetClearUserDataResponseStatus( - sync_pb::ClientToServerResponse::ErrorType errortype ) { + sync_pb::SyncEnums::ErrorType errortype ) { // Note: this is not a thread-safe set, ok for now. NOT ok if tests // run the syncer on the background thread while this method is called. clear_user_data_response_errortype_ = errortype; @@ -473,11 +474,11 @@ void MockConnectionManager::ProcessAuthenticate( EXPECT_FALSE(auth_token.empty()); if (auth_token != valid_auth_token_) { - response->set_error_code(ClientToServerResponse::AUTH_INVALID); + response->set_error_code(SyncEnums::AUTH_INVALID); return; } - response->set_error_code(ClientToServerResponse::SUCCESS); + response->set_error_code(SyncEnums::SUCCESS); response->mutable_authenticate()->CopyFrom(auth_response_); auth_response_.Clear(); } diff --git a/chrome/browser/sync/test/engine/mock_connection_manager.h b/chrome/browser/sync/test/engine/mock_connection_manager.h index 4ea6c3e..ad2ea0c 100644 --- a/chrome/browser/sync/test/engine/mock_connection_manager.h +++ b/chrome/browser/sync/test/engine/mock_connection_manager.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -134,8 +134,7 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { void FailNextPostBufferToPathCall() { fail_next_postbuffer_ = true; } - void SetClearUserDataResponseStatus( - sync_pb::ClientToServerResponse::ErrorType errortype); + void SetClearUserDataResponseStatus(sync_pb::SyncEnums::ErrorType errortype); // A visitor class to allow a test to change some monitoring state atomically // with the action of overriding the response codes sent back to the Syncer @@ -322,8 +321,7 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { MidCommitObserver* mid_commit_observer_; // The clear data response we'll return in the next response - sync_pb::ClientToServerResponse::ErrorType - clear_user_data_response_errortype_; + sync_pb::SyncEnums::ErrorType clear_user_data_response_errortype_; // The AUTHENTICATE response we'll return for auth requests. sync_pb::AuthenticateResponse auth_response_; diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index e290836..f2c0349 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -629,27 +629,27 @@ void SyncTest::TriggerAuthError() { namespace { -sync_pb::ClientToServerResponse::ErrorType +sync_pb::SyncEnums::ErrorType GetClientToServerResponseErrorType( browser_sync::SyncProtocolErrorType error) { switch (error) { case browser_sync::SYNC_SUCCESS: - return sync_pb::ClientToServerResponse::SUCCESS; + return sync_pb::SyncEnums::SUCCESS; case browser_sync::NOT_MY_BIRTHDAY: - return sync_pb::ClientToServerResponse::NOT_MY_BIRTHDAY; + return sync_pb::SyncEnums::NOT_MY_BIRTHDAY; case browser_sync::THROTTLED: - return sync_pb::ClientToServerResponse::THROTTLED; + return sync_pb::SyncEnums::THROTTLED; case browser_sync::CLEAR_PENDING: - return sync_pb::ClientToServerResponse::CLEAR_PENDING; + return sync_pb::SyncEnums::CLEAR_PENDING; case browser_sync::TRANSIENT_ERROR: - return sync_pb::ClientToServerResponse::TRANSIENT_ERROR; + return sync_pb::SyncEnums::TRANSIENT_ERROR; case browser_sync::MIGRATION_DONE: - return sync_pb::ClientToServerResponse::MIGRATION_DONE; + return sync_pb::SyncEnums::MIGRATION_DONE; case browser_sync::UNKNOWN_ERROR: - return sync_pb::ClientToServerResponse::UNKNOWN; + return sync_pb::SyncEnums::UNKNOWN; default: NOTREACHED(); - return sync_pb::ClientToServerResponse::UNKNOWN; + return sync_pb::SyncEnums::UNKNOWN; } } |