Commit 85c24916 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Wrap whole bookmarks_helper library in namespace

Trivially moves all helper functions and classes to the existing
bookmarks_helper namespace.

Bug: None
Change-Id: I9947b8437bc28e84de0b905a3e1bd4e9ef3292af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879912
Auto-Submit: Mikel Astiz <mastiz@chromium.org>
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarMaksim Moskvitin <mmoskvitin@google.com>
Cr-Commit-Position: refs/heads/master@{#709403}
parent 79fb2f6b
......@@ -53,11 +53,13 @@
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_skia.h"
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
namespace bookmarks_helper {
namespace {
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
void ApplyBookmarkFavicon(
const BookmarkNode* bookmark_node,
favicon::FaviconService* favicon_service,
......@@ -276,14 +278,14 @@ void SetFaviconImpl(Profile* profile,
const BookmarkNode* node,
const GURL& icon_url,
const gfx::Image& image,
bookmarks_helper::FaviconSource favicon_source) {
FaviconSource favicon_source) {
BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile);
FaviconChangeObserver observer(model, node);
favicon::FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS);
if (favicon_source == bookmarks_helper::FROM_UI) {
if (favicon_source == FROM_UI) {
favicon_service->SetFavicons({node->url()}, icon_url,
favicon_base::IconType::kFavicon, image);
} else {
......@@ -318,7 +320,7 @@ void OnGotFaviconData(
// |test()->verifier()|.
void DeleteFaviconMappingsImpl(Profile* profile,
const BookmarkNode* node,
bookmarks_helper::FaviconSource favicon_source) {
FaviconSource favicon_source) {
BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile);
FaviconChangeObserver observer(model, node);
......@@ -326,7 +328,7 @@ void DeleteFaviconMappingsImpl(Profile* profile,
FaviconServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS);
if (favicon_source == bookmarks_helper::FROM_UI) {
if (favicon_source == FROM_UI) {
favicon_service->DeleteFaviconMappings({node->url()},
favicon_base::IconType::kFavicon);
} else {
......@@ -481,7 +483,7 @@ void FindNodeInVerifier(BookmarkModel* foreign_model,
}
// Swing over to the other tree.
walker = bookmarks_helper::GetVerifierBookmarkModel()->root_node();
walker = GetVerifierBookmarkModel()->root_node();
// Climb down.
while (!path.empty()) {
......@@ -497,9 +499,6 @@ void FindNodeInVerifier(BookmarkModel* foreign_model,
} // namespace
namespace bookmarks_helper {
BookmarkModel* GetBookmarkModel(int index) {
return BookmarkModelFactory::GetForBrowserContext(
sync_datatype_helper::test()->GetProfile(index));
......@@ -1018,15 +1017,13 @@ std::unique_ptr<syncer::LoopbackServerEntity> CreateBookmarkServerEntity(
return bookmark_builder.BuildBookmark(url);
}
} // namespace bookmarks_helper
BookmarksMatchChecker::BookmarksMatchChecker()
: MultiClientStatusChangeChecker(
sync_datatype_helper::test()->GetSyncServices()) {}
bool BookmarksMatchChecker::IsExitConditionSatisfied(std::ostream* os) {
*os << "Waiting for matching models";
return bookmarks_helper::AllModelsMatch();
return AllModelsMatch();
}
BookmarksMatchVerifierChecker::BookmarksMatchVerifierChecker()
......@@ -1035,7 +1032,7 @@ BookmarksMatchVerifierChecker::BookmarksMatchVerifierChecker()
bool BookmarksMatchVerifierChecker::IsExitConditionSatisfied(std::ostream* os) {
*os << "Waiting for model to match verifier";
return bookmarks_helper::AllModelsMatchVerifier();
return AllModelsMatchVerifier();
}
BookmarksTitleChecker::BookmarksTitleChecker(int profile_index,
......@@ -1051,8 +1048,7 @@ BookmarksTitleChecker::BookmarksTitleChecker(int profile_index,
bool BookmarksTitleChecker::IsExitConditionSatisfied(std::ostream* os) {
*os << "Waiting for bookmark count to match";
int actual_count = bookmarks_helper::CountBookmarksWithTitlesMatching(
profile_index_, title_);
int actual_count = CountBookmarksWithTitlesMatching(profile_index_, title_);
return expected_count_ == actual_count;
}
......@@ -1124,8 +1120,7 @@ namespace {
bool BookmarkCountsByUrlMatch(int profile,
const GURL& url,
int expected_count) {
int actual_count =
bookmarks_helper::CountBookmarksWithUrlsMatching(profile, url);
int actual_count = CountBookmarksWithUrlsMatching(profile, url);
if (expected_count != actual_count) {
DVLOG(1) << base::StringPrintf("Expected %d URL(s), but there were %d.",
expected_count, actual_count);
......@@ -1147,7 +1142,7 @@ BookmarksUrlChecker::BookmarksUrlChecker(int profile,
BookmarksGUIDChecker::BookmarksGUIDChecker(int profile, const std::string& guid)
: AwaitMatchStatusChangeChecker(
base::BindRepeating(bookmarks_helper::ContainsBookmarkNodeWithGUID,
profile,
guid),
base::BindRepeating(ContainsBookmarkNodeWithGUID, profile, guid),
"Bookmark GUID exists.") {}
} // namespace bookmarks_helper
......@@ -24,11 +24,11 @@ class GURL;
namespace bookmarks {
class BookmarkModel;
class BookmarkNode;
}
} // namespace bookmarks
namespace gfx {
class Image;
}
} // namespace gfx
namespace bookmarks_helper {
......@@ -237,8 +237,6 @@ std::unique_ptr<syncer::LoopbackServerEntity> CreateBookmarkServerEntity(
const std::string& title,
const GURL& url);
} // namespace bookmarks_helper
// Checker used to block until bookmarks match on all clients.
class BookmarksMatchChecker : public MultiClientStatusChangeChecker {
public:
......@@ -319,4 +317,6 @@ class BookmarksGUIDChecker : public AwaitMatchStatusChangeChecker {
BookmarksGUIDChecker(int profile_index, const std::string& guid);
};
} // namespace bookmarks_helper
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_BOOKMARKS_HELPER_H_
......@@ -33,6 +33,9 @@ using bookmarks::BookmarkNode;
using bookmarks::UrlAndTitle;
using bookmarks_helper::AddFolder;
using bookmarks_helper::AddURL;
using bookmarks_helper::BookmarksGUIDChecker;
using bookmarks_helper::BookmarksTitleChecker;
using bookmarks_helper::BookmarksUrlChecker;
using bookmarks_helper::CheckHasNoFavicon;
using bookmarks_helper::ContainsBookmarkNodeWithGUID;
using bookmarks_helper::CountBookmarksWithTitlesMatching;
......
......@@ -19,7 +19,9 @@
namespace {
using bookmarks_helper::AddURL;
using bookmarks_helper::BookmarksTitleChecker;
using bookmarks_helper::CreateBookmarkServerEntity;
using bookmarks_helper::ServerBookmarksEqualityChecker;
using encryption_helper::CreateCustomPassphraseNigori;
using encryption_helper::GetEncryptedBookmarkEntitySpecifics;
using encryption_helper::GetServerNigori;
......
......@@ -41,6 +41,10 @@ using bookmarks_helper::AddFolder;
using bookmarks_helper::AddURL;
using bookmarks_helper::AllModelsMatch;
using bookmarks_helper::AllModelsMatchVerifier;
using bookmarks_helper::BookmarksGUIDChecker;
using bookmarks_helper::BookmarksMatchChecker;
using bookmarks_helper::BookmarksMatchVerifierChecker;
using bookmarks_helper::BookmarksTitleChecker;
using bookmarks_helper::CheckFaviconExpired;
using bookmarks_helper::CheckHasNoFavicon;
using bookmarks_helper::ContainsDuplicateBookmarks;
......
......@@ -20,6 +20,7 @@ static const int kDecryptingClientId = 1;
using bookmarks_helper::AddURL;
using bookmarks_helper::AllModelsMatchVerifier;
using bookmarks_helper::BookmarksMatchVerifierChecker;
// These tests consider the client as a black-box; they are not concerned with
// whether the data is committed to the server correctly encrypted. Rather, they
......
......@@ -39,7 +39,7 @@ class TwoClientUserEventsSyncTest : public SyncTest {
}
bool WaitForBookmarksToMatchVerifier() {
return BookmarksMatchVerifierChecker().Wait();
return bookmarks_helper::BookmarksMatchVerifierChecker().Wait();
}
void AddTestBookmarksToClient(int index) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment