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

Unified Diff: chrome/browser/importer/importer_host.cc

Issue 6679004: importer: Pull ExternalProcessImporterClient out of ImporterHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 | « chrome/browser/importer/importer_host.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/importer/importer_host.cc
diff --git a/chrome/browser/importer/importer_host.cc b/chrome/browser/importer/importer_host.cc
index 07445ebe762186d0df35c58457c8233faff1d5bc..7152124811e09612a258b072375ff8921cbb0ada 100644
--- a/chrome/browser/importer/importer_host.cc
+++ b/chrome/browser/importer/importer_host.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/importer/external_process_importer_client.h"
#include "chrome/browser/importer/firefox_profile_lock.h"
#include "chrome/browser/importer/importer_bridge.h"
#include "chrome/browser/importer/importer_lock_dialog.h"
@@ -315,230 +316,3 @@ void ExternalProcessImporterHost::Loaded(BookmarkModel* model) {
import_to_bookmark_bar_ = (!model->HasBookmarks());
InvokeTaskIfDone();
}
-
-// ExternalProcessImporterClient -----------------------------------------------
-
-ExternalProcessImporterClient::ExternalProcessImporterClient(
- ExternalProcessImporterHost* importer_host,
- const importer::ProfileInfo& profile_info,
- int items,
- InProcessImporterBridge* bridge,
- bool import_to_bookmark_bar)
- : bookmarks_options_(0),
- total_bookmarks_count_(0),
- total_history_rows_count_(0),
- total_fav_icons_count_(0),
- process_importer_host_(importer_host),
- profile_import_process_host_(NULL),
- profile_info_(profile_info),
- items_(items),
- import_to_bookmark_bar_(import_to_bookmark_bar),
- bridge_(bridge),
- cancelled_(false) {
- bridge_->AddRef();
- process_importer_host_->NotifyImportStarted();
-}
-
-ExternalProcessImporterClient::~ExternalProcessImporterClient() {
- bridge_->Release();
-}
-
-void ExternalProcessImporterClient::Start() {
- AddRef(); // balanced in Cleanup.
- BrowserThread::ID thread_id;
- CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id));
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ExternalProcessImporterClient::StartProcessOnIOThread,
- g_browser_process->resource_dispatcher_host(), thread_id));
-}
-
-void ExternalProcessImporterClient::StartProcessOnIOThread(
- ResourceDispatcherHost* rdh,
- BrowserThread::ID thread_id) {
- profile_import_process_host_ =
- new ProfileImportProcessHost(rdh, this, thread_id);
- profile_import_process_host_->StartProfileImportProcess(profile_info_,
- items_, import_to_bookmark_bar_);
-}
-
-void ExternalProcessImporterClient::Cancel() {
- if (cancelled_)
- return;
-
- cancelled_ = true;
- if (profile_import_process_host_) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ExternalProcessImporterClient::CancelImportProcessOnIOThread));
- }
- Release();
-}
-
-void ExternalProcessImporterClient::CancelImportProcessOnIOThread() {
- profile_import_process_host_->CancelProfileImportProcess();
-}
-
-void ExternalProcessImporterClient::NotifyItemFinishedOnIOThread(
- importer::ImportItem import_item) {
- profile_import_process_host_->ReportImportItemFinished(import_item);
-}
-
-void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) {
- if (cancelled_)
- return;
-
- process_importer_host_->Cancel();
-}
-
-void ExternalProcessImporterClient::Cleanup() {
- if (cancelled_)
- return;
-
- if (process_importer_host_)
- process_importer_host_->NotifyImportEnded();
- Release();
-}
-
-void ExternalProcessImporterClient::OnImportStart() {
- if (cancelled_)
- return;
-
- bridge_->NotifyStarted();
-}
-
-void ExternalProcessImporterClient::OnImportFinished(bool succeeded,
- std::string error_msg) {
- if (cancelled_)
- return;
-
- if (!succeeded)
- LOG(WARNING) << "Import failed. Error: " << error_msg;
- Cleanup();
-}
-
-void ExternalProcessImporterClient::OnImportItemStart(int item_data) {
- if (cancelled_)
- return;
-
- bridge_->NotifyItemStarted(static_cast<importer::ImportItem>(item_data));
-}
-
-void ExternalProcessImporterClient::OnImportItemFinished(int item_data) {
- if (cancelled_)
- return;
-
- importer::ImportItem import_item =
- static_cast<importer::ImportItem>(item_data);
- bridge_->NotifyItemEnded(import_item);
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ExternalProcessImporterClient::NotifyItemFinishedOnIOThread,
- import_item));
-}
-
-void ExternalProcessImporterClient::OnHistoryImportStart(
- size_t total_history_rows_count) {
- if (cancelled_)
- return;
-
- total_history_rows_count_ = total_history_rows_count;
- history_rows_.reserve(total_history_rows_count);
-}
-
-void ExternalProcessImporterClient::OnHistoryImportGroup(
- const std::vector<history::URLRow>& history_rows_group,
- int visit_source) {
- if (cancelled_)
- return;
-
- history_rows_.insert(history_rows_.end(), history_rows_group.begin(),
- history_rows_group.end());
- if (history_rows_.size() == total_history_rows_count_)
- bridge_->SetHistoryItems(history_rows_,
- static_cast<history::VisitSource>(visit_source));
-}
-
-void ExternalProcessImporterClient::OnHomePageImportReady(
- const GURL& home_page) {
- if (cancelled_)
- return;
-
- bridge_->AddHomePage(home_page);
-}
-
-void ExternalProcessImporterClient::OnBookmarksImportStart(
- const std::wstring first_folder_name,
- int options, size_t total_bookmarks_count) {
- if (cancelled_)
- return;
-
- bookmarks_first_folder_name_ = first_folder_name;
- bookmarks_options_ = options;
- total_bookmarks_count_ = total_bookmarks_count;
- bookmarks_.reserve(total_bookmarks_count);
-}
-
-void ExternalProcessImporterClient::OnBookmarksImportGroup(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group) {
- if (cancelled_)
- return;
-
- // Collect sets of bookmarks from importer process until we have reached
- // total_bookmarks_count_:
- bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(),
- bookmarks_group.end());
- if (bookmarks_.size() == total_bookmarks_count_) {
- bridge_->AddBookmarkEntries(bookmarks_, bookmarks_first_folder_name_,
- bookmarks_options_);
- }
-}
-
-void ExternalProcessImporterClient::OnFavIconsImportStart(
- size_t total_fav_icons_count) {
- if (cancelled_)
- return;
-
- total_fav_icons_count_ = total_fav_icons_count;
- fav_icons_.reserve(total_fav_icons_count);
-}
-
-void ExternalProcessImporterClient::OnFavIconsImportGroup(
- const std::vector<history::ImportedFavIconUsage>& fav_icons_group) {
- if (cancelled_)
- return;
-
- fav_icons_.insert(fav_icons_.end(), fav_icons_group.begin(),
- fav_icons_group.end());
- if (fav_icons_.size() == total_fav_icons_count_)
- bridge_->SetFavIcons(fav_icons_);
-}
-
-void ExternalProcessImporterClient::OnPasswordFormImportReady(
- const webkit_glue::PasswordForm& form) {
- if (cancelled_)
- return;
-
- bridge_->SetPasswordForm(form);
-}
-
-void ExternalProcessImporterClient::OnKeywordsImportReady(
- const std::vector<TemplateURL>& template_urls,
- int default_keyword_index, bool unique_on_host_and_path) {
- if (cancelled_)
- return;
-
- std::vector<TemplateURL*> template_url_vec;
- template_url_vec.reserve(template_urls.size());
- std::vector<TemplateURL>::const_iterator iter;
- for (iter = template_urls.begin();
- iter != template_urls.end();
- ++iter) {
- template_url_vec.push_back(new TemplateURL(*iter));
- }
- bridge_->SetKeywords(template_url_vec, default_keyword_index,
- unique_on_host_and_path);
-}
« no previous file with comments | « chrome/browser/importer/importer_host.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698