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

Unified Diff: sync/test/fake_server/fake_server.cc

Issue 833243007: Refactor FakeServer::CreateDefaultPermanentItems() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sync/test/fake_server/fake_server.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/fake_server/fake_server.cc
diff --git a/sync/test/fake_server/fake_server.cc b/sync/test/fake_server/fake_server.cc
index 74637035cdb45f20dd451bde950c055005e58982..45d03b4f3c7d163539e33595c00e806c230d18d0 100644
--- a/sync/test/fake_server/fake_server.cc
+++ b/sync/test/fake_server/fake_server.cc
@@ -161,6 +161,18 @@ FakeServer::~FakeServer() {
STLDeleteContainerPairSecondPointers(entities_.begin(), entities_.end());
}
+bool FakeServer::CreatePermanentBookmarkFolder(const char* server_tag,
+ const char* name) {
+ FakeServerEntity* entity =
+ PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name,
+ ModelTypeToRootTag(syncer::BOOKMARKS));
+ if (entity == NULL)
+ return false;
+
+ SaveEntity(entity);
+ return true;
+}
+
bool FakeServer::CreateDefaultPermanentItems() {
ModelTypeSet all_types = syncer::ProtocolTypes();
for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
@@ -173,25 +185,10 @@ bool FakeServer::CreateDefaultPermanentItems() {
SaveEntity(top_level_entity);
if (model_type == syncer::BOOKMARKS) {
- FakeServerEntity* bookmark_bar_entity =
- PermanentEntity::Create(syncer::BOOKMARKS,
- "bookmark_bar",
- "Bookmark Bar",
- ModelTypeToRootTag(syncer::BOOKMARKS));
- if (bookmark_bar_entity == NULL) {
+ if (!CreatePermanentBookmarkFolder("bookmark_bar", "Bookmark Bar"))
return false;
- }
- SaveEntity(bookmark_bar_entity);
-
- FakeServerEntity* other_bookmarks_entity =
- PermanentEntity::Create(syncer::BOOKMARKS,
- "other_bookmarks",
- "Other Bookmarks",
- ModelTypeToRootTag(syncer::BOOKMARKS));
- if (other_bookmarks_entity == NULL) {
+ if (!CreatePermanentBookmarkFolder("other_bookmarks", "Other Bookmarks"))
return false;
- }
- SaveEntity(other_bookmarks_entity);
}
}
« no previous file with comments | « sync/test/fake_server/fake_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698