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/firefox2_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/firefox2_importer.cc')
-rw-r--r-- | chrome/browser/importer/firefox2_importer.cc | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 943cb9e..3a38b2f 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -13,7 +13,6 @@ #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/importer/firefox_importer_utils.h" -#include "chrome/browser/importer/importer_bridge.h" #include "chrome/browser/importer/mork_reader.h" #include "chrome/browser/importer/nss_decryptor.h" #include "chrome/browser/search_engines/template_url.h" @@ -36,16 +35,18 @@ Firefox2Importer::~Firefox2Importer() { } void Firefox2Importer::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; parsing_bookmarks_html_file_ = (profile_info.browser_type == BOOKMARKS_HTML); // The order here is important! - bridge_->NotifyStarted(); + NotifyStarted(); if ((items & HOME_PAGE) && !cancelled()) ImportHomepage(); // Doesn't have a UI item. @@ -53,27 +54,27 @@ void Firefox2Importer::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(); } // static @@ -263,19 +264,21 @@ void Firefox2Importer::ImportBookmarks() { // Write data into profile. if (!bookmarks.empty() && !cancelled()) { - 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, + first_folder_name, + import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0)); } if (!parsing_bookmarks_html_file_ && !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 (!favicons.empty()) { - bridge_->SetFavIcons(favicons); + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddFavicons, favicons)); } } @@ -302,7 +305,8 @@ void Firefox2Importer::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])); } } } @@ -310,7 +314,7 @@ void Firefox2Importer::ImportPasswords() { void Firefox2Importer::ImportHistory() { std::wstring file = source_path_; file_util::AppendToPath(&file, L"history.dat"); - ImportHistoryFromFirefox2(file, bridge_); + ImportHistoryFromFirefox2(file, main_loop_, writer_); } void Firefox2Importer::ImportSearchEngines() { @@ -319,16 +323,17 @@ void Firefox2Importer::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 Firefox2Importer::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)); } } |