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

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

Issue 1094553002: Revert "Speculative revert by sheriff" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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') | tools/mb/mb_config.pyl » ('j') | 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 c54a9e903c9db3200bbb44c2a5bf9126da1ddd82..dbe3105a943cb9d33037b23b04ec4dfc2ae7adca 100644
--- a/sync/test/fake_server/fake_server.cc
+++ b/sync/test/fake_server/fake_server.cc
@@ -34,17 +34,29 @@ using syncer::GetModelType;
using syncer::ModelType;
using syncer::ModelTypeSet;
+namespace fake_server {
+
+class FakeServerEntity;
+
+namespace {
+
// The default store birthday value.
static const char kDefaultStoreBirthday[] = "1234567890";
// The default keystore key.
static const char kDefaultKeystoreKey[] = "1111111111111111";
-namespace fake_server {
+// Properties of the bookmark bar permanent folder.
+static const char kBookmarkBarFolderServerTag[] = "bookmark_bar";
+static const char kBookmarkBarFolderName[] = "Bookmark Bar";
-class FakeServerEntity;
+// Properties of the other bookmarks permanent folder.
+static const char kOtherBookmarksFolderServerTag[] = "other_bookmarks";
+static const char kOtherBookmarksFolderName[] = "Other Bookmarks";
-namespace {
+// Properties of the synced bookmarks permanent folder.
+static const char kSyncedBookmarksFolderServerTag[] = "synced_bookmarks";
+static const char kSyncedBookmarksFolderName[] = "Synced Bookmarks";
// A filter used during GetUpdates calls to determine what information to
// send back to the client. There is a 1:1 correspondence between any given
@@ -167,8 +179,8 @@ FakeServer::~FakeServer() {
STLDeleteContainerPairSecondPointers(entities_.begin(), entities_.end());
}
-bool FakeServer::CreatePermanentBookmarkFolder(const char* server_tag,
- const char* name) {
+bool FakeServer::CreatePermanentBookmarkFolder(const std::string& server_tag,
+ const std::string& name) {
FakeServerEntity* entity =
PermanentEntity::Create(syncer::BOOKMARKS, server_tag, name,
ModelTypeToRootTag(syncer::BOOKMARKS));
@@ -191,9 +203,11 @@ bool FakeServer::CreateDefaultPermanentItems() {
SaveEntity(top_level_entity);
if (model_type == syncer::BOOKMARKS) {
- if (!CreatePermanentBookmarkFolder("bookmark_bar", "Bookmark Bar"))
+ if (!CreatePermanentBookmarkFolder(kBookmarkBarFolderServerTag,
+ kBookmarkBarFolderName))
return false;
- if (!CreatePermanentBookmarkFolder("other_bookmarks", "Other Bookmarks"))
+ if (!CreatePermanentBookmarkFolder(kOtherBookmarksFolderServerTag,
+ kOtherBookmarksFolderName))
return false;
}
}
@@ -201,21 +215,6 @@ bool FakeServer::CreateDefaultPermanentItems() {
return true;
}
-bool FakeServer::CreateMobileBookmarksPermanentItem() {
- // This folder is called "Synced Bookmarks" by sync and is renamed
- // "Mobile Bookmarks" by the mobile client UIs.
- FakeServerEntity* mobile_bookmarks_entity =
- PermanentEntity::Create(syncer::BOOKMARKS,
- "synced_bookmarks",
- "Synced Bookmarks",
- ModelTypeToRootTag(syncer::BOOKMARKS));
- if (mobile_bookmarks_entity == NULL) {
- return false;
- }
- SaveEntity(mobile_bookmarks_entity);
- return true;
-}
-
void FakeServer::SaveEntity(FakeServerEntity* entity) {
delete entities_[entity->GetId()];
entity->SetVersion(++version_);
@@ -291,8 +290,11 @@ bool FakeServer::HandleGetUpdatesRequest(
scoped_ptr<UpdateSieve> sieve = UpdateSieve::Create(get_updates);
+ // This folder is called "Synced Bookmarks" by sync and is renamed
+ // "Mobile Bookmarks" by the mobile client UIs.
if (get_updates.create_mobile_bookmarks_folder() &&
- !CreateMobileBookmarksPermanentItem()) {
+ !CreatePermanentBookmarkFolder(kSyncedBookmarksFolderServerTag,
+ kSyncedBookmarksFolderName)) {
return false;
}
@@ -601,4 +603,18 @@ void FakeServer::DisableNetwork() {
network_enabled_ = false;
}
+std::string FakeServer::GetBookmarkBarFolderId() const {
+ for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end();
+ ++it) {
+ FakeServerEntity* entity = it->second;
+ if (entity->GetName() == kBookmarkBarFolderName &&
+ entity->IsFolder() &&
+ entity->GetModelType() == syncer::BOOKMARKS) {
+ return entity->GetId();
+ }
+ }
+ NOTREACHED() << "Bookmark Bar entity not found.";
+ return "";
+}
+
} // namespace fake_server
« no previous file with comments | « sync/test/fake_server/fake_server.h ('k') | tools/mb/mb_config.pyl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698