diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-04 23:33:36 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-04 23:33:36 +0000 |
commit | 4557d22bc0b6fe59fb146b08065f91d47d3c9254 (patch) | |
tree | 7ef9d789310470d974d3af98ca3c94e611cff8e7 /chrome/browser/webdata | |
parent | b7522682a07d06f417ba596fd3e7822bf22c1ab3 (diff) | |
download | chromium_src-4557d22bc0b6fe59fb146b08065f91d47d3c9254.zip chromium_src-4557d22bc0b6fe59fb146b08065f91d47d3c9254.tar.gz chromium_src-4557d22bc0b6fe59fb146b08065f91d47d3c9254.tar.bz2 |
sync: remove use of protobuf extensions in protocol to reduce static init overhead.
Instead, we now use optional fields in EntitySpecifics. Because the tag numbers remain
the same, this is a wire-format compatible change.
This incurs a (#datatypes * sizeof(void*))*#sync_items memory cost, due to storing extra pointers. In practice, for a typical account on windows this amounts to < 200k, and the static init cost is believed to be greater.
Note - upcoming features in protobufs may let us eliminate this extra memory overhead.
Also: The testserver tests were broken on ToT due to a bug in _SaveEntry's saving of mtime which is fixed in this patch.
TBR=yoz@chromium.org
TBR=mnissler@chromium.org
TBR=pkasting@chromium.org
TBR=georgey@chromium.org
BUG=94992, 94925
Review URL: http://codereview.chromium.org/9460047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
3 files changed, 14 insertions, 14 deletions
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) { |