diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 19:22:51 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 19:22:51 +0000 |
commit | 5072aee46aa709d9a67a3c988c5934bec67d71e5 (patch) | |
tree | 214a9ba02d8b022b58ef50b112762a5c02cddf9b /chrome/browser/importer/firefox3_importer.cc | |
parent | 636b49b9cad66fe061fe4d6e1f69bdf4bee1a780 (diff) | |
download | chromium_src-5072aee46aa709d9a67a3c988c5934bec67d71e5.zip chromium_src-5072aee46aa709d9a67a3c988c5934bec67d71e5.tar.gz chromium_src-5072aee46aa709d9a67a3c988c5934bec67d71e5.tar.bz2 |
Revert "Refactor ImporterHost as preparation for OOP switch", which caused purify XP leak:
std::_W::_Allocate(unsigned int,wchar_t *) [unit_tests.exe]
Alloc Location
...
chrome/browser/importer/ie_importer.cc IEImporter::StartImport(ProfileInfo,WORD,ImporterBridge *)
base/tuple.h ?DispatchToMethod@VImporter@@P81@AEXUProfileInfo@@GPAVImporterBridge@@@ZU2@GV?$scoped_refptr@VImporterBridge@@@@@@YAXPAVImporter@@P80@AEXUProfileInfo@@GPAVImporterBridge@@@ZABU?$Tuple3@UProfileInfo@@GV?$scoped_refptr@VImporterBridge@@@@@@@Z
^^^
This reverts commit r28007 and r27996.
TBR=jeremy
Review URL: http://codereview.chromium.org/260011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer/firefox3_importer.cc')
-rw-r--r-- | chrome/browser/importer/firefox3_importer.cc | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 10d2855..a509f55 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -14,7 +14,6 @@ #include "base/string_util.h" #include "chrome/browser/importer/firefox2_importer.h" #include "chrome/browser/importer/firefox_importer_utils.h" -#include "chrome/browser/importer/importer_bridge.h" #include "chrome/browser/importer/nss_decryptor.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/time_format.h" @@ -26,15 +25,17 @@ using base::Time; using webkit_glue::PasswordForm; void Firefox3Importer::StartImport(ProfileInfo profile_info, - uint16 items, - ImporterBridge* bridge) { - bridge_ = bridge; + uint16 items, ProfileWriter* writer, + MessageLoop* delagate_loop, + ImporterHost* host) { + writer_ = writer; source_path_ = profile_info.source_path; app_path_ = profile_info.app_path; + importer_host_ = host; // The order here is important! - bridge_->NotifyStarted(); + NotifyStarted(); if ((items & HOME_PAGE) && !cancelled()) ImportHomepage(); // Doesn't have a UI item. @@ -42,27 +43,27 @@ void Firefox3Importer::StartImport(ProfileInfo profile_info, // will also import favicons and we store favicon for a URL only if the URL // exist in history or bookmarks. if ((items & HISTORY) && !cancelled()) { - bridge_->NotifyItemStarted(HISTORY); + NotifyItemStarted(HISTORY); ImportHistory(); - bridge_->NotifyItemEnded(HISTORY); + NotifyItemEnded(HISTORY); } if ((items & FAVORITES) && !cancelled()) { - bridge_->NotifyItemStarted(FAVORITES); + NotifyItemStarted(FAVORITES); ImportBookmarks(); - bridge_->NotifyItemEnded(FAVORITES); + NotifyItemEnded(FAVORITES); } if ((items & SEARCH_ENGINES) && !cancelled()) { - bridge_->NotifyItemStarted(SEARCH_ENGINES); + NotifyItemStarted(SEARCH_ENGINES); ImportSearchEngines(); - bridge_->NotifyItemEnded(SEARCH_ENGINES); + NotifyItemEnded(SEARCH_ENGINES); } if ((items & PASSWORDS) && !cancelled()) { - bridge_->NotifyItemStarted(PASSWORDS); + NotifyItemStarted(PASSWORDS); ImportPasswords(); - bridge_->NotifyItemEnded(PASSWORDS); + NotifyItemEnded(PASSWORDS); } - bridge_->NotifyEnded(); + NotifyEnded(); } void Firefox3Importer::ImportHistory() { @@ -109,7 +110,8 @@ void Firefox3Importer::ImportHistory() { rows.push_back(row); } if (!rows.empty() && !cancelled()) { - bridge_->SetHistoryItems(rows); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddHistoryPage, rows)); } } @@ -242,22 +244,22 @@ void Firefox3Importer::ImportBookmarks() { // Write into profile. if (!bookmarks.empty() && !cancelled()) { - const std::wstring& first_folder_name = - l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_FIREFOX); - int options = 0; - if (import_to_bookmark_bar()) - options = ProfileWriter::IMPORT_TO_BOOKMARK_BAR; - bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddBookmarkEntry, bookmarks, + l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), + import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0)); } if (!template_urls.empty() && !cancelled()) { - bridge_->SetKeywords(template_urls, -1, false); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddKeywords, template_urls, -1, false)); } else { STLDeleteContainerPointers(template_urls.begin(), template_urls.end()); } if (!favicon_map.empty() && !cancelled()) { std::vector<history::ImportedFavIconUsage> favicons; LoadFavicons(db.get(), favicon_map, &favicons); - bridge_->SetFavIcons(favicons); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddFavicons, favicons)); } } @@ -287,7 +289,8 @@ void Firefox3Importer::ImportPasswords() { if (!cancelled()) { for (size_t i = 0; i < forms.size(); ++i) { - bridge_->SetPasswordForm(forms[i]); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddPasswordForm, forms[i])); } } } @@ -298,15 +301,16 @@ void Firefox3Importer::ImportSearchEngines() { std::vector<TemplateURL*> search_engines; ParseSearchEnginesFromXMLFiles(files, &search_engines); - int default_index = - GetFirefoxDefaultSearchEngineIndex(search_engines, source_path_); - bridge_->SetKeywords(search_engines, default_index, true); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddKeywords, search_engines, + GetFirefoxDefaultSearchEngineIndex(search_engines, source_path_), true)); } void Firefox3Importer::ImportHomepage() { - GURL home_page = GetHomepage(source_path_); - if (home_page.is_valid() && !IsDefaultHomepage(home_page, app_path_)) { - bridge_->AddHomePage(home_page); + GURL homepage = GetHomepage(source_path_); + if (homepage.is_valid() && !IsDefaultHomepage(homepage, app_path_)) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddHomepage, homepage)); } } |