summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/syncable/syncable_unittest.cc
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-04 23:33:36 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-04 23:33:36 +0000
commit4557d22bc0b6fe59fb146b08065f91d47d3c9254 (patch)
tree7ef9d789310470d974d3af98ca3c94e611cff8e7 /chrome/browser/sync/syncable/syncable_unittest.cc
parentb7522682a07d06f417ba596fd3e7822bf22c1ab3 (diff)
downloadchromium_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/sync/syncable/syncable_unittest.cc')
-rw-r--r--chrome/browser/sync/syncable/syncable_unittest.cc30
1 files changed, 14 insertions, 16 deletions
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());