Commit e7b4ccf7 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Callback -> {Once,Repeating}Callback in //chrome/utility/importer

Also NULL->nullptr at call sites to satisfy presubmit checks.

Bug: 1007645
Change-Id: I2b1e30c68e4040f3e6e340f8c9e5f448998e2980
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943647Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720759}
parent f9b89fe0
...@@ -106,8 +106,8 @@ static std::string stripDt(const std::string& lineDt) { ...@@ -106,8 +106,8 @@ static std::string stripDt(const std::string& lineDt) {
} }
void ImportBookmarksFile( void ImportBookmarksFile(
const base::Callback<bool(void)>& cancellation_callback, base::RepeatingCallback<bool(void)> cancellation_callback,
const base::Callback<bool(const GURL&)>& valid_url_callback, base::RepeatingCallback<bool(const GURL&)> valid_url_callback,
const base::FilePath& file_path, const base::FilePath& file_path,
std::vector<ImportedBookmarkEntry>* bookmarks, std::vector<ImportedBookmarkEntry>* bookmarks,
std::vector<importer::SearchEngineInfo>* search_engines, std::vector<importer::SearchEngineInfo>* search_engines,
......
...@@ -44,8 +44,8 @@ namespace bookmark_html_reader { ...@@ -44,8 +44,8 @@ namespace bookmark_html_reader {
// |favicons| is a pointer to a vector, which is filled with the favicons of // |favicons| is a pointer to a vector, which is filled with the favicons of
// imported bookmarks. It may be NULL, in which case favicons are not imported. // imported bookmarks. It may be NULL, in which case favicons are not imported.
void ImportBookmarksFile( void ImportBookmarksFile(
const base::Callback<bool(void)>& cancellation_callback, base::RepeatingCallback<bool(void)> cancellation_callback,
const base::Callback<bool(const GURL&)>& valid_url_callback, base::RepeatingCallback<bool(const GURL&)> valid_url_callback,
const base::FilePath& file_path, const base::FilePath& file_path,
std::vector<ImportedBookmarkEntry>* bookmarks, std::vector<ImportedBookmarkEntry>* bookmarks,
std::vector<importer::SearchEngineInfo>* search_engines, std::vector<importer::SearchEngineInfo>* search_engines,
......
...@@ -347,9 +347,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, Firefox2BookmarkFileImport) { ...@@ -347,9 +347,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, Firefox2BookmarkFileImport) {
base::FilePath path = test_data_path_.AppendASCII("firefox2.html"); base::FilePath path = test_data_path_.AppendASCII("firefox2.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, &bookmarks, NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(3U, bookmarks.size()); ASSERT_EQ(3U, bookmarks.size());
ExpectFirstFirefox2Bookmark(bookmarks[0]); ExpectFirstFirefox2Bookmark(bookmarks[0]);
...@@ -361,9 +361,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, BookmarkFileWithHrTagImport) { ...@@ -361,9 +361,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, BookmarkFileWithHrTagImport) {
base::FilePath path = test_data_path_.AppendASCII("firefox23.html"); base::FilePath path = test_data_path_.AppendASCII("firefox23.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, &bookmarks, NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(3U, bookmarks.size()); ASSERT_EQ(3U, bookmarks.size());
ExpectFirstFirefox23Bookmark(bookmarks[0]); ExpectFirstFirefox23Bookmark(bookmarks[0]);
...@@ -375,9 +375,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, EpiphanyBookmarkFileImport) { ...@@ -375,9 +375,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, EpiphanyBookmarkFileImport) {
base::FilePath path = test_data_path_.AppendASCII("epiphany.html"); base::FilePath path = test_data_path_.AppendASCII("epiphany.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, &bookmarks, NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(2U, bookmarks.size()); ASSERT_EQ(2U, bookmarks.size());
ExpectFirstEpiphanyBookmark(bookmarks[0]); ExpectFirstEpiphanyBookmark(bookmarks[0]);
...@@ -389,9 +389,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, FirefoxBookmarkFileWithKeywordImport) { ...@@ -389,9 +389,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, FirefoxBookmarkFileWithKeywordImport) {
"firefox_bookmark_keyword.html"); "firefox_bookmark_keyword.html");
std::vector<importer::SearchEngineInfo> search_engines; std::vector<importer::SearchEngineInfo> search_engines;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, NULL, &search_engines, NULL); nullptr, &search_engines, nullptr);
ASSERT_EQ(2U, search_engines.size()); ASSERT_EQ(2U, search_engines.size());
ExpectFirstFirefoxBookmarkWithKeyword(search_engines[0]); ExpectFirstFirefoxBookmarkWithKeyword(search_engines[0]);
...@@ -402,9 +402,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, EmptyFolderImport) { ...@@ -402,9 +402,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, EmptyFolderImport) {
base::FilePath path = test_data_path_.AppendASCII("empty_folder.html"); base::FilePath path = test_data_path_.AppendASCII("empty_folder.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), path, &bookmarks, base::RepeatingCallback<bool(const GURL&)>(), path,
NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(3U, bookmarks.size()); ASSERT_EQ(3U, bookmarks.size());
ExpectFirstEmptyFolderBookmark(bookmarks[0]); ExpectFirstEmptyFolderBookmark(bookmarks[0]);
...@@ -417,9 +417,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, ...@@ -417,9 +417,9 @@ TEST_F(BookmarkHTMLReaderTestWithData,
base::FilePath path = test_data_path_.AppendASCII("redditsaver.html"); base::FilePath path = test_data_path_.AppendASCII("redditsaver.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, &bookmarks, NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(2U, bookmarks.size()); ASSERT_EQ(2U, bookmarks.size());
EXPECT_EQ(ASCIIToUTF16("Google"), bookmarks[0].title); EXPECT_EQ(ASCIIToUTF16("Google"), bookmarks[0].title);
...@@ -434,9 +434,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, ...@@ -434,9 +434,9 @@ TEST_F(BookmarkHTMLReaderTestWithData,
base::FilePath path = test_data_path_.AppendASCII("ie_sans_charset.html"); base::FilePath path = test_data_path_.AppendASCII("ie_sans_charset.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(const GURL&)>(), path,
path, &bookmarks, NULL, NULL); &bookmarks, nullptr, nullptr);
ASSERT_EQ(3U, bookmarks.size()); ASSERT_EQ(3U, bookmarks.size());
EXPECT_EQ(ASCIIToUTF16("Google"), bookmarks[0].title); EXPECT_EQ(ASCIIToUTF16("Google"), bookmarks[0].title);
...@@ -463,10 +463,11 @@ TEST_F(BookmarkHTMLReaderTestWithData, CancellationCallback) { ...@@ -463,10 +463,11 @@ TEST_F(BookmarkHTMLReaderTestWithData, CancellationCallback) {
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
CancelAfterFifteenCalls cancel_fifteen; CancelAfterFifteenCalls cancel_fifteen;
ImportBookmarksFile(base::Bind(&CancelAfterFifteenCalls::ShouldCancel, ImportBookmarksFile(
base::Unretained(&cancel_fifteen)), base::BindRepeating(&CancelAfterFifteenCalls::ShouldCancel,
base::Callback<bool(const GURL&)>(), base::Unretained(&cancel_fifteen)),
path, &bookmarks, NULL, NULL); base::RepeatingCallback<bool(const GURL&)>(), path, &bookmarks, nullptr,
nullptr);
// The cancellation callback is checked before each line is read, so fifteen // The cancellation callback is checked before each line is read, so fifteen
// lines are imported. The first fifteen lines of firefox2.html include only // lines are imported. The first fifteen lines of firefox2.html include only
...@@ -489,9 +490,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, ValidURLCallback) { ...@@ -489,9 +490,9 @@ TEST_F(BookmarkHTMLReaderTestWithData, ValidURLCallback) {
base::FilePath path = test_data_path_.AppendASCII("firefox2.html"); base::FilePath path = test_data_path_.AppendASCII("firefox2.html");
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
ImportBookmarksFile(base::Callback<bool(void)>(), ImportBookmarksFile(base::RepeatingCallback<bool(void)>(),
base::Bind(&IsURLValid), base::BindRepeating(&IsURLValid), path, &bookmarks,
path, &bookmarks, NULL, NULL); nullptr, nullptr);
ASSERT_EQ(2U, bookmarks.size()); ASSERT_EQ(2U, bookmarks.size());
ExpectFirstFirefox2Bookmark(bookmarks[0]); ExpectFirstFirefox2Bookmark(bookmarks[0]);
......
...@@ -97,12 +97,9 @@ void BookmarksFileImporter::StartImport( ...@@ -97,12 +97,9 @@ void BookmarksFileImporter::StartImport(
favicon_base::FaviconUsageDataList favicons; favicon_base::FaviconUsageDataList favicons;
bookmark_html_reader::ImportBookmarksFile( bookmark_html_reader::ImportBookmarksFile(
base::Bind(IsImporterCancelled, base::Unretained(this)), base::BindRepeating(IsImporterCancelled, base::Unretained(this)),
base::Bind(internal::CanImportURL), base::BindRepeating(internal::CanImportURL), source_profile.source_path,
source_profile.source_path, &bookmarks, &search_engines, &favicons);
&bookmarks,
&search_engines,
&favicons);
if (!bookmarks.empty() && !cancelled()) { if (!bookmarks.empty() && !cancelled()) {
base::string16 first_folder_name = base::string16 first_folder_name =
......
...@@ -51,12 +51,10 @@ void LoadDefaultBookmarks(const base::FilePath& app_path, ...@@ -51,12 +51,10 @@ void LoadDefaultBookmarks(const base::FilePath& app_path,
std::vector<ImportedBookmarkEntry> bookmarks; std::vector<ImportedBookmarkEntry> bookmarks;
std::vector<importer::SearchEngineInfo> search_engines; std::vector<importer::SearchEngineInfo> search_engines;
bookmark_html_reader::ImportBookmarksFile(base::Callback<bool(void)>(), bookmark_html_reader::ImportBookmarksFile(
base::Callback<bool(const GURL&)>(), base::RepeatingCallback<bool(void)>(),
file, base::RepeatingCallback<bool(const GURL&)>(), file, &bookmarks,
&bookmarks, &search_engines, nullptr);
&search_engines,
NULL);
for (size_t i = 0; i < bookmarks.size(); ++i) for (size_t i = 0; i < bookmarks.size(); ++i)
urls->insert(bookmarks[i].url); urls->insert(bookmarks[i].url);
} }
......
...@@ -76,7 +76,7 @@ class FFDecryptorClientListener ...@@ -76,7 +76,7 @@ class FFDecryptorClientListener
receiver) receiver)
: receiver_(this, std::move(receiver)) {} : receiver_(this, std::move(receiver)) {}
void SetQuitClosure(base::Closure quit_closure) { void SetQuitClosure(base::OnceClosure quit_closure) {
receiver_.set_disconnect_handler(std::move(quit_closure)); receiver_.set_disconnect_handler(std::move(quit_closure));
} }
...@@ -160,23 +160,24 @@ class FFDecryptorServerChannelListener { ...@@ -160,23 +160,24 @@ class FFDecryptorServerChannelListener {
bool got_result_; bool got_result_;
private: private:
void InitDecryptorReply(base::Closure quit_closure, bool result) { void InitDecryptorReply(base::OnceClosure quit_closure, bool result) {
result_bool_ = result; result_bool_ = result;
got_result_ = true; got_result_ = true;
quit_closure.Run(); std::move(quit_closure).Run();
} }
void DecryptReply(base::Closure quit_closure, const base::string16& text) { void DecryptReply(base::OnceClosure quit_closure,
const base::string16& text) {
result_string_ = text; result_string_ = text;
got_result_ = true; got_result_ = true;
quit_closure.Run(); std::move(quit_closure).Run();
} }
void ParseSignonsReply(base::Closure quit_closure, void ParseSignonsReply(base::OnceClosure quit_closure,
const std::vector<autofill::PasswordForm>& forms) { const std::vector<autofill::PasswordForm>& forms) {
result_vector_ = forms; result_vector_ = forms;
got_result_ = true; got_result_ = true;
quit_closure.Run(); std::move(quit_closure).Run();
} }
mojo::Remote<firefox_importer_unittest_utils_mac::mojom::FirefoxDecryptor> mojo::Remote<firefox_importer_unittest_utils_mac::mojom::FirefoxDecryptor>
......
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