Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2837)

Unified Diff: chrome/browser/sync/internal_api/syncapi_unittest.cc

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fred's review Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/internal_api/syncapi_unittest.cc
diff --git a/chrome/browser/sync/internal_api/syncapi_unittest.cc b/chrome/browser/sync/internal_api/syncapi_unittest.cc
index 7b7c3e28221fb6d2235dd841641dcad3c813abb6..68067468402661fa241396bca225abb649bd253e 100644
--- a/chrome/browser/sync/internal_api/syncapi_unittest.cc
+++ b/chrome/browser/sync/internal_api/syncapi_unittest.cc
@@ -170,7 +170,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.
@@ -508,8 +508,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());
@@ -527,8 +526,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());
@@ -1812,7 +1810,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.
@@ -1823,7 +1821,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.
@@ -1929,8 +1927,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),
@@ -2038,8 +2036,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));
@@ -2068,7 +2066,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,
@@ -2102,7 +2100,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,
@@ -2132,8 +2130,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));
@@ -2153,8 +2150,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,
@@ -2185,8 +2181,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,
@@ -2213,8 +2208,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),
@@ -2247,8 +2242,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),
@@ -2305,8 +2300,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,
@@ -2341,8 +2336,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,
@@ -2410,12 +2405,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,
« no previous file with comments | « chrome/browser/sync/internal_api/change_record_unittest.cc ('k') | chrome/browser/sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698