diff options
Diffstat (limited to 'chrome/browser')
67 files changed, 437 insertions, 572 deletions
diff --git a/chrome/browser/extensions/app_notification_manager.cc b/chrome/browser/extensions/app_notification_manager.cc index 269107b..f1272fa 100644 --- a/chrome/browser/extensions/app_notification_manager.cc +++ b/chrome/browser/extensions/app_notification_manager.cc @@ -14,6 +14,7 @@ #include "base/time.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "content/public/browser/notification_service.h" @@ -56,8 +57,7 @@ void PopulateGuidToSyncDataMap(const SyncDataList& sync_data, SyncDataMap* data_map) { for (SyncDataList::const_iterator iter = sync_data.begin(); iter != sync_data.end(); ++iter) { - (*data_map)[iter->GetSpecifics().GetExtension( - sync_pb::app_notification).guid()] = *iter; + (*data_map)[iter->GetSpecifics().app_notification().guid()] = *iter; } } } // namespace @@ -515,7 +515,7 @@ SyncData AppNotificationManager::CreateSyncDataFromNotification( DCHECK(!notification.is_local()); sync_pb::EntitySpecifics specifics; sync_pb::AppNotification* notif_specifics = - specifics.MutableExtension(sync_pb::app_notification); + specifics.mutable_app_notification(); notif_specifics->set_app_id(notification.extension_id()); notif_specifics->set_creation_timestamp_ms( notification.creation_time().ToInternalValue()); @@ -532,7 +532,7 @@ SyncData AppNotificationManager::CreateSyncDataFromNotification( AppNotification* AppNotificationManager::CreateNotificationFromSyncData( const SyncData& sync_data) { sync_pb::AppNotification specifics = - sync_data.GetSpecifics().GetExtension(sync_pb::app_notification); + sync_data.GetSpecifics().app_notification(); // Check for mandatory fields. if (!specifics.has_app_id() || !specifics.has_guid() || diff --git a/chrome/browser/extensions/app_notification_manager_sync_unittest.cc b/chrome/browser/extensions/app_notification_manager_sync_unittest.cc index 8777048..ffdedf6 100644 --- a/chrome/browser/extensions/app_notification_manager_sync_unittest.cc +++ b/chrome/browser/extensions/app_notification_manager_sync_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. @@ -9,6 +9,7 @@ #include "chrome/browser/extensions/app_notification.h" #include "chrome/browser/extensions/app_notification_manager.h" #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/test/base/testing_profile.h" #include "content/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -19,8 +20,7 @@ namespace { // Extract notification guid from SyncData. std::string GetGuid(const SyncData& sync_data) { - return sync_data.GetSpecifics().GetExtension( - sync_pb::app_notification).guid(); + return sync_data.GetSpecifics().app_notification().guid(); } // Dummy SyncChangeProcessor used to help review what SyncChanges are pushed diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index 0880121..7622d45 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -51,6 +51,7 @@ #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/sync/protocol/app_specifics.pb.h" #include "chrome/browser/sync/protocol/extension_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -4202,8 +4203,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataUninstall) { &processor); sync_pb::EntitySpecifics specifics; - sync_pb::ExtensionSpecifics* ext_specifics = - specifics.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); ext_specifics->set_id(good_crx); ext_specifics->set_version("1.0"); SyncData sync_data = SyncData::CreateLocalData(good_crx, "Name", specifics); @@ -4238,8 +4238,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataWrongType) { EXPECT_TRUE(service_->GetExtensionById(good_crx, true)); sync_pb::EntitySpecifics specifics; - sync_pb::AppSpecifics* app_specifics = - specifics.MutableExtension(sync_pb::app); + sync_pb::AppSpecifics* app_specifics = specifics.mutable_app(); sync_pb::ExtensionSpecifics* extension_specifics = app_specifics->mutable_extension(); extension_specifics->set_id(good_crx); @@ -4283,8 +4282,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataSettings) { EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); sync_pb::EntitySpecifics specifics; - sync_pb::ExtensionSpecifics* ext_specifics = - specifics.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); ext_specifics->set_id(good_crx); ext_specifics->set_version( service_->GetInstalledExtension(good_crx)->version()->GetString()); @@ -4339,8 +4337,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataTerminatedExtension) { EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); sync_pb::EntitySpecifics specifics; - sync_pb::ExtensionSpecifics* ext_specifics = - specifics.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); ext_specifics->set_id(good_crx); ext_specifics->set_version( service_->GetInstalledExtension(good_crx)->version()->GetString()); @@ -4370,8 +4367,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataVersionCheck) { EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); sync_pb::EntitySpecifics specifics; - sync_pb::ExtensionSpecifics* ext_specifics = - specifics.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); ext_specifics->set_id(good_crx); ext_specifics->set_enabled(true); @@ -4424,8 +4420,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataNotInstalled) { &processor); sync_pb::EntitySpecifics specifics; - sync_pb::ExtensionSpecifics* ext_specifics = - specifics.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension(); ext_specifics->set_id(good_crx); ext_specifics->set_enabled(false); ext_specifics->set_incognito_enabled(true); diff --git a/chrome/browser/extensions/extension_sync_data.cc b/chrome/browser/extensions/extension_sync_data.cc index f3bb6c8..e656eff 100644 --- a/chrome/browser/extensions/extension_sync_data.cc +++ b/chrome/browser/extensions/extension_sync_data.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. @@ -8,6 +8,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/sync/protocol/app_specifics.pb.h" #include "chrome/browser/sync/protocol/extension_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" ExtensionSyncData::ExtensionSyncData() : uninstalled_(false), @@ -92,11 +93,10 @@ SyncData ExtensionSyncData::GetSyncData() const { switch (type_) { case Extension::SYNC_TYPE_EXTENSION: - PopulateExtensionSpecifics(specifics.MutableExtension( - sync_pb::extension)); + PopulateExtensionSpecifics(specifics.mutable_extension()); break; case Extension::SYNC_TYPE_APP: - PopulateAppSpecifics(specifics.MutableExtension(sync_pb::app)); + PopulateAppSpecifics(specifics.mutable_app()); break; default: LOG(FATAL) << "Attempt to get non-syncable data."; @@ -156,13 +156,11 @@ void ExtensionSyncData::PopulateFromExtensionSpecifics( void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) { const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); - if (entity_specifics.HasExtension(sync_pb::extension)) { - PopulateFromExtensionSpecifics( - entity_specifics.GetExtension(sync_pb::extension)); + if (entity_specifics.has_extension()) { + PopulateFromExtensionSpecifics(entity_specifics.extension()); type_ = Extension::SYNC_TYPE_EXTENSION; - } else if (entity_specifics.HasExtension(sync_pb::app)) { - PopulateFromAppSpecifics( - entity_specifics.GetExtension(sync_pb::app)); + } else if (entity_specifics.has_app()) { + PopulateFromAppSpecifics(entity_specifics.app()); type_ = Extension::SYNC_TYPE_APP; } else { LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; diff --git a/chrome/browser/extensions/extension_sync_data_unittest.cc b/chrome/browser/extensions/extension_sync_data_unittest.cc index 90afc1e..4be1055 100644 --- a/chrome/browser/extensions/extension_sync_data_unittest.cc +++ b/chrome/browser/extensions/extension_sync_data_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. @@ -8,6 +8,7 @@ #include "base/version.h" #include "chrome/browser/sync/protocol/app_specifics.pb.h" #include "chrome/browser/sync/protocol/extension_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -37,8 +38,7 @@ class ExtensionSyncDataTest : public testing::Test { TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForExtension) { sync_pb::EntitySpecifics entity; - sync_pb::ExtensionSpecifics* extension_specifics = - entity.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* extension_specifics = entity.mutable_extension(); extension_specifics->set_id(kValidId); extension_specifics->set_update_url(kValidUpdateUrl2); extension_specifics->set_enabled(false); @@ -63,8 +63,7 @@ TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForExtension) { TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForExtension) { sync_pb::EntitySpecifics entity; - sync_pb::ExtensionSpecifics* input_extension = - entity.MutableExtension(sync_pb::extension); + sync_pb::ExtensionSpecifics* input_extension = entity.mutable_extension(); input_extension->set_id(kValidId); input_extension->set_update_url(kValidUpdateUrl2); input_extension->set_enabled(true); @@ -77,7 +76,7 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForExtension) { SyncData output_sync_data = extension_sync_data.GetSyncData(); const sync_pb::ExtensionSpecifics& output_specifics = - output_sync_data.GetSpecifics().GetExtension(sync_pb::extension); + output_sync_data.GetSpecifics().extension(); EXPECT_EQ(extension_sync_data.id(), output_specifics.id()); EXPECT_EQ(extension_sync_data.update_url().spec(), output_specifics.update_url()); @@ -91,7 +90,7 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForExtension) { TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForApp) { sync_pb::EntitySpecifics entity; - sync_pb::AppSpecifics* app_specifics = entity.MutableExtension(sync_pb::app); + sync_pb::AppSpecifics* app_specifics = entity.mutable_app(); app_specifics->set_app_launch_ordinal( StringOrdinal::CreateInitialOrdinal().ToString()); app_specifics->set_page_ordinal( @@ -135,8 +134,7 @@ TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForApp) { TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForApp) { sync_pb::EntitySpecifics entity; - sync_pb::AppSpecifics* input_specifics = entity.MutableExtension( - sync_pb::app); + sync_pb::AppSpecifics* input_specifics = entity.mutable_app(); input_specifics->set_app_launch_ordinal( StringOrdinal::CreateInitialOrdinal().ToString()); input_specifics->set_page_ordinal( @@ -159,9 +157,9 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForApp) { ExtensionSyncData extension_sync_data(sync_data); SyncData output_sync_data = extension_sync_data.GetSyncData(); - EXPECT_TRUE(sync_data.GetSpecifics().HasExtension(sync_pb::app)); + EXPECT_TRUE(sync_data.GetSpecifics().has_app()); const sync_pb::AppSpecifics& output_specifics = - output_sync_data.GetSpecifics().GetExtension(sync_pb::app); + output_sync_data.GetSpecifics().app(); EXPECT_EQ(input_specifics->SerializeAsString(), output_specifics.SerializeAsString()); } @@ -169,7 +167,7 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForApp) { // Ensures that invalid StringOrdinals don't break ExtensionSyncData. TEST_F(ExtensionSyncDataTest, ExtensionSyncDataInvalidOrdinal) { sync_pb::EntitySpecifics entity; - sync_pb::AppSpecifics* app_specifics = entity.MutableExtension(sync_pb::app); + sync_pb::AppSpecifics* app_specifics = entity.mutable_app(); // Set the ordinals as invalid. app_specifics->set_app_launch_ordinal(""); app_specifics->set_page_ordinal(""); diff --git a/chrome/browser/extensions/settings/setting_sync_data.cc b/chrome/browser/extensions/settings/setting_sync_data.cc index f537969..fa71ff8 100644 --- a/chrome/browser/extensions/settings/setting_sync_data.cc +++ b/chrome/browser/extensions/settings/setting_sync_data.cc @@ -28,16 +28,16 @@ void SettingSyncData::Init( DCHECK(!internal_.get()); sync_pb::EntitySpecifics specifics = sync_data.GetSpecifics(); // The data must only be either extension or app specfics. - DCHECK_NE(specifics.HasExtension(sync_pb::extension_setting), - specifics.HasExtension(sync_pb::app_setting)); - if (specifics.HasExtension(sync_pb::extension_setting)) { + DCHECK_NE(specifics.has_extension_setting(), + specifics.has_app_setting()); + if (specifics.has_extension_setting()) { InitFromExtensionSettingSpecifics( change_type, - specifics.GetExtension(sync_pb::extension_setting)); - } else if (specifics.HasExtension(sync_pb::app_setting)) { + specifics.extension_setting()); + } else if (specifics.has_app_setting()) { InitFromExtensionSettingSpecifics( change_type, - specifics.GetExtension(sync_pb::app_setting).extension_setting()); + specifics.app_setting().extension_setting()); } } diff --git a/chrome/browser/extensions/settings/settings_sync_util.cc b/chrome/browser/extensions/settings/settings_sync_util.cc index 68a69cc..5fcc9a6 100644 --- a/chrome/browser/extensions/settings/settings_sync_util.cc +++ b/chrome/browser/extensions/settings/settings_sync_util.cc @@ -8,6 +8,7 @@ #include "base/json/json_writer.h" #include "chrome/browser/sync/protocol/app_setting_specifics.pb.h" #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" namespace extensions { @@ -46,14 +47,13 @@ SyncData CreateData( const Value& value, syncable::ModelType type) { sync_pb::EntitySpecifics specifics; - switch (type) { case syncable::EXTENSION_SETTINGS: PopulateExtensionSettingSpecifics( extension_id, key, value, - specifics.MutableExtension(sync_pb::extension_setting)); + specifics.mutable_extension_setting()); break; case syncable::APP_SETTINGS: @@ -61,7 +61,7 @@ SyncData CreateData( extension_id, key, value, - specifics.MutableExtension(sync_pb::app_setting)); + specifics.mutable_app_setting()); break; default: diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc index 0f48fd0..dd28d81 100644 --- a/chrome/browser/prefs/pref_model_associator.cc +++ b/chrome/browser/prefs/pref_model_associator.cc @@ -13,6 +13,7 @@ #include "base/values.h" #include "chrome/browser/sync/api/sync_change.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" @@ -46,7 +47,7 @@ void PrefModelAssociator::InitPrefAndAssociate( // The server has a value for the preference, we have to reconcile it with // ours. const sync_pb::PreferenceSpecifics& preference = - sync_pref.GetSpecifics().GetExtension(sync_pb::preference); + sync_pref.GetSpecifics().preference(); DCHECK_EQ(pref->name(), preference.name()); scoped_ptr<Value> value( @@ -124,8 +125,7 @@ SyncError PrefModelAssociator::MergeDataAndStartSyncing( sync_iter != initial_sync_data.end(); ++sync_iter) { DCHECK_EQ(PREFERENCES, sync_iter->GetDataType()); - std::string sync_pref_name = sync_iter->GetSpecifics(). - GetExtension(sync_pb::preference).name(); + std::string sync_pref_name = sync_iter->GetSpecifics().preference().name(); if (remaining_preferences.count(sync_pref_name) == 0) { // We're not syncing this preference locally, ignore the sync data. // TODO(zea): Eventually we want to be able to have the syncable service @@ -198,8 +198,7 @@ bool PrefModelAssociator::CreatePrefSyncData( } sync_pb::EntitySpecifics specifics; - sync_pb::PreferenceSpecifics* pref_specifics = specifics.MutableExtension( - sync_pb::preference); + sync_pb::PreferenceSpecifics* pref_specifics = specifics.mutable_preference(); pref_specifics->set_name(name); pref_specifics->set_value(serialized); *sync_data = SyncData::CreateLocalData(name, name, specifics); @@ -306,7 +305,7 @@ SyncError PrefModelAssociator::ProcessSyncChanges( std::string name; sync_pb::PreferenceSpecifics pref_specifics = - iter->sync_data().GetSpecifics().GetExtension(sync_pb::preference); + iter->sync_data().GetSpecifics().preference(); scoped_ptr<Value> value(ReadPreferenceSpecifics(pref_specifics, &name)); diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc index b93f4dd..80e6ba8 100644 --- a/chrome/browser/search_engines/template_url_service.cc +++ b/chrome/browser/search_engines/template_url_service.cc @@ -34,6 +34,7 @@ #include "chrome/browser/search_engines/util.h" #include "chrome/browser/sync/api/sync_change.h" #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" @@ -965,8 +966,8 @@ void TemplateURLService::ProcessTemplateURLChange( SyncData TemplateURLService::CreateSyncDataFromTemplateURL( const TemplateURL& turl) { sync_pb::EntitySpecifics specifics; - sync_pb::SearchEngineSpecifics* se_specifics = specifics.MutableExtension( - sync_pb::search_engine); + sync_pb::SearchEngineSpecifics* se_specifics = + specifics.mutable_search_engine(); se_specifics->set_short_name(UTF16ToUTF8(turl.short_name())); se_specifics->set_keyword(UTF16ToUTF8(turl.keyword())); se_specifics->set_favicon_url(turl.GetFaviconURL().spec()); @@ -1003,8 +1004,7 @@ SyncDataMap TemplateURLService::CreateGUIDToSyncDataMap( SyncDataMap data_map; SyncDataList::const_iterator iter; for (iter = sync_data.begin(); iter != sync_data.end(); ++iter) { - data_map[iter->GetSpecifics().GetExtension( - sync_pb::search_engine).sync_guid()] = *iter; + data_map[iter->GetSpecifics().search_engine().sync_guid()] = *iter; } return data_map; } @@ -1889,7 +1889,7 @@ void TemplateURLService::UpdateTemplateURLWithSyncData( TemplateURL* dst, const SyncData& sync_data) { sync_pb::SearchEngineSpecifics specifics = - sync_data.GetSpecifics().GetExtension(sync_pb::search_engine); + sync_data.GetSpecifics().search_engine(); dst->set_short_name(UTF8ToUTF16(specifics.short_name())); dst->set_keyword(UTF8ToUTF16(specifics.keyword())); dst->SetFaviconURL(GURL(specifics.favicon_url())); diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc index c784175..b425a27 100644 --- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc +++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc @@ -10,6 +10,7 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_pref_service.h" @@ -23,20 +24,17 @@ namespace { // Extract the GUID from a search engine SyncData. std::string GetGUID(const SyncData& sync_data) { - return sync_data.GetSpecifics().GetExtension( - sync_pb::search_engine).sync_guid(); + return sync_data.GetSpecifics().search_engine().sync_guid(); } // Extract the URL from a search engine SyncData. std::string GetURL(const SyncData& sync_data) { - return sync_data.GetSpecifics().GetExtension( - sync_pb::search_engine).url(); + return sync_data.GetSpecifics().search_engine().url(); } // Extract the keyword from a search engine SyncData. std::string GetKeyword(const SyncData& sync_data) { - return sync_data.GetSpecifics().GetExtension( - sync_pb::search_engine).keyword(); + return sync_data.GetSpecifics().search_engine().keyword(); } // TODO(stevet): Share these with template_url_service_unittest. diff --git a/chrome/browser/sync/abstract_profile_sync_service_test.cc b/chrome/browser/sync/abstract_profile_sync_service_test.cc index 9f5dc7c..02b2a05 100644 --- a/chrome/browser/sync/abstract_profile_sync_service_test.cc +++ b/chrome/browser/sync/abstract_profile_sync_service_test.cc @@ -61,7 +61,7 @@ bool ProfileSyncServiceTestHelper::CreateRoot(ModelType model_type, node.Put(IS_DEL, false); node.Put(syncable::ID, ids->MakeServer(tag_name)); sync_pb::EntitySpecifics specifics; - syncable::AddDefaultExtensionValue(model_type, &specifics); + syncable::AddDefaultFieldValue(model_type, &specifics); node.Put(SPECIFICS, specifics); return true; diff --git a/chrome/browser/sync/api/sync_change_unittest.cc b/chrome/browser/sync/api/sync_change_unittest.cc index 494db9e..26308d4 100644 --- a/chrome/browser/sync/api/sync_change_unittest.cc +++ b/chrome/browser/sync/api/sync_change_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. @@ -9,6 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/sync/protocol/proto_value_conversions.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,8 +35,7 @@ TEST_F(SyncChangeTest, LocalDelete) { TEST_F(SyncChangeTest, LocalUpdate) { SyncChange::SyncChangeType change_type = SyncChange::ACTION_UPDATE; sync_pb::EntitySpecifics specifics; - sync_pb::PreferenceSpecifics* pref_specifics = - specifics.MutableExtension(sync_pb::preference); + sync_pb::PreferenceSpecifics* pref_specifics = specifics.mutable_preference(); pref_specifics->set_name("test"); std::string tag = "client_tag"; std::string title = "client_title"; @@ -54,8 +54,7 @@ TEST_F(SyncChangeTest, LocalUpdate) { TEST_F(SyncChangeTest, LocalAdd) { SyncChange::SyncChangeType change_type = SyncChange::ACTION_ADD; sync_pb::EntitySpecifics specifics; - sync_pb::PreferenceSpecifics* pref_specifics = - specifics.MutableExtension(sync_pb::preference); + sync_pb::PreferenceSpecifics* pref_specifics = specifics.mutable_preference(); pref_specifics->set_name("test"); std::string tag = "client_tag"; std::string title = "client_title"; @@ -77,7 +76,7 @@ TEST_F(SyncChangeTest, SyncerChanges) { // Create an update. sync_pb::EntitySpecifics update_specifics; sync_pb::PreferenceSpecifics* pref_specifics = - update_specifics.MutableExtension(sync_pb::preference); + update_specifics.mutable_preference(); pref_specifics->set_name("update"); change_list.push_back(SyncChange( SyncChange::ACTION_UPDATE, @@ -85,8 +84,7 @@ TEST_F(SyncChangeTest, SyncerChanges) { // Create an add. sync_pb::EntitySpecifics add_specifics; - pref_specifics = - add_specifics.MutableExtension(sync_pb::preference); + pref_specifics = add_specifics.mutable_preference(); pref_specifics->set_name("add"); change_list.push_back(SyncChange( SyncChange::ACTION_ADD, @@ -94,8 +92,7 @@ TEST_F(SyncChangeTest, SyncerChanges) { // Create a delete. sync_pb::EntitySpecifics delete_specifics; - pref_specifics = - delete_specifics.MutableExtension(sync_pb::preference); + pref_specifics = delete_specifics.mutable_preference(); pref_specifics->set_name("add"); change_list.push_back(SyncChange( SyncChange::ACTION_DELETE, diff --git a/chrome/browser/sync/api/sync_data.cc b/chrome/browser/sync/api/sync_data.cc index 08117ac..180cb76 100644 --- a/chrome/browser/sync/api/sync_data.cc +++ b/chrome/browser/sync/api/sync_data.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. @@ -56,7 +56,7 @@ SyncData SyncData::CreateLocalDelete( const std::string& sync_tag, syncable::ModelType datatype) { sync_pb::EntitySpecifics specifics; - syncable::AddDefaultExtensionValue(datatype, &specifics); + syncable::AddDefaultFieldValue(datatype, &specifics); return CreateLocalData(sync_tag, "", specifics); } diff --git a/chrome/browser/sync/engine/apply_updates_command_unittest.cc b/chrome/browser/sync/engine/apply_updates_command_unittest.cc index e8d4604..8b98461 100644 --- a/chrome/browser/sync/engine/apply_updates_command_unittest.cc +++ b/chrome/browser/sync/engine/apply_updates_command_unittest.cc @@ -37,7 +37,7 @@ using syncable::WriteTransaction; namespace { sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { sync_pb::EntitySpecifics result; - AddDefaultExtensionValue(syncable::BOOKMARKS, &result); + AddDefaultFieldValue(syncable::BOOKMARKS, &result); return result; } } // namespace @@ -124,7 +124,7 @@ class ApplyUpdatesCommandTest : public SyncerCommandTest { entry.Put(syncable::PARENT_ID, parent_id); CHECK(entry.PutPredecessor(predecessor_id)); sync_pb::EntitySpecifics default_specifics; - syncable::AddDefaultExtensionValue(model_type, &default_specifics); + syncable::AddDefaultFieldValue(model_type, &default_specifics); entry.Put(syncable::SPECIFICS, default_specifics); if (item_id.ServerKnows()) { entry.Put(syncable::SERVER_SPECIFICS, default_specifics); @@ -170,7 +170,7 @@ class ApplyUpdatesCommandTest : public SyncerCommandTest { int64 version = GetNextRevision(); sync_pb::EntitySpecifics default_specifics; - syncable::AddDefaultExtensionValue(model_type, &default_specifics); + syncable::AddDefaultFieldValue(model_type, &default_specifics); MutableEntry entry(&trans, syncable::CREATE, parent_id, name); if (!entry.good()) { @@ -538,7 +538,7 @@ TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) { data.set_origin("http://example.com"); cryptographer->Encrypt(data, - specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); + specifics.mutable_password()->mutable_encrypted()); CreateUnappliedNewItem("item", specifics, false); ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD); @@ -560,14 +560,14 @@ TEST_F(ApplyUpdatesCommandTest, UndecryptableData) { // Undecryptable updates should not be applied. sync_pb::EntitySpecifics encrypted_bookmark; encrypted_bookmark.mutable_encrypted(); - AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); + AddDefaultFieldValue(syncable::BOOKMARKS, &encrypted_bookmark); string root_server_id = syncable::GetNullId().GetServerId(); CreateUnappliedNewItemWithParent("folder", encrypted_bookmark, root_server_id); CreateUnappliedNewItem("item2", encrypted_bookmark, false); sync_pb::EntitySpecifics encrypted_password; - encrypted_password.MutableExtension(sync_pb::password); + encrypted_password.mutable_password(); CreateUnappliedNewItem("item3", encrypted_password, false); ExpectGroupsToChange(apply_updates_command_, GROUP_UI, GROUP_PASSWORD); @@ -623,7 +623,7 @@ TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { cryptographer->AddKey(params); cryptographer->Encrypt(data, - specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); + specifics.mutable_password()->mutable_encrypted()); } CreateUnappliedNewItem("item1", specifics, false); } @@ -638,7 +638,7 @@ TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) { data.set_origin("http://example.com/2"); cryptographer.Encrypt(data, - specifics.MutableExtension(sync_pb::password)->mutable_encrypted()); + specifics.mutable_password()->mutable_encrypted()); CreateUnappliedNewItem("item2", specifics, false); } @@ -685,8 +685,7 @@ TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { other_cryptographer.AddKey(params); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); encrypted_types.Put(syncable::BOOKMARKS); @@ -734,8 +733,7 @@ TEST_F(ApplyUpdatesCommandTest, NigoriUpdateForDisabledTypes) { other_cryptographer.AddKey(params); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_sessions(true); nigori->set_encrypt_themes(true); @@ -814,8 +812,7 @@ TEST_F(ApplyUpdatesCommandTest, EncryptUnsyncedChanges) { KeyParams params = {"localhost", "dummy", "foobar"}; cryptographer->AddKey(params); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); cryptographer->GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); encrypted_types.Put(syncable::BOOKMARKS); @@ -954,8 +951,7 @@ TEST_F(ApplyUpdatesCommandTest, CannotEncryptUnsyncedChanges) { KeyParams params = {"localhost", "dummy", "foobar"}; other_cryptographer.AddKey(params); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); encrypted_types.Put(syncable::BOOKMARKS); diff --git a/chrome/browser/sync/engine/build_commit_command.cc b/chrome/browser/sync/engine/build_commit_command.cc index 4655827..06adac6 100644 --- a/chrome/browser/sync/engine/build_commit_command.cc +++ b/chrome/browser/sync/engine/build_commit_command.cc @@ -179,7 +179,7 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) { if (meta_entry.Get(IS_DEL)) { sync_entry->set_deleted(true); } else { - if (meta_entry.Get(SPECIFICS).HasExtension(sync_pb::bookmark)) { + if (meta_entry.Get(SPECIFICS).has_bookmark()) { // Common data in both new and old protocol. const Id& prev_id = meta_entry.Get(syncable::PREV_ID); string prev_id_string = diff --git a/chrome/browser/sync/engine/clear_data_command_unittest.cc b/chrome/browser/sync/engine/clear_data_command_unittest.cc index f84401a..0f56dad 100644 --- a/chrome/browser/sync/engine/clear_data_command_unittest.cc +++ b/chrome/browser/sync/engine/clear_data_command_unittest.cc @@ -7,7 +7,6 @@ #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" #include "chrome/browser/sync/protocol/sync.pb.h" -#include "chrome/browser/sync/test/engine/proto_extension_validator.h" #include "chrome/browser/sync/test/engine/syncer_command_test.h" #include "chrome/browser/sync/test/sessions/test_scoped_session_event_listener.h" diff --git a/chrome/browser/sync/engine/conflict_resolver.cc b/chrome/browser/sync/engine/conflict_resolver.cc index 77521ab..c608ba5 100644 --- a/chrome/browser/sync/engine/conflict_resolver.cc +++ b/chrome/browser/sync/engine/conflict_resolver.cc @@ -227,25 +227,23 @@ ConflictResolver::ProcessSimpleConflict(WriteTransaction* trans, // preserves their encryption keys). sync_pb::EntitySpecifics specifics = entry.Get(syncable::SERVER_SPECIFICS); - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* server_nigori = specifics.mutable_nigori(); // Store the merged set of encrypted types (cryptographer->Update(..) will // have merged the local types already). - cryptographer->UpdateNigoriFromEncryptedTypes(nigori); + cryptographer->UpdateNigoriFromEncryptedTypes(server_nigori); // The local set of keys is already merged with the server's set within // the cryptographer. If we don't have pending keys we can store the // merged set back immediately. Else we preserve the server keys and will // update the nigori when the user provides the pending passphrase via // SetPassphrase(..). if (cryptographer->is_ready()) { - cryptographer->GetKeys(nigori->mutable_encrypted()); + cryptographer->GetKeys(server_nigori->mutable_encrypted()); } // TODO(zea): Find a better way of doing this. As it stands, we have to // update this code whenever we add a new non-cryptographer related field // to the nigori node. - if (entry.Get(syncable::SPECIFICS).GetExtension(sync_pb::nigori) - .sync_tabs()) { - nigori->set_sync_tabs(true); + if (entry.Get(syncable::SPECIFICS).nigori().sync_tabs()) { + server_nigori->set_sync_tabs(true); } // We deliberately leave the server's device information. This client will // add it's own device information on restart. diff --git a/chrome/browser/sync/engine/download_updates_command_unittest.cc b/chrome/browser/sync/engine/download_updates_command_unittest.cc index 3998ee0a..0bcc0d7 100644 --- a/chrome/browser/sync/engine/download_updates_command_unittest.cc +++ b/chrome/browser/sync/engine/download_updates_command_unittest.cc @@ -8,7 +8,6 @@ #include "chrome/browser/sync/protocol/preference_specifics.pb.h" #include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/sync/test/engine/fake_model_worker.h" -#include "chrome/browser/sync/test/engine/proto_extension_validator.h" #include "chrome/browser/sync/test/engine/syncer_command_test.h" using ::testing::_; diff --git a/chrome/browser/sync/engine/nigori_util_unittest.cc b/chrome/browser/sync/engine/nigori_util_unittest.cc index 1472f39..7d3fc34 100644 --- a/chrome/browser/sync/engine/nigori_util_unittest.cc +++ b/chrome/browser/sync/engine/nigori_util_unittest.cc @@ -1,8 +1,9 @@ -// 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. #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/sync/util/cryptographer.h" #include "chrome/browser/sync/engine/nigori_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,15 +21,15 @@ TEST(NigoriUtilTest, SpecificsNeedsEncryption) { EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), specifics)); EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); - AddDefaultExtensionValue(PREFERENCES, &specifics); + AddDefaultFieldValue(PREFERENCES, &specifics); EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics)); sync_pb::EntitySpecifics bookmark_specifics; - AddDefaultExtensionValue(BOOKMARKS, &bookmark_specifics); + AddDefaultFieldValue(BOOKMARKS, &bookmark_specifics); EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); - bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); - bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); + bookmark_specifics.mutable_bookmark()->set_title("title"); + bookmark_specifics.mutable_bookmark()->set_url("url"); EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics)); EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); @@ -37,7 +38,7 @@ TEST(NigoriUtilTest, SpecificsNeedsEncryption) { EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics)); sync_pb::EntitySpecifics password_specifics; - AddDefaultExtensionValue(PASSWORDS, &password_specifics); + AddDefaultFieldValue(PASSWORDS, &password_specifics); EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, password_specifics)); } 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 ed968b1..44a9515 100644 --- a/chrome/browser/sync/engine/process_commit_response_command_unittest.cc +++ b/chrome/browser/sync/engine/process_commit_response_command_unittest.cc @@ -97,7 +97,7 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest { entry.Put(syncable::PARENT_ID, parent_id); entry.PutPredecessor(predecessor_id); sync_pb::EntitySpecifics default_specifics; - syncable::AddDefaultExtensionValue(model_type, &default_specifics); + syncable::AddDefaultFieldValue(model_type, &default_specifics); entry.Put(syncable::SPECIFICS, default_specifics); if (item_id.ServerKnows()) { entry.Put(syncable::SERVER_SPECIFICS, default_specifics); diff --git a/chrome/browser/sync/engine/store_timestamps_command.cc b/chrome/browser/sync/engine/store_timestamps_command.cc index 082a870..efe7bbc 100644 --- a/chrome/browser/sync/engine/store_timestamps_command.cc +++ b/chrome/browser/sync/engine/store_timestamps_command.cc @@ -29,7 +29,7 @@ SyncerError StoreTimestampsCommand::ExecuteImpl( syncable::ModelTypeSet forward_progress_types; for (int i = 0; i < updates.new_progress_marker_size(); ++i) { syncable::ModelType model = - syncable::GetModelTypeFromExtensionFieldNumber( + syncable::GetModelTypeFromSpecificsFieldNumber( updates.new_progress_marker(i).data_type_id()); if (model == syncable::UNSPECIFIED || model == syncable::TOP_LEVEL_FOLDER) { NOTREACHED() << "Unintelligible server response."; diff --git a/chrome/browser/sync/engine/syncapi_internal.cc b/chrome/browser/sync/engine/syncapi_internal.cc index 3db0ea8..b0c5e3a 100644 --- a/chrome/browser/sync/engine/syncapi_internal.cc +++ b/chrome/browser/sync/engine/syncapi_internal.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. @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/sync/util/cryptographer.h" #include "chrome/browser/sync/protocol/password_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" using browser_sync::Cryptographer; @@ -14,10 +15,9 @@ namespace sync_api { sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { - if (!specifics.HasExtension(sync_pb::password)) + if (!specifics.has_password()) return NULL; - const sync_pb::PasswordSpecifics& password_specifics = - specifics.GetExtension(sync_pb::password); + const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); if (!password_specifics.has_encrypted()) return NULL; const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc index 53c917a..d0712b5 100644 --- a/chrome/browser/sync/engine/syncer_proto_util.cc +++ b/chrome/browser/sync/engine/syncer_proto_util.cc @@ -111,7 +111,7 @@ void SyncerProtoUtil::HandleMigrationDoneResponse( << "MIGRATION_DONE but no types specified."; syncable::ModelTypeSet to_migrate; for (int i = 0; i < response->migrated_data_type_id_size(); i++) { - to_migrate.Put(syncable::GetModelTypeFromExtensionFieldNumber( + to_migrate.Put(syncable::GetModelTypeFromSpecificsFieldNumber( response->migrated_data_type_id(i))); } // TODO(akalin): This should be a set union. @@ -301,7 +301,7 @@ browser_sync::SyncProtocolError ConvertErrorPBToLocalType( 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( + syncable::GetModelTypeFromSpecificsFieldNumber( error.error_data_type_ids(i))); } } diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc index 374dec0..3a45495 100644 --- a/chrome/browser/sync/engine/syncer_unittest.cc +++ b/chrome/browser/sync/engine/syncer_unittest.cc @@ -234,8 +234,8 @@ class SyncerTest : public testing::Test, EXPECT_FALSE(entry->Get(IS_DIR)); EXPECT_FALSE(entry->Get(IS_DEL)); sync_pb::EntitySpecifics specifics; - specifics.MutableExtension(sync_pb::bookmark)->set_url("http://demo/"); - specifics.MutableExtension(sync_pb::bookmark)->set_favicon("PNG"); + specifics.mutable_bookmark()->set_url("http://demo/"); + specifics.mutable_bookmark()->set_favicon("PNG"); entry->Put(syncable::SPECIFICS, specifics); entry->Put(syncable::IS_UNSYNCED, true); } @@ -246,9 +246,9 @@ class SyncerTest : public testing::Test, } void VerifyTestBookmarkDataInEntry(Entry* entry) { const sync_pb::EntitySpecifics& specifics = entry->Get(syncable::SPECIFICS); - EXPECT_TRUE(specifics.HasExtension(sync_pb::bookmark)); - EXPECT_EQ("PNG", specifics.GetExtension(sync_pb::bookmark).favicon()); - EXPECT_EQ("http://demo/", specifics.GetExtension(sync_pb::bookmark).url()); + EXPECT_TRUE(specifics.has_bookmark()); + EXPECT_EQ("PNG", specifics.bookmark().favicon()); + EXPECT_EQ("http://demo/", specifics.bookmark().url()); } void SyncRepeatedlyToTriggerConflictResolution(SyncSession* session) { @@ -264,13 +264,13 @@ class SyncerTest : public testing::Test, } sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { sync_pb::EntitySpecifics result; - AddDefaultExtensionValue(syncable::BOOKMARKS, &result); + AddDefaultFieldValue(syncable::BOOKMARKS, &result); return result; } sync_pb::EntitySpecifics DefaultPreferencesSpecifics() { sync_pb::EntitySpecifics result; - AddDefaultExtensionValue(syncable::PREFERENCES, &result); + AddDefaultFieldValue(syncable::PREFERENCES, &result); return result; } // Enumeration of alterations to entries for commit ordering tests. @@ -581,7 +581,7 @@ TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { const syncable::ModelTypeSet throttled_types(syncable::BOOKMARKS); sync_pb::EntitySpecifics bookmark_data; - AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data); + AddDefaultFieldValue(syncable::BOOKMARKS, &bookmark_data); mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); SyncShareAsDelegate(); @@ -646,9 +646,9 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) { KeyParams key_params = {"localhost", "dummy", "foobar"}; KeyParams other_params = {"localhost", "dummy", "foobar2"}; sync_pb::EntitySpecifics bookmark, encrypted_bookmark; - bookmark.MutableExtension(sync_pb::bookmark)->set_url("url"); - bookmark.MutableExtension(sync_pb::bookmark)->set_title("title"); - AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); + bookmark.mutable_bookmark()->set_url("url"); + bookmark.mutable_bookmark()->set_title("title"); + AddDefaultFieldValue(syncable::BOOKMARKS, &encrypted_bookmark); mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); mock_server_->AddUpdateDirectory(2, 0, "B", 10, 10); mock_server_->AddUpdateDirectory(3, 0, "C", 10, 10); @@ -663,8 +663,7 @@ TEST_F(SyncerTest, GetCommitIdsFiltersUnreadyEntries) { browser_sync::Cryptographer other_cryptographer(&encryptor_); other_cryptographer.AddKey(other_params); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); // Set up with an old passphrase, but have pending keys @@ -762,19 +761,19 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) { browser_sync::Cryptographer other_cryptographer(&encryptor_); other_cryptographer.AddKey(key_params); sync_pb::EntitySpecifics bookmark, encrypted_bookmark, modified_bookmark; - bookmark.MutableExtension(sync_pb::bookmark)->set_title("title"); + bookmark.mutable_bookmark()->set_title("title"); other_cryptographer.Encrypt(bookmark, encrypted_bookmark.mutable_encrypted()); - AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark); - modified_bookmark.MutableExtension(sync_pb::bookmark)->set_title("title2"); + AddDefaultFieldValue(syncable::BOOKMARKS, &encrypted_bookmark); + modified_bookmark.mutable_bookmark()->set_title("title2"); other_cryptographer.Encrypt(modified_bookmark, modified_bookmark.mutable_encrypted()); sync_pb::EntitySpecifics pref, encrypted_pref, modified_pref; - pref.MutableExtension(sync_pb::preference)->set_name("name"); - AddDefaultExtensionValue(syncable::PREFERENCES, &encrypted_pref); + pref.mutable_preference()->set_name("name"); + AddDefaultFieldValue(syncable::PREFERENCES, &encrypted_pref); other_cryptographer.Encrypt(pref, encrypted_pref.mutable_encrypted()); - modified_pref.MutableExtension(sync_pb::preference)->set_name("name2"); + modified_pref.mutable_preference()->set_name("name2"); other_cryptographer.Encrypt(modified_pref, modified_pref.mutable_encrypted()); { @@ -782,8 +781,7 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) { // have pending keys. WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); nigori->set_encrypt_preferences(true); @@ -947,19 +945,17 @@ TEST_F(SyncerTest, NigoriConflicts) { other_cryptographer.AddKey(other_key_params); syncable::ModelTypeSet encrypted_types(syncable::PASSWORDS, syncable::NIGORI); sync_pb::EntitySpecifics initial_nigori_specifics; - initial_nigori_specifics.MutableExtension(sync_pb::nigori); + initial_nigori_specifics.mutable_nigori(); mock_server_->SetNigori(1, 10, 10, initial_nigori_specifics); // Data for testing encryption/decryption. sync_pb::EntitySpecifics other_encrypted_specifics; - other_encrypted_specifics.MutableExtension(sync_pb::bookmark)-> - set_title("title"); + other_encrypted_specifics.mutable_bookmark()->set_title("title"); other_cryptographer.Encrypt( other_encrypted_specifics, other_encrypted_specifics.mutable_encrypted()); sync_pb::EntitySpecifics our_encrypted_specifics; - our_encrypted_specifics.MutableExtension(sync_pb::bookmark)-> - set_title("title2"); + our_encrypted_specifics.mutable_bookmark()->set_title("title2"); // Receive the initial nigori node. SyncShareAsDelegate(); @@ -968,8 +964,7 @@ TEST_F(SyncerTest, NigoriConflicts) { // Local changes with different passphrase, different types, and sync_tabs. WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); cryptographer(&wtrans)->AddKey(local_key_params); cryptographer(&wtrans)->Encrypt( our_encrypted_specifics, @@ -990,8 +985,7 @@ TEST_F(SyncerTest, NigoriConflicts) { } { sync_pb::EntitySpecifics specifics; - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); other_cryptographer.GetKeys(nigori->mutable_encrypted()); nigori->set_encrypt_bookmarks(true); nigori->set_encrypt_preferences(true); @@ -1019,14 +1013,13 @@ TEST_F(SyncerTest, NigoriConflicts) { EXPECT_TRUE(encrypted_types.Equals( cryptographer(&wtrans)->GetEncryptedTypes())); EXPECT_TRUE(cryptographer(&wtrans)->encrypt_everything()); - EXPECT_TRUE(specifics.GetExtension(sync_pb::nigori).sync_tabs()); + EXPECT_TRUE(specifics.nigori().sync_tabs()); // Supply the pending keys. Afterwards, we should be able to decrypt both // our own encrypted data and data encrypted by the other cryptographer, // but the key provided by the other cryptographer should be the default. EXPECT_TRUE(cryptographer(&wtrans)->DecryptPendingKeys(other_key_params)); EXPECT_FALSE(cryptographer(&wtrans)->has_pending_keys()); - sync_pb::NigoriSpecifics* nigori = - specifics.MutableExtension(sync_pb::nigori); + sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); cryptographer(&wtrans)->GetKeys(nigori->mutable_encrypted()); cryptographer(&wtrans)->UpdateNigoriFromEncryptedTypes(nigori); // Normally this would be written as part of SetPassphrase, but we do it @@ -1054,8 +1047,7 @@ TEST_F(SyncerTest, NigoriConflicts) { other_encrypted_specifics.encrypted())); EXPECT_TRUE(cryptographer(&wtrans)-> CanDecryptUsingDefaultKey(other_encrypted_specifics.encrypted())); - EXPECT_TRUE(nigori_entry.Get(SPECIFICS).GetExtension(sync_pb::nigori) - .sync_tabs()); + EXPECT_TRUE(nigori_entry.Get(SPECIFICS).nigori().sync_tabs()); } } @@ -2299,7 +2291,7 @@ TEST_F(SyncerTest, DoublyChangedWithResolver) { ASSERT_TRUE(child.good()); EXPECT_TRUE(child.Get(syncable::IS_UNSYNCED)); EXPECT_FALSE(child.Get(syncable::IS_UNAPPLIED_UPDATE)); - EXPECT_TRUE(child.Get(SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_TRUE(child.Get(SPECIFICS).has_bookmark()); EXPECT_EQ("Pete.htm", child.Get(NON_UNIQUE_NAME)); VerifyTestBookmarkDataInEntry(&child); } @@ -2727,7 +2719,7 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. - server.Get(SPECIFICS).GetExtension(sync_pb::bookmark).url()); + server.Get(SPECIFICS).bookmark().url()); } } @@ -2793,7 +2785,7 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { EXPECT_EQ("Bar.htm", server.Get(NON_UNIQUE_NAME)); EXPECT_EQ("Bar.htm", local.Get(NON_UNIQUE_NAME)); EXPECT_EQ("http://google.com", // Default from AddUpdateBookmark. - server.Get(SPECIFICS).GetExtension(sync_pb::bookmark).url()); + server.Get(SPECIFICS).bookmark().url()); } } @@ -3521,11 +3513,9 @@ TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) { int64 original_metahandle = 0; sync_pb::EntitySpecifics local_bookmark(DefaultBookmarkSpecifics()); - local_bookmark.MutableExtension(sync_pb::bookmark)-> - set_url("http://foo/localsite"); + local_bookmark.mutable_bookmark()->set_url("http://foo/localsite"); sync_pb::EntitySpecifics server_bookmark(DefaultBookmarkSpecifics()); - server_bookmark.MutableExtension(sync_pb::bookmark)-> - set_url("http://bar/serversite"); + server_bookmark.mutable_bookmark()->set_url("http://bar/serversite"); { WriteTransaction trans(FROM_HERE, UNITTEST, directory()); diff --git a/chrome/browser/sync/engine/syncer_util.cc b/chrome/browser/sync/engine/syncer_util.cc index 2efe5d0..6a1af32 100644 --- a/chrome/browser/sync/engine/syncer_util.cc +++ b/chrome/browser/sync/engine/syncer_util.cc @@ -280,9 +280,8 @@ UpdateAttemptResponse SyncerUtil::AttemptToUpdateEntry( // priority on preserving the server's passphrase change to preserving local // non-encryption changes. Next time the non-encryption changes are made to // the nigori node (e.g. on restart), they will commit without issue. - if (specifics.HasExtension(sync_pb::nigori)) { - const sync_pb::NigoriSpecifics& nigori = - specifics.GetExtension(sync_pb::nigori); + if (specifics.has_nigori()) { + const sync_pb::NigoriSpecifics& nigori = specifics.nigori(); cryptographer->Update(nigori); // Make sure any unsynced changes are properly encrypted as necessary. @@ -320,11 +319,10 @@ UpdateAttemptResponse SyncerUtil::AttemptToUpdateEntry( << syncable::ModelTypeToString(entry->GetServerModelType()) << " update, returning encryption_conflict."; return CONFLICT_ENCRYPTION; - } else if (specifics.HasExtension(sync_pb::password) && + } else if (specifics.has_password() && entry->Get(UNIQUE_SERVER_TAG).empty()) { // Passwords use their own legacy encryption scheme. - const sync_pb::PasswordSpecifics& password = - specifics.GetExtension(sync_pb::password); + const sync_pb::PasswordSpecifics& password = specifics.password(); if (!cryptographer->CanDecrypt(password.encrypted())) { DVLOG(1) << "Received an undecryptable password update, returning " << "encryption_conflict."; @@ -396,7 +394,7 @@ void UpdateBookmarkSpecifics(const std::string& singleton_tag, if (singleton_tag == "google_chrome") return; sync_pb::EntitySpecifics pb; - sync_pb::BookmarkSpecifics* bookmark = pb.MutableExtension(sync_pb::bookmark); + sync_pb::BookmarkSpecifics* bookmark = pb.mutable_bookmark(); if (!url.empty()) bookmark->set_url(url); if (!favicon_bytes.empty()) diff --git a/chrome/browser/sync/engine/verify_updates_command_unittest.cc b/chrome/browser/sync/engine/verify_updates_command_unittest.cc index d3f20a4..b207e6f 100644 --- a/chrome/browser/sync/engine/verify_updates_command_unittest.cc +++ b/chrome/browser/sync/engine/verify_updates_command_unittest.cc @@ -51,7 +51,7 @@ class VerifyUpdatesCommandTest : public SyncerCommandTest { entry.Put(syncable::NON_UNIQUE_NAME, item_id); entry.Put(syncable::PARENT_ID, Id::CreateFromServerId(parent_id)); sync_pb::EntitySpecifics default_specifics; - AddDefaultExtensionValue(type, &default_specifics); + AddDefaultFieldValue(type, &default_specifics); entry.Put(syncable::SERVER_SPECIFICS, default_specifics); } @@ -63,7 +63,7 @@ class VerifyUpdatesCommandTest : public SyncerCommandTest { e->set_parent_id_string(parent); e->set_non_unique_name("b1"); e->set_name("b1"); - AddDefaultExtensionValue(type, e->mutable_specifics()); + AddDefaultFieldValue(type, e->mutable_specifics()); } VerifyUpdatesCommand command_; diff --git a/chrome/browser/sync/glue/password_change_processor.cc b/chrome/browser/sync/glue/password_change_processor.cc index a2fb04e..87efd19 100644 --- a/chrome/browser/sync/glue/password_change_processor.cc +++ b/chrome/browser/sync/glue/password_change_processor.cc @@ -175,7 +175,7 @@ void PasswordChangeProcessor::ApplyChangesFromSyncModel( changes.Get().begin(); it != changes.Get().end(); ++it) { if (sync_api::ChangeRecord::ACTION_DELETE == it->action) { - DCHECK(it->specifics.HasExtension(sync_pb::password)) + DCHECK(it->specifics.has_password()) << "Password specifics data not present on delete!"; DCHECK(it->extra.get()); sync_api::ExtraPasswordChangeRecordData* extra = diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc index 8b51ed9..00b9979 100644 --- a/chrome/browser/sync/glue/session_change_processor.cc +++ b/chrome/browser/sync/glue/session_change_processor.cc @@ -264,8 +264,7 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel( // and just ensure we've disassociated. DCHECK_EQ(syncable::GetModelTypeFromSpecifics(it->specifics), syncable::SESSIONS); - const sync_pb::SessionSpecifics& specifics = - it->specifics.GetExtension(sync_pb::session); + const sync_pb::SessionSpecifics& specifics = it->specifics.session(); session_model_associator_->DisassociateForeignSession( specifics.session_tag()); continue; diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc index 74277cc..7fe8b2b 100644 --- a/chrome/browser/sync/glue/typed_url_change_processor.cc +++ b/chrome/browser/sync/glue/typed_url_change_processor.cc @@ -213,9 +213,9 @@ void TypedUrlChangeProcessor::ApplyChangesFromSyncModel( changes.Get().begin(); it != changes.Get().end(); ++it) { if (sync_api::ChangeRecord::ACTION_DELETE == it->action) { - DCHECK(it->specifics.HasExtension(sync_pb::typed_url)) << + DCHECK(it->specifics.has_typed_url()) << "Typed URL delete change does not have necessary specifics."; - GURL url(it->specifics.GetExtension(sync_pb::typed_url).url()); + GURL url(it->specifics.typed_url().url()); pending_deleted_urls_.push_back(url); continue; } diff --git a/chrome/browser/sync/internal_api/base_node.cc b/chrome/browser/sync/internal_api/base_node.cc index 4778720..9098105 100644 --- a/chrome/browser/sync/internal_api/base_node.cc +++ b/chrome/browser/sync/internal_api/base_node.cc @@ -63,10 +63,10 @@ BaseNode::~BaseNode() {} std::string BaseNode::GenerateSyncableHash( syncable::ModelType model_type, const std::string& client_tag) { - // blank PB with just the extension in it has termination symbol, - // handy for delimiter + // Blank PB with just the field in it has termination symbol, + // handy for delimiter. sync_pb::EntitySpecifics serialized_type; - syncable::AddDefaultExtensionValue(model_type, &serialized_type); + syncable::AddDefaultFieldValue(model_type, &serialized_type); std::string hash_input; serialized_type.AppendToString(&hash_input); hash_input.append(client_tag); @@ -81,7 +81,7 @@ bool BaseNode::DecryptIfNecessary() { return true; // Ignore unique folders. const sync_pb::EntitySpecifics& specifics = GetEntry()->Get(syncable::SPECIFICS); - if (specifics.HasExtension(sync_pb::password)) { + if (specifics.has_password()) { // Passwords have their own legacy encryption structure. scoped_ptr<sync_pb::PasswordSpecificsData> data(DecryptPasswordSpecifics( specifics, GetTransaction()->GetCryptographer())); @@ -100,7 +100,7 @@ bool BaseNode::DecryptIfNecessary() { // follows the new bookmarks format. if (!specifics.has_encrypted()) { if (GetModelType() == syncable::BOOKMARKS && - !specifics.GetExtension(sync_pb::bookmark).has_title() && + !specifics.bookmark().has_title() && !GetTitle().empty()) { // Last check ensures this isn't a new node. // We need to fill in the title. std::string title = GetTitle(); @@ -109,7 +109,7 @@ bool BaseNode::DecryptIfNecessary() { DVLOG(1) << "Reading from legacy bookmark, manually returning title " << title; unencrypted_data_.CopyFrom(specifics); - unencrypted_data_.MutableExtension(sync_pb::bookmark)->set_title( + unencrypted_data_.mutable_bookmark()->set_title( server_legal_title); } return true; @@ -144,7 +144,7 @@ const sync_pb::EntitySpecifics& BaseNode::GetUnencryptedSpecifics( // DecryptIfNecessary(). if (GetModelType() == syncable::BOOKMARKS) { const sync_pb::BookmarkSpecifics& bookmark_specifics = - specifics.GetExtension(sync_pb::bookmark); + specifics.bookmark(); if (bookmark_specifics.has_title() || GetTitle().empty() || // For the empty node case !GetEntry()->Get(syncable::UNIQUE_SERVER_TAG).empty()) { @@ -277,27 +277,27 @@ int64 BaseNode::GetExternalId() const { const sync_pb::AppSpecifics& BaseNode::GetAppSpecifics() const { DCHECK_EQ(syncable::APPS, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::app); + return GetEntitySpecifics().app(); } const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const { DCHECK_EQ(syncable::AUTOFILL, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::autofill); + return GetEntitySpecifics().autofill(); } const AutofillProfileSpecifics& BaseNode::GetAutofillProfileSpecifics() const { DCHECK_EQ(GetModelType(), syncable::AUTOFILL_PROFILE); - return GetEntitySpecifics().GetExtension(sync_pb::autofill_profile); + return GetEntitySpecifics().autofill_profile(); } const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const { DCHECK_EQ(syncable::BOOKMARKS, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::bookmark); + return GetEntitySpecifics().bookmark(); } const sync_pb::NigoriSpecifics& BaseNode::GetNigoriSpecifics() const { DCHECK_EQ(syncable::NIGORI, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::nigori); + return GetEntitySpecifics().nigori(); } const sync_pb::PasswordSpecificsData& BaseNode::GetPasswordSpecifics() const { @@ -307,22 +307,22 @@ const sync_pb::PasswordSpecificsData& BaseNode::GetPasswordSpecifics() const { const sync_pb::ThemeSpecifics& BaseNode::GetThemeSpecifics() const { DCHECK_EQ(syncable::THEMES, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::theme); + return GetEntitySpecifics().theme(); } const sync_pb::TypedUrlSpecifics& BaseNode::GetTypedUrlSpecifics() const { DCHECK_EQ(syncable::TYPED_URLS, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::typed_url); + return GetEntitySpecifics().typed_url(); } const sync_pb::ExtensionSpecifics& BaseNode::GetExtensionSpecifics() const { DCHECK_EQ(syncable::EXTENSIONS, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::extension); + return GetEntitySpecifics().extension(); } const sync_pb::SessionSpecifics& BaseNode::GetSessionSpecifics() const { DCHECK_EQ(syncable::SESSIONS, GetModelType()); - return GetEntitySpecifics().GetExtension(sync_pb::session); + return GetEntitySpecifics().session(); } const sync_pb::EntitySpecifics& BaseNode::GetEntitySpecifics() const { diff --git a/chrome/browser/sync/internal_api/change_record_unittest.cc b/chrome/browser/sync/internal_api/change_record_unittest.cc index e9cb3a4..edb2ae1 100644 --- a/chrome/browser/sync/internal_api/change_record_unittest.cc +++ b/chrome/browser/sync/internal_api/change_record_unittest.cc @@ -75,9 +75,9 @@ class MockExtraChangeRecordData TEST_F(ChangeRecordTest, ChangeRecordToValue) { sync_pb::EntitySpecifics old_specifics; - old_specifics.MutableExtension(sync_pb::extension)->set_id("old"); + old_specifics.mutable_extension()->set_id("old"); sync_pb::EntitySpecifics new_specifics; - old_specifics.MutableExtension(sync_pb::extension)->set_id("new"); + old_specifics.mutable_extension()->set_id("new"); const int64 kTestId = 5; diff --git a/chrome/browser/sync/internal_api/syncapi_unittest.cc b/chrome/browser/sync/internal_api/syncapi_unittest.cc index 827927a..c4f6e16 100644 --- a/chrome/browser/sync/internal_api/syncapi_unittest.cc +++ b/chrome/browser/sync/internal_api/syncapi_unittest.cc @@ -168,7 +168,7 @@ int64 MakeFolderWithParent(UserShare* share, int64 MakeServerNodeForType(UserShare* share, ModelType model_type) { sync_pb::EntitySpecifics specifics; - syncable::AddDefaultExtensionValue(model_type, &specifics); + syncable::AddDefaultFieldValue(model_type, &specifics); syncable::WriteTransaction trans( FROM_HERE, syncable::UNITTEST, share->directory.get()); // Attempt to lookup by nigori tag. @@ -506,8 +506,7 @@ TEST_F(SyncApiTest, BaseNodeSetSpecifics) { EXPECT_TRUE(node.InitByIdLookup(child_id)); sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)-> - set_url("http://www.google.com"); + entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); EXPECT_NE(entity_specifics.SerializeAsString(), node.GetEntitySpecifics().SerializeAsString()); @@ -525,8 +524,7 @@ TEST_F(SyncApiTest, BaseNodeSetSpecificsPreservesUnknownFields) { EXPECT_TRUE(node.GetEntitySpecifics().unknown_fields().empty()); sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)-> - set_url("http://www.google.com"); + entity_specifics.mutable_bookmark()->set_url("http://www.google.com"); entity_specifics.mutable_unknown_fields()->AddFixed32(5, 100); node.SetEntitySpecifics(entity_specifics); EXPECT_FALSE(node.GetEntitySpecifics().unknown_fields().empty()); @@ -1791,7 +1789,7 @@ TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { EXPECT_TRUE(node.InitByIdLookup(node_id1)); sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)->set_url(url); + entity_specifics.mutable_bookmark()->set_url(url); node.SetEntitySpecifics(entity_specifics); // Set the old style title. @@ -1802,7 +1800,7 @@ TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) { EXPECT_TRUE(node2.InitByIdLookup(node_id2)); sync_pb::EntitySpecifics entity_specifics2; - entity_specifics2.MutableExtension(sync_pb::bookmark)->set_url(url2); + entity_specifics2.mutable_bookmark()->set_url(url2); node2.SetEntitySpecifics(entity_specifics2); // Set the old style title. @@ -1908,8 +1906,8 @@ TEST_F(SyncManagerTest, CreateLocalBookmark) { TEST_F(SyncManagerTest, UpdateEntryWithEncryption) { std::string client_tag = "title"; sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); - entity_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); + entity_specifics.mutable_bookmark()->set_url("url"); + entity_specifics.mutable_bookmark()->set_title("title"); MakeServerNode(sync_manager_.GetUserShare(), syncable::BOOKMARKS, client_tag, BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, client_tag), @@ -2012,8 +2010,8 @@ TEST_F(SyncManagerTest, UpdateEntryWithEncryption) { // Manually change to different data. Should set is_unsynced. { - entity_specifics.MutableExtension(sync_pb::bookmark)->set_url("url2"); - entity_specifics.MutableExtension(sync_pb::bookmark)->set_title("title2"); + entity_specifics.mutable_bookmark()->set_url("url2"); + entity_specifics.mutable_bookmark()->set_title("title2"); WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); WriteNode node(&trans); EXPECT_TRUE(node.InitByClientTagLookup(syncable::BOOKMARKS, client_tag)); @@ -2042,7 +2040,7 @@ TEST_F(SyncManagerTest, UpdatePasswordSetEntitySpecificsNoChange) { data.set_password_value("secret"); cryptographer->Encrypt( data, - entity_specifics.MutableExtension(sync_pb::password)-> + entity_specifics.mutable_password()-> mutable_encrypted()); } MakeServerNode(sync_manager_.GetUserShare(), syncable::PASSWORDS, client_tag, @@ -2076,7 +2074,7 @@ TEST_F(SyncManagerTest, UpdatePasswordSetPasswordSpecifics) { data.set_password_value("secret"); cryptographer->Encrypt( data, - entity_specifics.MutableExtension(sync_pb::password)-> + entity_specifics.mutable_password()-> mutable_encrypted()); } MakeServerNode(sync_manager_.GetUserShare(), syncable::PASSWORDS, client_tag, @@ -2106,8 +2104,7 @@ TEST_F(SyncManagerTest, UpdatePasswordSetPasswordSpecifics) { data.set_password_value("secret2"); cryptographer->Encrypt( data, - entity_specifics.MutableExtension(sync_pb::password)-> - mutable_encrypted()); + entity_specifics.mutable_password()->mutable_encrypted()); node.SetPasswordSpecifics(data); const syncable::Entry* node_entry = node.GetEntry(); EXPECT_TRUE(node_entry->Get(IS_UNSYNCED)); @@ -2127,8 +2124,7 @@ TEST_F(SyncManagerTest, UpdatePasswordNewPassphrase) { data.set_password_value("secret"); cryptographer->Encrypt( data, - entity_specifics.MutableExtension(sync_pb::password)-> - mutable_encrypted()); + entity_specifics.mutable_password()->mutable_encrypted()); } MakeServerNode(sync_manager_.GetUserShare(), syncable::PASSWORDS, client_tag, BaseNode::GenerateSyncableHash(syncable::PASSWORDS, @@ -2159,8 +2155,7 @@ TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) { data.set_password_value("secret"); cryptographer->Encrypt( data, - entity_specifics.MutableExtension(sync_pb::password)-> - mutable_encrypted()); + entity_specifics.mutable_password()->mutable_encrypted()); } MakeServerNode(sync_manager_.GetUserShare(), syncable::PASSWORDS, client_tag, BaseNode::GenerateSyncableHash(syncable::PASSWORDS, @@ -2183,8 +2178,8 @@ TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) { TEST_F(SyncManagerTest, SetBookmarkTitle) { std::string client_tag = "title"; sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); - entity_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); + entity_specifics.mutable_bookmark()->set_url("url"); + entity_specifics.mutable_bookmark()->set_title("title"); MakeServerNode(sync_manager_.GetUserShare(), syncable::BOOKMARKS, client_tag, BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, client_tag), @@ -2217,8 +2212,8 @@ TEST_F(SyncManagerTest, SetBookmarkTitle) { TEST_F(SyncManagerTest, SetBookmarkTitleWithEncryption) { std::string client_tag = "title"; sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); - entity_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); + entity_specifics.mutable_bookmark()->set_url("url"); + entity_specifics.mutable_bookmark()->set_title("title"); MakeServerNode(sync_manager_.GetUserShare(), syncable::BOOKMARKS, client_tag, BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, client_tag), @@ -2271,8 +2266,8 @@ TEST_F(SyncManagerTest, SetBookmarkTitleWithEncryption) { TEST_F(SyncManagerTest, SetNonBookmarkTitle) { std::string client_tag = "title"; sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::preference)->set_name("name"); - entity_specifics.MutableExtension(sync_pb::preference)->set_value("value"); + entity_specifics.mutable_preference()->set_name("name"); + entity_specifics.mutable_preference()->set_value("value"); MakeServerNode(sync_manager_.GetUserShare(), syncable::PREFERENCES, client_tag, @@ -2307,8 +2302,8 @@ TEST_F(SyncManagerTest, SetNonBookmarkTitle) { TEST_F(SyncManagerTest, SetNonBookmarkTitleWithEncryption) { std::string client_tag = "title"; sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::preference)->set_name("name"); - entity_specifics.MutableExtension(sync_pb::preference)->set_value("value"); + entity_specifics.mutable_preference()->set_name("name"); + entity_specifics.mutable_preference()->set_value("value"); MakeServerNode(sync_manager_.GetUserShare(), syncable::PREFERENCES, client_tag, @@ -2372,12 +2367,12 @@ TEST_F(SyncManagerTest, SetPreviouslyEncryptedSpecifics) { ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); browser_sync::Cryptographer* crypto = trans.GetCryptographer(); sync_pb::EntitySpecifics bm_specifics; - bm_specifics.MutableExtension(sync_pb::bookmark)->set_title("title"); - bm_specifics.MutableExtension(sync_pb::bookmark)->set_url("url"); + bm_specifics.mutable_bookmark()->set_title("title"); + bm_specifics.mutable_bookmark()->set_url("url"); sync_pb::EncryptedData encrypted; crypto->Encrypt(bm_specifics, &encrypted); entity_specifics.mutable_encrypted()->CopyFrom(encrypted); - syncable::AddDefaultExtensionValue(syncable::BOOKMARKS, &entity_specifics); + syncable::AddDefaultFieldValue(syncable::BOOKMARKS, &entity_specifics); } MakeServerNode(sync_manager_.GetUserShare(), syncable::BOOKMARKS, client_tag, BaseNode::GenerateSyncableHash(syncable::BOOKMARKS, diff --git a/chrome/browser/sync/internal_api/write_node.cc b/chrome/browser/sync/internal_api/write_node.cc index 8fdbfe9..d64639d 100644 --- a/chrome/browser/sync/internal_api/write_node.cc +++ b/chrome/browser/sync/internal_api/write_node.cc @@ -73,7 +73,7 @@ bool WriteNode::UpdateEntryWithEncryption( was_encrypted) { generated_specifics.CopyFrom(old_specifics); } else { - syncable::AddDefaultExtensionValue(type, &generated_specifics); + syncable::AddDefaultFieldValue(type, &generated_specifics); } // Does not change anything if underlying encrypted blob was already up // to date and encrypted with the default key. @@ -107,7 +107,7 @@ bool WriteNode::UpdateEntryWithEncryption( // else the server will try to do it for us. if (type == syncable::BOOKMARKS) { sync_pb::BookmarkSpecifics* bookmark_specifics = - generated_specifics.MutableExtension(sync_pb::bookmark); + generated_specifics.mutable_bookmark(); if (!entry->Get(syncable::IS_DIR)) bookmark_specifics->set_url(kEncryptedString); bookmark_specifics->set_title(kEncryptedString); @@ -176,7 +176,7 @@ void WriteNode::SetTitle(const std::wstring& title) { // TODO(zea): refactor bookmarks to not need this functionality. if (GetModelType() == syncable::BOOKMARKS) { sync_pb::EntitySpecifics specifics = GetEntitySpecifics(); - specifics.MutableExtension(sync_pb::bookmark)->set_title(new_legal_title); + specifics.mutable_bookmark()->set_title(new_legal_title); SetEntitySpecifics(specifics); // Does it's own encryption checking. } @@ -204,21 +204,21 @@ void WriteNode::SetURL(const GURL& url) { void WriteNode::SetAppSpecifics( const sync_pb::AppSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::app)->CopyFrom(new_value); + entity_specifics.mutable_app()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } void WriteNode::SetAutofillSpecifics( const sync_pb::AutofillSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::autofill)->CopyFrom(new_value); + entity_specifics.mutable_autofill()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } void WriteNode::SetAutofillProfileSpecifics( const sync_pb::AutofillProfileSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::autofill_profile)-> + entity_specifics.mutable_autofill_profile()-> CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } @@ -226,14 +226,14 @@ void WriteNode::SetAutofillProfileSpecifics( void WriteNode::SetBookmarkSpecifics( const sync_pb::BookmarkSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::bookmark)->CopyFrom(new_value); + entity_specifics.mutable_bookmark()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } void WriteNode::SetNigoriSpecifics( const sync_pb::NigoriSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::nigori)->CopyFrom(new_value); + entity_specifics.mutable_nigori()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } @@ -253,11 +253,11 @@ void WriteNode::SetPasswordSpecifics( syncable::PASSWORDS) { entity_specifics.CopyFrom(old_specifics); } else { - syncable::AddDefaultExtensionValue(syncable::PASSWORDS, + syncable::AddDefaultFieldValue(syncable::PASSWORDS, &entity_specifics); } sync_pb::PasswordSpecifics* password_specifics = - entity_specifics.MutableExtension(sync_pb::password); + entity_specifics.mutable_password(); // This will only update password_specifics if the underlying unencrypted blob // was different from |data| or was not encrypted with the proper passphrase. if (!cryptographer->Encrypt(data, password_specifics->mutable_encrypted())) { @@ -271,14 +271,14 @@ void WriteNode::SetPasswordSpecifics( void WriteNode::SetThemeSpecifics( const sync_pb::ThemeSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::theme)->CopyFrom(new_value); + entity_specifics.mutable_theme()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } void WriteNode::SetSessionSpecifics( const sync_pb::SessionSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::session)->CopyFrom(new_value); + entity_specifics.mutable_session()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } @@ -328,14 +328,14 @@ void WriteNode::ResetFromSpecifics() { void WriteNode::SetTypedUrlSpecifics( const sync_pb::TypedUrlSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::typed_url)->CopyFrom(new_value); + entity_specifics.mutable_typed_url()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } void WriteNode::SetExtensionSpecifics( const sync_pb::ExtensionSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::extension)->CopyFrom(new_value); + entity_specifics.mutable_extension()->CopyFrom(new_value); SetEntitySpecifics(entity_specifics); } @@ -398,12 +398,12 @@ bool WriteNode::InitByTagLookup(const std::string& tag) { void WriteNode::PutModelType(syncable::ModelType model_type) { // Set an empty specifics of the appropriate datatype. The presence - // of the specific extension will identify the model type. + // of the specific field will identify the model type. DCHECK(GetModelType() == model_type || GetModelType() == syncable::UNSPECIFIED); // Immutable once set. sync_pb::EntitySpecifics specifics; - syncable::AddDefaultExtensionValue(model_type, &specifics); + syncable::AddDefaultFieldValue(model_type, &specifics); SetEntitySpecifics(specifics); } diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc index 411a219..7c6d2cf 100644 --- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc @@ -451,7 +451,7 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest { sync_pb::EntitySpecifics specifics; AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); sync_pb::AutofillSpecifics* autofill_specifics = - specifics.MutableExtension(sync_pb::autofill); + specifics.mutable_autofill(); node.SetAutofillSpecifics(*autofill_specifics); return true; } @@ -469,7 +469,7 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest { sync_pb::EntitySpecifics specifics; AutofillProfileSyncableService::WriteAutofillProfile(profile, &specifics); sync_pb::AutofillProfileSpecifics* profile_specifics = - specifics.MutableExtension(sync_pb::autofill_profile); + specifics.mutable_autofill_profile(); node.SetAutofillProfileSpecifics(*profile_specifics); return true; } @@ -660,8 +660,7 @@ class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> { } sync_pb::EntitySpecifics entity_specifics; - entity_specifics.MutableExtension(sync_pb::autofill)-> - CopyFrom(new_autofill); + entity_specifics.mutable_autofill()->CopyFrom(new_autofill); { // Tell main thread we've started diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index e67b0c97..14ee672 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -176,7 +176,7 @@ class ProfileSyncServicePreferenceTest return NULL; const sync_pb::PreferenceSpecifics& specifics( - node.GetEntitySpecifics().GetExtension(sync_pb::preference)); + node.GetEntitySpecifics().preference()); JSONReader reader; return reader.JsonToValue(specifics.value(), false, false); @@ -267,7 +267,7 @@ TEST_F(ProfileSyncServicePreferenceTest, CreatePrefSyncData) { *pref->GetValue(), &sync_data)); EXPECT_EQ(std::string(prefs::kHomePage), sync_data.GetTag()); const sync_pb::PreferenceSpecifics& specifics(sync_data.GetSpecifics(). - GetExtension(sync_pb::preference)); + preference()); EXPECT_EQ(std::string(prefs::kHomePage), specifics.name()); base::JSONReader reader; diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index c724927..486cfd7 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -682,7 +682,7 @@ TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionDelete) { int64 node_id = model_associator_->GetSyncIdFromSessionTag( model_associator_->GetCurrentMachineTag()); sync_pb::EntitySpecifics deleted_specifics; - deleted_specifics.MutableExtension(sync_pb::session)->set_session_tag("tag"); + deleted_specifics.mutable_session()->set_session_tag("tag"); ASSERT_FALSE(notified_of_update_); { sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); diff --git a/chrome/browser/sync/protocol/app_notification_specifics.proto b/chrome/browser/sync/protocol/app_notification_specifics.proto index 46d0426..58436c7 100644 --- a/chrome/browser/sync/protocol/app_notification_specifics.proto +++ b/chrome/browser/sync/protocol/app_notification_specifics.proto @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of an app notification. // An App Notification, to be delivered from Chrome Apps to the @@ -44,6 +42,3 @@ message AppNotification { optional string link_text = 7; } -extend EntitySpecifics { - optional AppNotification app_notification = 45184; -} diff --git a/chrome/browser/sync/protocol/app_setting_specifics.proto b/chrome/browser/sync/protocol/app_setting_specifics.proto index 0d9e25d..d936c66 100644 --- a/chrome/browser/sync/protocol/app_setting_specifics.proto +++ b/chrome/browser/sync/protocol/app_setting_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,7 +16,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; import "extension_setting_specifics.proto"; // Properties of app setting sync objects; just an extension setting. @@ -24,6 +23,3 @@ message AppSettingSpecifics { optional ExtensionSettingSpecifics extension_setting = 1; } -extend EntitySpecifics { - optional AppSettingSpecifics app_setting = 103656; -} diff --git a/chrome/browser/sync/protocol/app_specifics.proto b/chrome/browser/sync/protocol/app_specifics.proto index 3a5e438..a7f09ec 100644 --- a/chrome/browser/sync/protocol/app_specifics.proto +++ b/chrome/browser/sync/protocol/app_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. // @@ -14,7 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; import "extension_specifics.proto"; // Settings related to push notifications for apps. @@ -59,6 +58,3 @@ message AppSpecifics { optional string page_ordinal = 4; } -extend EntitySpecifics { - optional AppSpecifics app = 48364; -} diff --git a/chrome/browser/sync/protocol/autofill_specifics.proto b/chrome/browser/sync/protocol/autofill_specifics.proto index 0e9aded..ac7bc51 100644 --- a/chrome/browser/sync/protocol/autofill_specifics.proto +++ b/chrome/browser/sync/protocol/autofill_specifics.proto @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of autofill sync objects. // An AutofillProfile. @@ -65,7 +63,3 @@ message AutofillSpecifics { // optional AutofillCreditCardSpecifics deprecated_credit_card = 6; } -extend EntitySpecifics { - optional AutofillSpecifics autofill = 31729; - optional AutofillProfileSpecifics autofill_profile = 63951; -} diff --git a/chrome/browser/sync/protocol/bookmark_specifics.proto b/chrome/browser/sync/protocol/bookmark_specifics.proto index 83b1693..c177511 100644 --- a/chrome/browser/sync/protocol/bookmark_specifics.proto +++ b/chrome/browser/sync/protocol/bookmark_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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of bookmark sync objects. message BookmarkSpecifics { optional string url = 1; @@ -23,6 +21,3 @@ message BookmarkSpecifics { optional string title = 3; } -extend EntitySpecifics { - optional BookmarkSpecifics bookmark = 32904; -} diff --git a/chrome/browser/sync/protocol/extension_setting_specifics.proto b/chrome/browser/sync/protocol/extension_setting_specifics.proto index ff9f029..62947c5 100644 --- a/chrome/browser/sync/protocol/extension_setting_specifics.proto +++ b/chrome/browser/sync/protocol/extension_setting_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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of extension setting sync objects. message ExtensionSettingSpecifics { // Id of the extension the setting is for. @@ -28,6 +26,3 @@ message ExtensionSettingSpecifics { optional string value = 3; } -extend EntitySpecifics { - optional ExtensionSettingSpecifics extension_setting = 96159; -} diff --git a/chrome/browser/sync/protocol/extension_specifics.proto b/chrome/browser/sync/protocol/extension_specifics.proto index 25b98a0..e3e1dfb 100644 --- a/chrome/browser/sync/protocol/extension_specifics.proto +++ b/chrome/browser/sync/protocol/extension_specifics.proto @@ -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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of extension sync objects. // // Merge policy: the settings for the higher version number win; in @@ -39,6 +37,3 @@ message ExtensionSpecifics { optional string name = 6; } -extend EntitySpecifics { - optional ExtensionSpecifics extension = 48119; -} diff --git a/chrome/browser/sync/protocol/nigori_specifics.proto b/chrome/browser/sync/protocol/nigori_specifics.proto index 1655223..50f5014 100644 --- a/chrome/browser/sync/protocol/nigori_specifics.proto +++ b/chrome/browser/sync/protocol/nigori_specifics.proto @@ -15,7 +15,6 @@ option retain_unknown_fields = true; package sync_pb; import "encryption.proto"; -import "sync.proto"; message NigoriKey { optional string name = 1; @@ -93,6 +92,3 @@ message NigoriSpecifics { repeated DeviceInformation device_information = 28; } -extend EntitySpecifics { - optional NigoriSpecifics nigori = 47745; -} diff --git a/chrome/browser/sync/protocol/password_specifics.proto b/chrome/browser/sync/protocol/password_specifics.proto index 49f1343..769914433 100644 --- a/chrome/browser/sync/protocol/password_specifics.proto +++ b/chrome/browser/sync/protocol/password_specifics.proto @@ -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. // @@ -15,7 +15,6 @@ option retain_unknown_fields = true; package sync_pb; import "encryption.proto"; -import "sync.proto"; // These are the properties that get serialized into the |encrypted| field of // PasswordSpecifics. @@ -40,6 +39,3 @@ message PasswordSpecifics { optional EncryptedData encrypted = 1; } -extend EntitySpecifics { - optional PasswordSpecifics password = 45873; -} diff --git a/chrome/browser/sync/protocol/preference_specifics.proto b/chrome/browser/sync/protocol/preference_specifics.proto index 72bc375..4827c5d 100644 --- a/chrome/browser/sync/protocol/preference_specifics.proto +++ b/chrome/browser/sync/protocol/preference_specifics.proto @@ -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. // @@ -14,14 +14,9 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of preference sync objects. message PreferenceSpecifics { optional string name = 1; optional string value = 2; } -extend EntitySpecifics { - optional PreferenceSpecifics preference = 37702; -} diff --git a/chrome/browser/sync/protocol/proto_enum_conversions.h b/chrome/browser/sync/protocol/proto_enum_conversions.h index 47e4772..7722f92 100644 --- a/chrome/browser/sync/protocol/proto_enum_conversions.h +++ b/chrome/browser/sync/protocol/proto_enum_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. @@ -9,6 +9,7 @@ // Keep this file in sync with the .proto files in this directory. #include "chrome/browser/sync/protocol/session_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" // Utility functions to get the string equivalent for some sync proto // enums. diff --git a/chrome/browser/sync/protocol/proto_value_conversions.cc b/chrome/browser/sync/protocol/proto_value_conversions.cc index 3885fc2..86b632e 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions.cc +++ b/chrome/browser/sync/protocol/proto_value_conversions.cc @@ -92,11 +92,11 @@ ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) { StringValue>(proto.field(), \ Value::CreateStringValue)) -#define SET_EXTENSION(ns, field, fn) \ - do { \ - if (specifics.HasExtension(ns::field)) { \ - value->Set(#field, fn(specifics.GetExtension(ns::field))); \ - } \ +#define SET_FIELD(field, fn) \ + do { \ + if (specifics.has_##field()) { \ + value->Set(#field, fn(specifics.field())); \ + } \ } while (0) // If you add another macro, don't forget to add an #undef at the end @@ -379,21 +379,21 @@ DictionaryValue* TypedUrlSpecificsToValue( DictionaryValue* EntitySpecificsToValue( const sync_pb::EntitySpecifics& specifics) { DictionaryValue* value = new DictionaryValue(); - SET_EXTENSION(sync_pb, app, AppSpecificsToValue); - 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); - SET_EXTENSION(sync_pb, bookmark, BookmarkSpecificsToValue); - SET_EXTENSION(sync_pb, extension, ExtensionSpecificsToValue); - SET_EXTENSION(sync_pb, extension_setting, ExtensionSettingSpecificsToValue); - SET_EXTENSION(sync_pb, nigori, NigoriSpecificsToValue); - SET_EXTENSION(sync_pb, password, PasswordSpecificsToValue); - SET_EXTENSION(sync_pb, preference, PreferenceSpecificsToValue); - SET_EXTENSION(sync_pb, search_engine, SearchEngineSpecificsToValue); - SET_EXTENSION(sync_pb, session, SessionSpecificsToValue); - SET_EXTENSION(sync_pb, theme, ThemeSpecificsToValue); - SET_EXTENSION(sync_pb, typed_url, TypedUrlSpecificsToValue); + SET_FIELD(app, AppSpecificsToValue); + SET_FIELD(app_notification, AppNotificationToValue); + SET_FIELD(app_setting, AppSettingSpecificsToValue); + SET_FIELD(autofill, AutofillSpecificsToValue); + SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); + SET_FIELD(bookmark, BookmarkSpecificsToValue); + SET_FIELD(extension, ExtensionSpecificsToValue); + SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); + SET_FIELD(nigori, NigoriSpecificsToValue); + SET_FIELD(password, PasswordSpecificsToValue); + SET_FIELD(preference, PreferenceSpecificsToValue); + SET_FIELD(search_engine, SearchEngineSpecificsToValue); + SET_FIELD(session, SessionSpecificsToValue); + SET_FIELD(theme, ThemeSpecificsToValue); + SET_FIELD(typed_url, TypedUrlSpecificsToValue); return value; } @@ -408,6 +408,6 @@ DictionaryValue* EntitySpecificsToValue( #undef SET_STR #undef SET_STR_REP -#undef SET_EXTENSION +#undef SET_FIELD } // namespace browser_sync diff --git a/chrome/browser/sync/protocol/proto_value_conversions.h b/chrome/browser/sync/protocol/proto_value_conversions.h index f15b06f..fb32326 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions.h +++ b/chrome/browser/sync/protocol/proto_value_conversions.h @@ -135,7 +135,7 @@ base::DictionaryValue* TypedUrlSpecificsToValue( // Any present extensions are mapped to sub-dictionary values with the // key equal to the extension name. base::DictionaryValue* EntitySpecificsToValue( - const sync_pb::EntitySpecifics& entity_specifics); + const sync_pb::EntitySpecifics& specifics); } // namespace browser_sync diff --git a/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc b/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc index de61897..699ead8 100644 --- a/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc +++ b/chrome/browser/sync/protocol/proto_value_conversions_unittest.cc @@ -162,25 +162,25 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { sync_pb::EntitySpecifics specifics; // Touch the extensions to make sure it shows up in the generated // value. -#define SET_EXTENSION(key) (void)specifics.MutableExtension(sync_pb::key) - - SET_EXTENSION(app); - SET_EXTENSION(app_notification); - SET_EXTENSION(app_setting); - SET_EXTENSION(autofill); - SET_EXTENSION(autofill_profile); - SET_EXTENSION(bookmark); - SET_EXTENSION(extension); - SET_EXTENSION(extension_setting); - SET_EXTENSION(nigori); - SET_EXTENSION(password); - SET_EXTENSION(preference); - SET_EXTENSION(search_engine); - SET_EXTENSION(session); - SET_EXTENSION(theme); - SET_EXTENSION(typed_url); - -#undef SET_EXTENSION +#define SET_FIELD(key) (void)specifics.mutable_##key() + + SET_FIELD(app); + SET_FIELD(app_notification); + SET_FIELD(app_setting); + SET_FIELD(autofill); + SET_FIELD(autofill_profile); + SET_FIELD(bookmark); + SET_FIELD(extension); + SET_FIELD(extension_setting); + SET_FIELD(nigori); + SET_FIELD(password); + SET_FIELD(preference); + SET_FIELD(search_engine); + SET_FIELD(session); + SET_FIELD(theme); + SET_FIELD(typed_url); + +#undef SET_FIELD scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE, diff --git a/chrome/browser/sync/protocol/search_engine_specifics.proto b/chrome/browser/sync/protocol/search_engine_specifics.proto index b593b1c..effaf99 100644 --- a/chrome/browser/sync/protocol/search_engine_specifics.proto +++ b/chrome/browser/sync/protocol/search_engine_specifics.proto @@ -14,8 +14,6 @@ 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. @@ -61,6 +59,3 @@ message SearchEngineSpecifics { optional string sync_guid = 18; } -extend EntitySpecifics { - optional SearchEngineSpecifics search_engine = 88610; -} diff --git a/chrome/browser/sync/protocol/session_specifics.proto b/chrome/browser/sync/protocol/session_specifics.proto index a4a94b3..9b59dd0 100644 --- a/chrome/browser/sync/protocol/session_specifics.proto +++ b/chrome/browser/sync/protocol/session_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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - message SessionSpecifics { // Unique id for the client. optional string session_tag = 1; @@ -111,6 +109,3 @@ message TabNavigation { optional PageTransitionQualifier navigation_qualifier = 7; } -extend EntitySpecifics { - optional SessionSpecifics session = 50119; -} diff --git a/chrome/browser/sync/protocol/sync.proto b/chrome/browser/sync/protocol/sync.proto index bc866fe..d1aea72 100644 --- a/chrome/browser/sync/protocol/sync.proto +++ b/chrome/browser/sync/protocol/sync.proto @@ -14,6 +14,20 @@ option retain_unknown_fields = true; package sync_pb; +import "app_notification_specifics.proto"; +import "app_setting_specifics.proto"; +import "app_specifics.proto"; +import "autofill_specifics.proto"; +import "bookmark_specifics.proto"; +import "extension_setting_specifics.proto"; +import "extension_specifics.proto"; +import "nigori_specifics.proto"; +import "password_specifics.proto"; +import "preference_specifics.proto"; +import "search_engine_specifics.proto"; +import "session_specifics.proto"; +import "theme_specifics.proto"; +import "typed_url_specifics.proto"; import "encryption.proto"; import "sync_enums.proto"; import "client_commands.proto"; @@ -42,11 +56,10 @@ message EntitySpecifics { // EntitySpecifics. First, pick a non-colliding tag number by // picking a revision number of one of your past commits // to src.chromium.org. Then, in a different protocol buffer - // definition that includes this, do the following: + // definition, define your message type, and add an optional field + // to the list below using the unique tag value you selected. // - // extend EntitySpecifics { - // MyDatatypeSpecifics my_datatype = 32222; - // } + // optional MyDatatypeSpecifics my_datatype = 32222; // // where: // - 32222 is the non-colliding tag number you picked earlier. @@ -57,10 +70,32 @@ message EntitySpecifics { // datatype specifics from the code. // // Server implementations are obligated to preserve the contents of - // EntitySpecifics when it contains unrecognized extensions. In this + // EntitySpecifics when it contains unrecognized fields. In this // way, it is possible to add new datatype fields without having // to update the server. - extensions 30000 to max; + // + // Note: The tag selection process is based on legacy versions of the + // protocol which used protobuf extensions. We have kept the process + // consistent as the old values cannot change. The 5+ digit nature of the + // tags also makes them recognizable (individually and collectively) from + // noise in logs and debugging contexts, and creating a divergent subset of + // tags would only make things a bit more confusing. + + optional AutofillSpecifics autofill = 31729; + optional BookmarkSpecifics bookmark = 32904; + optional PreferenceSpecifics preference = 37702; + optional TypedUrlSpecifics typed_url = 40781; + optional ThemeSpecifics theme = 41210; + optional AppNotification app_notification = 45184; + optional PasswordSpecifics password = 45873; + optional NigoriSpecifics nigori = 47745; + optional ExtensionSpecifics extension = 48119; + optional AppSpecifics app = 48364; + optional SessionSpecifics session = 50119; + optional AutofillProfileSpecifics autofill_profile = 63951; + optional SearchEngineSpecifics search_engine = 88610; + optional ExtensionSettingSpecifics extension_setting = 96159; + optional AppSettingSpecifics app_setting = 103656; } message SyncEntity { @@ -318,7 +353,7 @@ message GetUpdatesCallerInfo { message DataTypeProgressMarker { // An integer identifying the data type whose progress is tracked by this // marker. The legitimate values of this field correspond to the protobuf - // field numbers of all EntitySpecifics extensions supported by the server. + // field numbers of all EntitySpecifics fields supported by the server. // These values are externally declared in per-datatype .proto files. optional int32 data_type_id = 1; @@ -374,14 +409,14 @@ message GetUpdatesMessage { // Indicates whether related folders should be fetched. optional bool fetch_folders = 3 [default = true]; - // The presence of an individual EntitySpecifics extension indicates that the - // client requests sync object types associated with that extension. This - // determination depends only on the presence of the extension field, not its - // contents -- thus clients should send empty extension messages. For - // backwards compatibility only bookmark objects will be sent to the client - // should requested_types not be present. + // The presence of an individual EntitySpecifics field indicates that the + // client requests sync object types associated with that field. This + // determination depends only on the presence of the field, not its + // contents -- thus clients should send empty messages as the field value. + // For backwards compatibility only bookmark objects will be sent to the + // client should requested_types not be present. // - // requested_types may contain multiple EntitySpecifics extensions -- in this + // requested_types may contain multiple EntitySpecifics fields -- in this // event, the server will return items of all the indicated types. // // requested_types has been deprecated; clients should use diff --git a/chrome/browser/sync/protocol/theme_specifics.proto b/chrome/browser/sync/protocol/theme_specifics.proto index eb864ff..f8318e8 100644 --- a/chrome/browser/sync/protocol/theme_specifics.proto +++ b/chrome/browser/sync/protocol/theme_specifics.proto @@ -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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of theme sync objects. message ThemeSpecifics { // If set, we're using a custom theme and all custom_* fields should be @@ -39,6 +37,3 @@ message ThemeSpecifics { optional string custom_theme_update_url = 5; } -extend EntitySpecifics { - optional ThemeSpecifics theme = 41210; -} diff --git a/chrome/browser/sync/protocol/typed_url_specifics.proto b/chrome/browser/sync/protocol/typed_url_specifics.proto index 4bc93e3..1f8a4b8 100644 --- a/chrome/browser/sync/protocol/typed_url_specifics.proto +++ b/chrome/browser/sync/protocol/typed_url_specifics.proto @@ -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. // @@ -14,8 +14,6 @@ option retain_unknown_fields = true; package sync_pb; -import "sync.proto"; - // Properties of typed_url sync objects - fields correspond to similarly named // fields in history::URLRow. message TypedUrlSpecifics { @@ -41,7 +39,3 @@ message TypedUrlSpecifics { // arrays must be the same length. repeated int32 visit_transitions = 8 [packed=true]; } - -extend EntitySpecifics { - optional TypedUrlSpecifics typed_url = 40781; -} diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc index 65c3278..7c4d748 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.cc +++ b/chrome/browser/sync/syncable/directory_backing_store.cc @@ -569,7 +569,7 @@ ModelType DirectoryBackingStore::ModelIdToModelTypeEnum( // static string DirectoryBackingStore::ModelTypeEnumToModelId(ModelType model_type) { sync_pb::EntitySpecifics specifics; - syncable::AddDefaultExtensionValue(model_type, &specifics); + syncable::AddDefaultFieldValue(model_type, &specifics); return specifics.SerializeAsString(); } @@ -680,7 +680,7 @@ void EncodeBookmarkURLAndFavicon(sql::Statement* old_value_query, if (old_is_bookmark_object) { sync_pb::BookmarkSpecifics* bookmark_data = - mutable_new_value->MutableExtension(sync_pb::bookmark); + mutable_new_value->mutable_bookmark(); if (!old_is_dir) { bookmark_data->set_url(old_url); bookmark_data->set_favicon(old_favicon); @@ -884,7 +884,7 @@ bool DirectoryBackingStore::MigrateVersion74To75() { // time we check for updates. sync_pb::DataTypeProgressMarker progress_marker; progress_marker.set_data_type_id( - GetExtensionFieldNumberFromModelType(type)); + GetSpecificsFieldNumberFromModelType(type)); progress_marker.set_timestamp_token_for_migration(query.ColumnInt64(1)); std::string progress_blob; progress_marker.SerializeToString(&progress_blob); diff --git a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc index aca6641..00ad0c4 100644 --- a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc +++ b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc @@ -1594,15 +1594,13 @@ TEST_F(DirectoryBackingStoreTest, MigrateVersion68To69) { ASSERT_EQ("s_ID_2", s.ColumnString(3)); sync_pb::EntitySpecifics specifics; specifics.ParseFromArray(s.ColumnBlob(4), s.ColumnByteLength(4)); - ASSERT_TRUE(specifics.HasExtension(sync_pb::bookmark)); - ASSERT_EQ("http://www.google.com/", - specifics.GetExtension(sync_pb::bookmark).url()); - ASSERT_EQ("AASGASGA", specifics.GetExtension(sync_pb::bookmark).favicon()); + ASSERT_TRUE(specifics.has_bookmark()); + ASSERT_EQ("http://www.google.com/", specifics.bookmark().url()); + ASSERT_EQ("AASGASGA", specifics.bookmark().favicon()); specifics.ParseFromArray(s.ColumnBlob(5), s.ColumnByteLength(5)); - ASSERT_TRUE(specifics.HasExtension(sync_pb::bookmark)); - ASSERT_EQ("http://www.google.com/2", - specifics.GetExtension(sync_pb::bookmark).url()); - ASSERT_EQ("ASADGADGADG", specifics.GetExtension(sync_pb::bookmark).favicon()); + ASSERT_TRUE(specifics.has_bookmark()); + ASSERT_EQ("http://www.google.com/2", specifics.bookmark().url()); + ASSERT_EQ("ASADGADGADG", specifics.bookmark().favicon()); ASSERT_FALSE(s.Step()); } @@ -2060,44 +2058,42 @@ TEST_P(MigrationTest, ToCurrentVersion) { EXPECT_TRUE((*it)->ref(IS_DIR)); EXPECT_TRUE((*it)->ref(SERVER_IS_DIR)); EXPECT_FALSE( - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); + (*it)->ref(SPECIFICS).bookmark().has_url()); EXPECT_FALSE( - (*it)->ref(SERVER_SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); + (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); EXPECT_FALSE( - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_favicon()); - EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS). - GetExtension(sync_pb::bookmark).has_favicon()); + (*it)->ref(SPECIFICS).bookmark().has_favicon()); + EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); ASSERT_TRUE(++it != index.end()); ASSERT_EQ(7, (*it)->ref(META_HANDLE)); EXPECT_EQ("google_chrome", (*it)->ref(UNIQUE_SERVER_TAG)); - EXPECT_FALSE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_FALSE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); ASSERT_TRUE(++it != index.end()); ASSERT_EQ(8, (*it)->ref(META_HANDLE)); EXPECT_EQ("google_chrome_bookmarks", (*it)->ref(UNIQUE_SERVER_TAG)); - EXPECT_TRUE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); ASSERT_TRUE(++it != index.end()); ASSERT_EQ(9, (*it)->ref(META_HANDLE)); EXPECT_EQ("bookmark_bar", (*it)->ref(UNIQUE_SERVER_TAG)); - EXPECT_TRUE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); ASSERT_TRUE(++it != index.end()); ASSERT_EQ(10, (*it)->ref(META_HANDLE)); EXPECT_FALSE((*it)->ref(IS_DEL)); - EXPECT_TRUE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_FALSE((*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); + EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); + EXPECT_FALSE((*it)->ref(SPECIFICS).bookmark().has_url()); EXPECT_FALSE( - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_favicon()); + (*it)->ref(SPECIFICS).bookmark().has_favicon()); EXPECT_FALSE( - (*it)->ref(SERVER_SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); - EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS). - GetExtension(sync_pb::bookmark).has_favicon()); + (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); + EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); EXPECT_EQ("other_bookmarks", (*it)->ref(UNIQUE_SERVER_TAG)); EXPECT_EQ("Other Bookmarks", (*it)->ref(NON_UNIQUE_NAME)); EXPECT_EQ("Other Bookmarks", (*it)->ref(SERVER_NON_UNIQUE_NAME)); @@ -2106,16 +2102,16 @@ TEST_P(MigrationTest, ToCurrentVersion) { ASSERT_EQ(11, (*it)->ref(META_HANDLE)); EXPECT_FALSE((*it)->ref(IS_DEL)); EXPECT_FALSE((*it)->ref(IS_DIR)); - EXPECT_TRUE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); EXPECT_EQ("http://dev.chromium.org/", - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).url()); + (*it)->ref(SPECIFICS).bookmark().url()); EXPECT_EQ("AGATWA", - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).favicon()); + (*it)->ref(SPECIFICS).bookmark().favicon()); EXPECT_EQ("http://dev.chromium.org/other", - (*it)->ref(SERVER_SPECIFICS).GetExtension(sync_pb::bookmark).url()); + (*it)->ref(SERVER_SPECIFICS).bookmark().url()); EXPECT_EQ("AFAGVASF", - (*it)->ref(SERVER_SPECIFICS).GetExtension(sync_pb::bookmark).favicon()); + (*it)->ref(SERVER_SPECIFICS).bookmark().favicon()); EXPECT_EQ("", (*it)->ref(UNIQUE_SERVER_TAG)); EXPECT_EQ("Home (The Chromium Projects)", (*it)->ref(NON_UNIQUE_NAME)); EXPECT_EQ("Home (The Chromium Projects)", (*it)->ref(SERVER_NON_UNIQUE_NAME)); @@ -2126,16 +2122,15 @@ TEST_P(MigrationTest, ToCurrentVersion) { EXPECT_TRUE((*it)->ref(IS_DIR)); EXPECT_EQ("Extra Bookmarks", (*it)->ref(NON_UNIQUE_NAME)); EXPECT_EQ("Extra Bookmarks", (*it)->ref(SERVER_NON_UNIQUE_NAME)); - EXPECT_TRUE((*it)->ref(SPECIFICS).HasExtension(sync_pb::bookmark)); - EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).HasExtension(sync_pb::bookmark)); + EXPECT_TRUE((*it)->ref(SPECIFICS).has_bookmark()); + EXPECT_TRUE((*it)->ref(SERVER_SPECIFICS).has_bookmark()); EXPECT_FALSE( - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); + (*it)->ref(SPECIFICS).bookmark().has_url()); EXPECT_FALSE( - (*it)->ref(SERVER_SPECIFICS).GetExtension(sync_pb::bookmark).has_url()); + (*it)->ref(SERVER_SPECIFICS).bookmark().has_url()); EXPECT_FALSE( - (*it)->ref(SPECIFICS).GetExtension(sync_pb::bookmark).has_favicon()); - EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS). - GetExtension(sync_pb::bookmark).has_favicon()); + (*it)->ref(SPECIFICS).bookmark().has_favicon()); + EXPECT_FALSE((*it)->ref(SERVER_SPECIFICS).bookmark().has_favicon()); ASSERT_TRUE(++it != index.end()); ASSERT_EQ(13, (*it)->ref(META_HANDLE)); diff --git a/chrome/browser/sync/syncable/model_type.cc b/chrome/browser/sync/syncable/model_type.cc index 7faf4523..311ac73 100644 --- a/chrome/browser/sync/syncable/model_type.cc +++ b/chrome/browser/sync/syncable/model_type.cc @@ -25,115 +25,115 @@ namespace syncable { -void AddDefaultExtensionValue(syncable::ModelType datatype, +void AddDefaultFieldValue(syncable::ModelType datatype, sync_pb::EntitySpecifics* specifics) { switch (datatype) { case BOOKMARKS: - specifics->MutableExtension(sync_pb::bookmark); + specifics->mutable_bookmark(); break; case PASSWORDS: - specifics->MutableExtension(sync_pb::password); + specifics->mutable_password(); break; case PREFERENCES: - specifics->MutableExtension(sync_pb::preference); + specifics->mutable_preference(); break; case AUTOFILL: - specifics->MutableExtension(sync_pb::autofill); + specifics->mutable_autofill(); break; case AUTOFILL_PROFILE: - specifics->MutableExtension(sync_pb::autofill_profile); + specifics->mutable_autofill_profile(); break; case THEMES: - specifics->MutableExtension(sync_pb::theme); + specifics->mutable_theme(); break; case TYPED_URLS: - specifics->MutableExtension(sync_pb::typed_url); + specifics->mutable_typed_url(); break; case EXTENSIONS: - specifics->MutableExtension(sync_pb::extension); + specifics->mutable_extension(); break; case NIGORI: - specifics->MutableExtension(sync_pb::nigori); + specifics->mutable_nigori(); break; case SEARCH_ENGINES: - specifics->MutableExtension(sync_pb::search_engine); + specifics->mutable_search_engine(); break; case SESSIONS: - specifics->MutableExtension(sync_pb::session); + specifics->mutable_session(); break; case APPS: - specifics->MutableExtension(sync_pb::app); + specifics->mutable_app(); break; case APP_SETTINGS: - specifics->MutableExtension(sync_pb::app_setting); + specifics->mutable_app_setting(); break; case EXTENSION_SETTINGS: - specifics->MutableExtension(sync_pb::extension_setting); + specifics->mutable_extension_setting(); break; case APP_NOTIFICATIONS: - specifics->MutableExtension(sync_pb::app_notification); + specifics->mutable_app_notification(); break; default: NOTREACHED() << "No known extension for model type."; } } -ModelType GetModelTypeFromExtensionFieldNumber(int field_number) { +ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) { for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { ModelType model_type = ModelTypeFromInt(i); - if (GetExtensionFieldNumberFromModelType(model_type) == field_number) + if (GetSpecificsFieldNumberFromModelType(model_type) == field_number) return model_type; } NOTREACHED(); return UNSPECIFIED; } -int GetExtensionFieldNumberFromModelType(ModelType model_type) { +int GetSpecificsFieldNumberFromModelType(ModelType model_type) { switch (model_type) { case BOOKMARKS: - return sync_pb::kBookmarkFieldNumber; + return sync_pb::EntitySpecifics::kBookmarkFieldNumber; break; case PASSWORDS: - return sync_pb::kPasswordFieldNumber; + return sync_pb::EntitySpecifics::kPasswordFieldNumber; break; case PREFERENCES: - return sync_pb::kPreferenceFieldNumber; + return sync_pb::EntitySpecifics::kPreferenceFieldNumber; break; case AUTOFILL: - return sync_pb::kAutofillFieldNumber; + return sync_pb::EntitySpecifics::kAutofillFieldNumber; break; case AUTOFILL_PROFILE: - return sync_pb::kAutofillProfileFieldNumber; + return sync_pb::EntitySpecifics::kAutofillProfileFieldNumber; break; case THEMES: - return sync_pb::kThemeFieldNumber; + return sync_pb::EntitySpecifics::kThemeFieldNumber; break; case TYPED_URLS: - return sync_pb::kTypedUrlFieldNumber; + return sync_pb::EntitySpecifics::kTypedUrlFieldNumber; break; case EXTENSIONS: - return sync_pb::kExtensionFieldNumber; + return sync_pb::EntitySpecifics::kExtensionFieldNumber; break; case NIGORI: - return sync_pb::kNigoriFieldNumber; + return sync_pb::EntitySpecifics::kNigoriFieldNumber; break; case SEARCH_ENGINES: - return sync_pb::kSearchEngineFieldNumber; + return sync_pb::EntitySpecifics::kSearchEngineFieldNumber; break; case SESSIONS: - return sync_pb::kSessionFieldNumber; + return sync_pb::EntitySpecifics::kSessionFieldNumber; break; case APPS: - return sync_pb::kAppFieldNumber; + return sync_pb::EntitySpecifics::kAppFieldNumber; break; case APP_SETTINGS: - return sync_pb::kAppSettingFieldNumber; + return sync_pb::EntitySpecifics::kAppSettingFieldNumber; break; case EXTENSION_SETTINGS: - return sync_pb::kExtensionSettingFieldNumber; + return sync_pb::EntitySpecifics::kExtensionSettingFieldNumber; break; case APP_NOTIFICATIONS: - return sync_pb::kAppNotificationFieldNumber; + return sync_pb::EntitySpecifics::kAppNotificationFieldNumber; break; default: NOTREACHED() << "No known extension for model type."; @@ -176,49 +176,49 @@ ModelType GetModelType(const sync_pb::SyncEntity& sync_pb_entity) { } ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { - if (specifics.HasExtension(sync_pb::bookmark)) + if (specifics.has_bookmark()) return BOOKMARKS; - if (specifics.HasExtension(sync_pb::password)) + if (specifics.has_password()) return PASSWORDS; - if (specifics.HasExtension(sync_pb::preference)) + if (specifics.has_preference()) return PREFERENCES; - if (specifics.HasExtension(sync_pb::autofill)) + if (specifics.has_autofill()) return AUTOFILL; - if (specifics.HasExtension(sync_pb::autofill_profile)) + if (specifics.has_autofill_profile()) return AUTOFILL_PROFILE; - if (specifics.HasExtension(sync_pb::theme)) + if (specifics.has_theme()) return THEMES; - if (specifics.HasExtension(sync_pb::typed_url)) + if (specifics.has_typed_url()) return TYPED_URLS; - if (specifics.HasExtension(sync_pb::extension)) + if (specifics.has_extension()) return EXTENSIONS; - if (specifics.HasExtension(sync_pb::nigori)) + if (specifics.has_nigori()) return NIGORI; - if (specifics.HasExtension(sync_pb::app)) + if (specifics.has_app()) return APPS; - if (specifics.HasExtension(sync_pb::search_engine)) + if (specifics.has_search_engine()) return SEARCH_ENGINES; - if (specifics.HasExtension(sync_pb::session)) + if (specifics.has_session()) return SESSIONS; - if (specifics.HasExtension(sync_pb::app_setting)) + if (specifics.has_app_setting()) return APP_SETTINGS; - if (specifics.HasExtension(sync_pb::extension_setting)) + if (specifics.has_extension_setting()) return EXTENSION_SETTINGS; - if (specifics.HasExtension(sync_pb::app_notification)) + if (specifics.has_app_notification()) return APP_NOTIFICATIONS; return UNSPECIFIED; diff --git a/chrome/browser/sync/syncable/model_type.h b/chrome/browser/sync/syncable/model_type.h index 506de66..115d5a0 100644 --- a/chrome/browser/sync/syncable/model_type.h +++ b/chrome/browser/sync/syncable/model_type.h @@ -44,7 +44,7 @@ enum ModelType { // The model types declared before here are somewhat special, as they // they do not correspond to any browser data model. The remaining types // are bona fide model types; all have a related browser data model and - // can be represented in the protocol using an extension to the + // can be represented in the protocol using a specific Message type in the // EntitySpecifics protocol buffer. // // A bookmark folder or a bookmark URL object. @@ -101,16 +101,16 @@ inline ModelType ModelTypeFromInt(int i) { return static_cast<ModelType>(i); } -void AddDefaultExtensionValue(syncable::ModelType datatype, - sync_pb::EntitySpecifics* specifics); +void AddDefaultFieldValue(syncable::ModelType datatype, + sync_pb::EntitySpecifics* specifics); // Extract the model type of a SyncEntity protocol buffer. ModelType is a // local concept: the enum is not in the protocol. The SyncEntity's ModelType -// is inferred from the presence of particular datatype extensions in the +// is inferred from the presence of particular datatype field in the // entity specifics. ModelType GetModelType(const sync_pb::SyncEntity& sync_entity); -// Extract the model type from an EntitySpecifics extension. Note that there +// Extract the model type from an EntitySpecifics field. Note that there // are some ModelTypes (like TOP_LEVEL_FOLDER) that can't be inferred this way; // prefer using GetModelType where possible. ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics); @@ -120,12 +120,12 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics); bool ShouldMaintainPosition(ModelType model_type); // Determine a model type from the field number of its associated -// EntitySpecifics extension. -ModelType GetModelTypeFromExtensionFieldNumber(int field_number); +// EntitySpecifics field. +ModelType GetModelTypeFromSpecificsFieldNumber(int field_number); -// Return the field number of the EntitySpecifics extension associated with +// Return the field number of the EntitySpecifics field associated with // a model type. -int GetExtensionFieldNumberFromModelType(ModelType model_type); +int GetSpecificsFieldNumberFromModelType(ModelType model_type); // TODO(sync): The functions below badly need some cleanup. diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index ce2d8bf..48d50a8 100644 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -456,7 +456,7 @@ Directory::PersistedKernelInfo::~PersistedKernelInfo() {} void Directory::PersistedKernelInfo::reset_download_progress( ModelType model_type) { download_progress[model_type].set_data_type_id( - GetExtensionFieldNumberFromModelType(model_type)); + GetSpecificsFieldNumberFromModelType(model_type)); // An empty-string token indicates no prior knowledge. download_progress[model_type].set_token(std::string()); } diff --git a/chrome/browser/sync/syncable/syncable_unittest.cc b/chrome/browser/sync/syncable/syncable_unittest.cc index 1815408..3eb2eff 100644 --- a/chrome/browser/sync/syncable/syncable_unittest.cc +++ b/chrome/browser/sync/syncable/syncable_unittest.cc @@ -64,9 +64,8 @@ void PutDataAsBookmarkFavicon(WriteTransaction* wtrans, const char* bytes, size_t bytes_length) { sync_pb::EntitySpecifics specifics; - specifics.MutableExtension(sync_pb::bookmark)->set_url("http://demo/"); - specifics.MutableExtension(sync_pb::bookmark)->set_favicon(bytes, - bytes_length); + specifics.mutable_bookmark()->set_url("http://demo/"); + specifics.mutable_bookmark()->set_favicon(bytes, bytes_length); e->Put(SPECIFICS, specifics); } @@ -75,11 +74,10 @@ void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans, const char* bytes, size_t bytes_length) { ASSERT_TRUE(e->good()); - ASSERT_TRUE(e->Get(SPECIFICS).HasExtension(sync_pb::bookmark)); - ASSERT_EQ("http://demo/", - e->Get(SPECIFICS).GetExtension(sync_pb::bookmark).url()); + ASSERT_TRUE(e->Get(SPECIFICS).has_bookmark()); + ASSERT_EQ("http://demo/", e->Get(SPECIFICS).bookmark().url()); ASSERT_EQ(std::string(bytes, bytes_length), - e->Get(SPECIFICS).GetExtension(sync_pb::bookmark).favicon()); + e->Get(SPECIFICS).bookmark().favicon()); } } // namespace @@ -531,11 +529,11 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsMetahandlesToPurge) { e.Put(IS_UNSYNCED, true); sync_pb::EntitySpecifics specs; if (i % 2 == 0) { - AddDefaultExtensionValue(BOOKMARKS, &specs); + AddDefaultFieldValue(BOOKMARKS, &specs); expected_purges.insert(e.Get(META_HANDLE)); all_handles.insert(e.Get(META_HANDLE)); } else { - AddDefaultExtensionValue(PREFERENCES, &specs); + AddDefaultFieldValue(PREFERENCES, &specs); all_handles.insert(e.Get(META_HANDLE)); } e.Put(SPECIFICS, specs); @@ -626,9 +624,9 @@ TEST_F(SyncableDirectoryTest, TestPurgeEntriesWithTypeIn) { sync_pb::EntitySpecifics bookmark_specs; sync_pb::EntitySpecifics autofill_specs; sync_pb::EntitySpecifics preference_specs; - AddDefaultExtensionValue(BOOKMARKS, &bookmark_specs); - AddDefaultExtensionValue(PREFERENCES, &preference_specs); - AddDefaultExtensionValue(AUTOFILL, &autofill_specs); + AddDefaultFieldValue(BOOKMARKS, &bookmark_specs); + AddDefaultFieldValue(PREFERENCES, &preference_specs); + AddDefaultFieldValue(AUTOFILL, &autofill_specs); dir_->set_initial_sync_ended_for_type(BOOKMARKS, true); dir_->set_initial_sync_ended_for_type(PREFERENCES, true); dir_->set_initial_sync_ended_for_type(AUTOFILL, true); @@ -1200,8 +1198,8 @@ TEST_F(SyncableDirectoryTest, TestSimpleFieldsPreservedDuringSaveChanges) { create.Put(IS_UNSYNCED, true); update.Put(IS_UNAPPLIED_UPDATE, true); sync_pb::EntitySpecifics specifics; - specifics.MutableExtension(sync_pb::bookmark)->set_favicon("PNG"); - specifics.MutableExtension(sync_pb::bookmark)->set_url("http://nowhere"); + specifics.mutable_bookmark()->set_favicon("PNG"); + specifics.mutable_bookmark()->set_url("http://nowhere"); create.Put(SPECIFICS, specifics); create_pre_save = create.GetKernelCopy(); update_pre_save = update.GetKernelCopy(); @@ -1372,7 +1370,7 @@ TEST_F(SyncableDirectoryTest, TestSaveChangesFailureWithPurge) { e1.Put(IS_DIR, true); e1.Put(ID, TestIdFactory::FromNumber(101)); sync_pb::EntitySpecifics bookmark_specs; - AddDefaultExtensionValue(BOOKMARKS, &bookmark_specs); + AddDefaultFieldValue(BOOKMARKS, &bookmark_specs); e1.Put(SPECIFICS, bookmark_specs); e1.Put(SERVER_SPECIFICS, bookmark_specs); e1.Put(ID, TestIdFactory::FromNumber(101)); @@ -1411,7 +1409,7 @@ TEST_F(SyncableDirectoryTest, GetModelType) { break; } sync_pb::EntitySpecifics specifics; - AddDefaultExtensionValue(datatype, &specifics); + AddDefaultFieldValue(datatype, &specifics); WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); diff --git a/chrome/browser/sync/test/engine/mock_connection_manager.cc b/chrome/browser/sync/test/engine/mock_connection_manager.cc index b32aa21..0b2e2e4 100644 --- a/chrome/browser/sync/test/engine/mock_connection_manager.cc +++ b/chrome/browser/sync/test/engine/mock_connection_manager.cc @@ -190,9 +190,9 @@ void MockConnectionManager::AddDefaultBookmarkData(sync_pb::SyncEntity* entity, } } else { entity->set_folder(is_folder); - entity->mutable_specifics()->MutableExtension(sync_pb::bookmark); + entity->mutable_specifics()->mutable_bookmark(); if (!is_folder) { - entity->mutable_specifics()->MutableExtension(sync_pb::bookmark)-> + entity->mutable_specifics()->mutable_bookmark()-> set_url("http://google.com"); } } @@ -617,7 +617,7 @@ bool MockConnectionManager::IsModelTypePresentInSpecifics( const google::protobuf::RepeatedPtrField< sync_pb::DataTypeProgressMarker>& filter, syncable::ModelType value) { - int data_type_id = syncable::GetExtensionFieldNumberFromModelType(value); + int data_type_id = syncable::GetSpecificsFieldNumberFromModelType(value); for (int i = 0; i < filter.size(); ++i) { if (filter.Get(i).data_type_id() == data_type_id) { return true; @@ -631,7 +631,7 @@ sync_pb::DataTypeProgressMarker const* const google::protobuf::RepeatedPtrField< sync_pb::DataTypeProgressMarker>& filter, syncable::ModelType value) { - int data_type_id = syncable::GetExtensionFieldNumberFromModelType(value); + int data_type_id = syncable::GetSpecificsFieldNumberFromModelType(value); for (int i = 0; i < filter.size(); ++i) { if (filter.Get(i).data_type_id() == data_type_id) { return &(filter.Get(i)); diff --git a/chrome/browser/sync/test/engine/proto_extension_validator.h b/chrome/browser/sync/test/engine/proto_extension_validator.h deleted file mode 100644 index 747bf3d..0000000 --- a/chrome/browser/sync/test/engine/proto_extension_validator.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2010 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. - -// A test utility that makes it easy to assert the exact presence of -// protobuf extensions in an extensible message. Example code: -// -// sync_pb::EntitySpecifics value; // Set up a test value. -// value.MutableExtension(sync_pb::bookmark); -// -// ProtoExtensionValidator<sync_pb::EntitySpecifics> good_expectation(value); -// good_expectation.ExpectHasExtension(sync_pb::bookmark); -// good_expectation.ExpectHasNoOtherFieldsOrExtensions(); -// -// ProtoExtensionValidator<sync_pb::EntitySpecifics> bad_expectation(value); -// bad_expectation.ExpectHasExtension(sync_pb::preference); // Fails, no pref -// bad_expectation.ExpectHasNoOtherFieldsOrExtensions(); // Fails, bookmark - -#ifndef CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ -#define CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ -#pragma once - -#include "base/string_util.h" -#include "chrome/browser/sync/test/engine/syncer_command_test.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace browser_sync { - -template<typename MessageType> -class ProtoExtensionValidator { - public: - explicit ProtoExtensionValidator(const MessageType& proto) - : proto_(proto) { - } - template<typename ExtensionTokenType> - void ExpectHasExtension(ExtensionTokenType token) { - EXPECT_TRUE(proto_.HasExtension(token)) - << "Proto failed to contain expected extension"; - proto_.ClearExtension(token); - EXPECT_FALSE(proto_.HasExtension(token)); - } - void ExpectNoOtherFieldsOrExtensions() { - EXPECT_EQ(MessageType::default_instance().SerializeAsString(), - proto_.SerializeAsString()) - << "Proto contained additional unexpected extensions."; - } - - private: - MessageType proto_; - DISALLOW_COPY_AND_ASSIGN(ProtoExtensionValidator); -}; - -} // namespace browser_sync - -#endif // CHROME_BROWSER_SYNC_TEST_ENGINE_PROTO_EXTENSION_VALIDATOR_H_ diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index 9d8c143..9855ecc 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc @@ -641,7 +641,7 @@ void SyncTest::TriggerMigrationDoneError( path.append( base::StringPrintf( "%ctype=%d", joiner, - syncable::GetExtensionFieldNumberFromModelType(it.Get()))); + syncable::GetSpecificsFieldNumberFromModelType(it.Get()))); joiner = '&'; } ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); diff --git a/chrome/browser/webdata/autocomplete_syncable_service.cc b/chrome/browser/webdata/autocomplete_syncable_service.cc index b2b2ce7..64ee484 100644 --- a/chrome/browser/webdata/autocomplete_syncable_service.cc +++ b/chrome/browser/webdata/autocomplete_syncable_service.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. @@ -10,6 +10,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/api/sync_error.h" #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/webdata/autofill_table.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_database.h" @@ -193,10 +194,10 @@ SyncError AutocompleteSyncableService::ProcessSyncChanges( CreateOrUpdateEntry(i->sync_data(), db_entries.get(), &new_entries); break; case SyncChange::ACTION_DELETE: { - DCHECK(i->sync_data().GetSpecifics().HasExtension(sync_pb::autofill)) + DCHECK(i->sync_data().GetSpecifics().has_autofill()) << "Autofill specifics data not present on delete!"; const sync_pb::AutofillSpecifics& autofill = - i->sync_data().GetSpecifics().GetExtension(sync_pb::autofill); + i->sync_data().GetSpecifics().autofill(); if (autofill.has_value()) { list_processing_error = AutofillEntryDelete(autofill); } else { @@ -265,7 +266,7 @@ void AutocompleteSyncableService::CreateOrUpdateEntry( std::vector<AutofillEntry>* new_entries) { const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); const sync_pb::AutofillSpecifics& autofill_specifics( - specifics.GetExtension(sync_pb::autofill)); + specifics.autofill()); if (!autofill_specifics.has_value()) { DLOG(WARNING) @@ -308,7 +309,7 @@ void AutocompleteSyncableService::CreateOrUpdateEntry( void AutocompleteSyncableService::WriteAutofillEntry( const AutofillEntry& entry, sync_pb::EntitySpecifics* autofill_specifics) { sync_pb::AutofillSpecifics* autofill = - autofill_specifics->MutableExtension(sync_pb::autofill); + autofill_specifics->mutable_autofill(); autofill->set_name(UTF16ToUTF8(entry.key().name())); autofill->set_value(UTF16ToUTF8(entry.key().value())); const std::vector<base::Time>& ts(entry.timestamps()); diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc index 892cf88..f2da26a 100644 --- a/chrome/browser/webdata/autofill_profile_syncable_service.cc +++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc @@ -11,6 +11,7 @@ #include "chrome/browser/autofill/form_group.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/api/sync_error.h" +#include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/webdata/autofill_table.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_database.h" @@ -196,7 +197,7 @@ SyncError AutofillProfileSyncableService::ProcessSyncChanges( break; case SyncChange::ACTION_DELETE: { std::string guid = i->sync_data().GetSpecifics(). - GetExtension(sync_pb::autofill_profile).guid(); + autofill_profile().guid(); bundle.profiles_to_delete.push_back(guid); profiles_map_.erase(guid); } break; @@ -300,7 +301,7 @@ void AutofillProfileSyncableService::WriteAutofillProfile( const AutofillProfile& profile, sync_pb::EntitySpecifics* profile_specifics) { sync_pb::AutofillProfileSpecifics* specifics = - profile_specifics->MutableExtension(sync_pb::autofill_profile); + profile_specifics->mutable_autofill_profile(); DCHECK(guid::IsValidGUID(profile.guid())); @@ -363,7 +364,7 @@ AutofillProfileSyncableService::CreateOrUpdateProfile( const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); const sync_pb::AutofillProfileSpecifics& autofill_specifics( - specifics.GetExtension(sync_pb::autofill_profile)); + specifics.autofill_profile()); GUIDToProfileMap::iterator it = profile_map->find( autofill_specifics.guid()); diff --git a/chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc b/chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc index 120a4ce..6f34719 100644 --- a/chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc +++ b/chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc @@ -57,10 +57,8 @@ MATCHER_P(CheckSyncChanges, n_sync_changes_list, "") { DCHECK(passed->IsValid()); if (passed->change_type() != expected->change_type()) return false; - if (passed->sync_data().GetSpecifics().GetExtension( - sync_pb::autofill_profile).guid() != - expected->sync_data().GetSpecifics().GetExtension( - sync_pb::autofill_profile).guid()) { + if (passed->sync_data().GetSpecifics().autofill_profile().guid() != + expected->sync_data().GetSpecifics().autofill_profile().guid()) { return false; } } @@ -210,9 +208,9 @@ TEST_F(AutofillProfileSyncableServiceTest, GetAllSyncData) { EXPECT_EQ(2U, data.size()); EXPECT_EQ(guid_present1, data.front().GetSpecifics() - .GetExtension(sync_pb::autofill_profile).guid()); + .autofill_profile().guid()); EXPECT_EQ(guid_present2, data.back().GetSpecifics() - .GetExtension(sync_pb::autofill_profile).guid()); + .autofill_profile().guid()); } TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { |