diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 00:21:39 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-01 00:21:39 +0000 |
commit | 10bbe921f6766d26e3e298bec211e1bc374cf0f9 (patch) | |
tree | fc9b8f50cb5ea911cf9b3a712de2f7a0045e9f39 | |
parent | 1f88b516c54bf39058785d16dacdb3b0c5262b04 (diff) | |
download | chromium_src-10bbe921f6766d26e3e298bec211e1bc374cf0f9.zip chromium_src-10bbe921f6766d26e3e298bec211e1bc374cf0f9.tar.gz chromium_src-10bbe921f6766d26e3e298bec211e1bc374cf0f9.tar.bz2 |
importer: Pull ImportProcessClient out of ProfileImportProcessHost.
- Rename ImportProcessClient class to ProfileImportProcessClient.
- Move chrome/browser/profile_import_process_host.[cc,h] to chrome/browser/importer/ directory.
BUG=None
TEST=None
R=avi@chromium.org
Review URL: http://codereview.chromium.org/6737006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80105 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/importer/external_process_importer_client.cc | 2 | ||||
-rw-r--r-- | chrome/browser/importer/external_process_importer_client.h | 17 | ||||
-rw-r--r-- | chrome/browser/importer/profile_import_process_client.cc | 118 | ||||
-rw-r--r-- | chrome/browser/importer/profile_import_process_client.h | 91 | ||||
-rw-r--r-- | chrome/browser/importer/profile_import_process_host.cc (renamed from chrome/browser/profile_import_process_host.cc) | 53 | ||||
-rw-r--r-- | chrome/browser/importer/profile_import_process_host.h | 84 | ||||
-rw-r--r-- | chrome/browser/profile_import_process_host.h | 141 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 6 |
8 files changed, 315 insertions, 197 deletions
diff --git a/chrome/browser/importer/external_process_importer_client.cc b/chrome/browser/importer/external_process_importer_client.cc index 44c57e2..3f15bf6 100644 --- a/chrome/browser/importer/external_process_importer_client.cc +++ b/chrome/browser/importer/external_process_importer_client.cc @@ -8,9 +8,11 @@ #include "chrome/browser/importer/external_process_importer_host.h" #include "chrome/browser/importer/importer_host.h" #include "chrome/browser/importer/in_process_importer_bridge.h" +#include "chrome/browser/importer/profile_import_process_host.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "content/browser/browser_thread.h" +#include "content/browser/renderer_host/resource_dispatcher_host.h" ExternalProcessImporterClient::ExternalProcessImporterClient( ExternalProcessImporterHost* importer_host, diff --git a/chrome/browser/importer/external_process_importer_client.h b/chrome/browser/importer/external_process_importer_client.h index 6126c2e..0e33b0a 100644 --- a/chrome/browser/importer/external_process_importer_client.h +++ b/chrome/browser/importer/external_process_importer_client.h @@ -11,11 +11,15 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/profile_writer.h" -#include "chrome/browser/profile_import_process_host.h" +#include "chrome/browser/importer/profile_import_process_client.h" +#include "content/browser/browser_thread.h" class ExternalProcessImporterHost; class InProcessImporterBridge; +class ProfileImportProcessHost; +class ResourceDispatcherHost; namespace history { class URLRow; @@ -29,8 +33,7 @@ struct ProfileInfo; // This class is the client for the ProfileImportProcessHost. It collects // notifications from this process host and feeds data back to the importer // host, who actually does the writing. -class ExternalProcessImporterClient - : public ProfileImportProcessHost::ImportProcessClient { +class ExternalProcessImporterClient : public ProfileImportProcessClient { public: ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, const importer::ProfileInfo& profile_info, @@ -52,13 +55,14 @@ class ExternalProcessImporterClient // Creates a new ProfileImportProcessHost, which launches the import process. void StartImportProcessOnIOThread(ResourceDispatcherHost* rdh, BrowserThread::ID thread_id); + // Cancel import process on IO thread. void CancelImportProcessOnIOThread(); // Report item completely downloaded on IO thread. void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); - // Begin ProfileImportProcessHost::ImportProcessClient implementation. + // Begin ProfileImportProcessClient implementation. virtual void OnProcessCrashed(int exit_status) OVERRIDE; virtual void OnImportStart() OVERRIDE; virtual void OnImportFinished(bool succeeded, @@ -71,9 +75,8 @@ class ExternalProcessImporterClient virtual void OnHistoryImportStart(size_t total_history_rows_count) OVERRIDE; // Called when a group of URLRows has been received. - // The source is passed with history::VisitSource type. virtual void OnHistoryImportGroup( - const std::vector<history::URLRow> &history_rows_group, + const std::vector<history::URLRow>& history_rows_group, int visit_source) OVERRIDE; // Called when the home page has been received. @@ -111,7 +114,7 @@ class ExternalProcessImporterClient int default_keyword_index, bool unique_on_host_and_path) OVERRIDE; - // End ProfileImportProcessHost::ImportProcessClient implementation. + // End ProfileImportProcessClient implementation. // These variables store data being collected from the importer until the // entire group has been collected and is ready to be written to the profile. diff --git a/chrome/browser/importer/profile_import_process_client.cc b/chrome/browser/importer/profile_import_process_client.cc new file mode 100644 index 0000000..26bcb3f --- /dev/null +++ b/chrome/browser/importer/profile_import_process_client.cc @@ -0,0 +1,118 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/importer/profile_import_process_client.h" + +#include "chrome/browser/history/history_types.h" +#include "chrome/browser/importer/importer_messages.h" +#include "chrome/browser/importer/profile_import_process_host.h" +#include "chrome/browser/search_engines/template_url.h" +#include "googleurl/src/gurl.h" +#include "ipc/ipc_message_macros.h" +#include "webkit/glue/password_form.h" + +ProfileImportProcessClient::ProfileImportProcessClient() { +} + +void ProfileImportProcessClient::OnProcessCrashed(int exit_status) { +} + +void ProfileImportProcessClient::OnImportStart() { +} + +void ProfileImportProcessClient::OnImportFinished( + bool succeeded, + const std::string& error_msg) { +} + +void ProfileImportProcessClient::OnImportItemStart(int item) { +} + +void ProfileImportProcessClient::OnImportItemFinished(int item) { +} + +void ProfileImportProcessClient::OnImportItemFailed( + const std::string& error_msg) { +} + +void ProfileImportProcessClient::OnHistoryImportStart( + size_t total_history_rows_count) { +} + +void ProfileImportProcessClient::OnHistoryImportGroup( + const std::vector<history::URLRow>& history_rows_group, + int visit_source) { +} + +void ProfileImportProcessClient::OnHomePageImportReady(const GURL& home_page) { +} + +void ProfileImportProcessClient::OnBookmarksImportStart( + const std::wstring& first_folder_name, + int options, + size_t total_bookmarks_count) { +} + +void ProfileImportProcessClient::OnBookmarksImportGroup( + const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) { +} + +void ProfileImportProcessClient::OnFaviconsImportStart( + size_t total_favicons_count) { +} + +void ProfileImportProcessClient::OnFaviconsImportGroup( + const std::vector<history::ImportedFaviconUsage>& favicons_group) { +} + +void ProfileImportProcessClient::OnPasswordFormImportReady( + const webkit_glue::PasswordForm& form) { +} + +void ProfileImportProcessClient::OnKeywordsImportReady( + const std::vector<TemplateURL>& template_urls, + int default_keyword_index, + bool unique_on_host_and_path) { +} + +bool ProfileImportProcessClient::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(ProfileImportProcessClient, message) + // Notification messages about the state of the import process. + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started, + OnImportStart) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished, + OnImportFinished) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started, + OnImportItemStart) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Finished, + OnImportItemFinished) + + // Data messages containing items to be written to the user profile. + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportStart, + OnHistoryImportStart) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, + OnHistoryImportGroup) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHomePageImportReady, + OnHomePageImportReady) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportStart, + OnBookmarksImportStart) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup, + OnBookmarksImportGroup) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportStart, + OnFaviconsImportStart) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup, + OnFaviconsImportGroup) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady, + OnPasswordFormImportReady) + IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady, + OnKeywordsImportReady) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP_EX() + return handled; +} + +ProfileImportProcessClient::~ProfileImportProcessClient() { +} diff --git a/chrome/browser/importer/profile_import_process_client.h b/chrome/browser/importer/profile_import_process_client.h new file mode 100644 index 0000000..7895fdb --- /dev/null +++ b/chrome/browser/importer/profile_import_process_client.h @@ -0,0 +1,91 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_ +#define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_ +#pragma once + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" +#include "chrome/browser/importer/profile_writer.h" + +class GURL; +class TemplateURL; + +namespace history { +class URLRow; +} + +namespace IPC { +class Message; +} + +namespace webkit_glue { +struct PasswordForm; +} + +// An interface that must be implemented by consumers of the profile import +// process in order to get results back from the process host. The +// ProfileImportProcessHost calls the client's functions on the thread passed to +// it when it's created. +class ProfileImportProcessClient : + public base::RefCountedThreadSafe<ProfileImportProcessClient> { + public: + ProfileImportProcessClient(); + + // These methods are used by the ProfileImportProcessHost to pass messages + // received from the external process back to the ImportProcessClient in + // ImporterHost. + virtual void OnProcessCrashed(int exit_status); + virtual void OnImportStart(); + virtual void OnImportFinished(bool succeeded, const std::string& error_msg); + virtual void OnImportItemStart(int item); + virtual void OnImportItemFinished(int item); + virtual void OnImportItemFailed(const std::string& error_msg); + + // These methods pass back data to be written to the user's profile from + // the external process to the process host client. + virtual void OnHistoryImportStart(size_t total_history_rows_count); + virtual void OnHistoryImportGroup( + const std::vector<history::URLRow>& history_rows_group, + int visit_source); // visit_source has history::VisitSource type. + + virtual void OnHomePageImportReady(const GURL& home_page); + + virtual void OnBookmarksImportStart( + const std::wstring& first_folder_name, + int options, + size_t total_bookmarks_count); + virtual void OnBookmarksImportGroup( + const std::vector<ProfileWriter::BookmarkEntry>& bookmarks); + + virtual void OnFaviconsImportStart(size_t total_favicons_count); + virtual void OnFaviconsImportGroup( + const std::vector<history::ImportedFaviconUsage>& favicons_group); + + virtual void OnPasswordFormImportReady( + const webkit_glue::PasswordForm& form); + + virtual void OnKeywordsImportReady( + const std::vector<TemplateURL>& template_urls, + int default_keyword_index, + bool unique_on_host_and_path); + + virtual bool OnMessageReceived(const IPC::Message& message); + + protected: + friend class base::RefCountedThreadSafe<ProfileImportProcessClient>; + + virtual ~ProfileImportProcessClient(); + + private: + friend class ProfileImportProcessHost; + + DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessClient); +}; + +#endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_ diff --git a/chrome/browser/profile_import_process_host.cc b/chrome/browser/importer/profile_import_process_host.cc index 37fca53..c15dcd8 100644 --- a/chrome/browser/profile_import_process_host.cc +++ b/chrome/browser/importer/profile_import_process_host.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/profile_import_process_host.h" +#include "chrome/browser/importer/profile_import_process_host.h" #include "base/command_line.h" #include "base/message_loop.h" @@ -10,6 +10,7 @@ #include "base/values.h" #include "chrome/browser/importer/firefox_importer_utils.h" #include "chrome/browser/importer/importer_messages.h" +#include "chrome/browser/importer/profile_import_process_client.h" #include "chrome/common/chrome_switches.h" #include "grit/generated_resources.h" #include "ipc/ipc_switches.h" @@ -17,7 +18,7 @@ ProfileImportProcessHost::ProfileImportProcessHost( ResourceDispatcherHost* resource_dispatcher, - ImportProcessClient* import_process_client, + ProfileImportProcessClient* import_process_client, BrowserThread::ID thread_id) : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS, resource_dispatcher), import_process_client_(import_process_client), @@ -123,7 +124,7 @@ bool ProfileImportProcessHost::OnMessageReceived(const IPC::Message& message) { BrowserThread::PostTask( thread_id_, FROM_HERE, NewRunnableMethod(import_process_client_.get(), - &ImportProcessClient::OnMessageReceived, + &ProfileImportProcessClient::OnMessageReceived, message)); return true; } @@ -133,52 +134,10 @@ void ProfileImportProcessHost::OnProcessCrashed(int exit_code) { BrowserThread::PostTask( thread_id_, FROM_HERE, NewRunnableMethod(import_process_client_.get(), - &ImportProcessClient::OnProcessCrashed, + &ProfileImportProcessClient::OnProcessCrashed, exit_code)); } bool ProfileImportProcessHost::CanShutdown() { return true; } - -ProfileImportProcessHost::ImportProcessClient::ImportProcessClient() {} - -ProfileImportProcessHost::ImportProcessClient::~ImportProcessClient() {} - -bool ProfileImportProcessHost::ImportProcessClient::OnMessageReceived( - const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(ProfileImportProcessHost, message) - // Notification messages about the state of the import process. - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started, - ImportProcessClient::OnImportStart) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished, - ImportProcessClient::OnImportFinished) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started, - ImportProcessClient::OnImportItemStart) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Finished, - ImportProcessClient::OnImportItemFinished) - - // Data messages containing items to be written to the user profile. - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportStart, - ImportProcessClient::OnHistoryImportStart) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, - ImportProcessClient::OnHistoryImportGroup) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHomePageImportReady, - ImportProcessClient::OnHomePageImportReady) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportStart, - ImportProcessClient::OnBookmarksImportStart) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup, - ImportProcessClient::OnBookmarksImportGroup) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportStart, - ImportProcessClient::OnFaviconsImportStart) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup, - ImportProcessClient::OnFaviconsImportGroup) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady, - ImportProcessClient::OnPasswordFormImportReady) - IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady, - ImportProcessClient::OnKeywordsImportReady) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - return handled; -} diff --git a/chrome/browser/importer/profile_import_process_host.h b/chrome/browser/importer/profile_import_process_host.h new file mode 100644 index 0000000..3b01824 --- /dev/null +++ b/chrome/browser/importer/profile_import_process_host.h @@ -0,0 +1,84 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_ +#define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_ +#pragma once + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/memory/ref_counted.h" +#include "chrome/browser/history/history_types.h" +#include "chrome/browser/importer/importer_data_types.h" +#include "chrome/browser/importer/profile_writer.h" +#include "content/browser/browser_child_process_host.h" +#include "content/browser/browser_thread.h" + +class ProfileImportProcessClient; + +namespace webkit_glue { +struct PasswordForm; +} + +// Browser-side host to a profile import process. This class lives only on +// the IO thread. It passes messages back to the |thread_id_| thread through +// a client object. +class ProfileImportProcessHost : public BrowserChildProcessHost { + public: + // |resource_dispatcher| is used in the base BrowserChildProcessHost class to + // manage IPC requests. + // |import_process_client| implements callbacks which are triggered by + // incoming IPC messages. This client creates an interface between IPC + // messages received by the ProfileImportProcessHost and the internal + // importer_bridge. + // |thread_id| gives the thread where the client lives. The + // ProfileImportProcessHost spawns tasks on this thread for the client. + ProfileImportProcessHost(ResourceDispatcherHost* resource_dispatcher, + ProfileImportProcessClient* import_process_client, + BrowserThread::ID thread_id); + virtual ~ProfileImportProcessHost(); + + // |profile_info|, |items|, and |import_to_bookmark_bar| are all needed by + // the external importer process. + bool StartProfileImportProcess(const importer::ProfileInfo& profile_info, + int items, + bool import_to_bookmark_bar); + + // Cancel the external import process. + bool CancelProfileImportProcess(); + + // Report that an item has been successfully imported. We need to make + // sure that all import messages have come across the wire before the + // external import process shuts itself down. + bool ReportImportItemFinished(importer::ImportItem item); + + protected: + // This method is virtual to be overridden by tests. + virtual FilePath GetProfileImportProcessCmd(); + + private: + // Launch the new process. + bool StartProcess(); + + // Called by the external importer process to send messages back to the + // ImportProcessClient. + virtual bool OnMessageReceived(const IPC::Message& message); + + // BrowserChildProcessHost: + virtual void OnProcessCrashed(int exit_code) OVERRIDE; + virtual bool CanShutdown() OVERRIDE; + + // Receives messages to be passed back to the importer host. + scoped_refptr<ProfileImportProcessClient> import_process_client_; + + // The thread where the import_process_client_ lives. + BrowserThread::ID thread_id_; + + DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessHost); +}; + +#endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_ diff --git a/chrome/browser/profile_import_process_host.h b/chrome/browser/profile_import_process_host.h deleted file mode 100644 index 24e7dae..0000000 --- a/chrome/browser/profile_import_process_host.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_PROFILE_IMPORT_PROCESS_HOST_H_ -#define CHROME_BROWSER_PROFILE_IMPORT_PROCESS_HOST_H_ -#pragma once - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "chrome/browser/history/history_types.h" -#include "chrome/browser/importer/importer_data_types.h" -#include "chrome/browser/importer/profile_writer.h" -#include "content/browser/browser_child_process_host.h" -#include "content/browser/browser_thread.h" - -namespace webkit_glue { -struct PasswordForm; -} - -// Browser-side host to a profile import process. This class lives only on -// the IO thread. It passes messages back to the |thread_id_| thread through -// a client object. -class ProfileImportProcessHost : public BrowserChildProcessHost { - public: - - // An interface that must be implemented by consumers of the profile import - // process in order to get results back from the process host. The - // ProfileImportProcessHost calls the client's functions on the thread passed - // to it when it's created. - class ImportProcessClient : - public base::RefCountedThreadSafe<ImportProcessClient> { - public: - ImportProcessClient(); - - // These methods are used by the ProfileImportProcessHost to pass messages - // received from the external process back to the ImportProcessClient in - // ImporterHost. - virtual void OnProcessCrashed(int exit_status) {} - virtual void OnImportStart() {} - virtual void OnImportFinished(bool succeeded, - const std::string& error_msg) {} - virtual void OnImportItemStart(int item) {} - virtual void OnImportItemFinished(int item) {} - virtual void OnImportItemFailed(const std::string& error_msg) {} - - // These methods pass back data to be written to the user's profile from - // the external process to the process host client. - virtual void OnHistoryImportStart(size_t total_history_rows_count) {} - virtual void OnHistoryImportGroup( - const std::vector<history::URLRow> &history_rows_group, - int visit_source) {} // visit_source has history::VisitSource type. - - virtual void OnHomePageImportReady( - const GURL& home_page) {} - - virtual void OnBookmarksImportStart(const std::wstring& first_folder_name, - int options, - size_t total_bookmarks_count) {} - virtual void OnBookmarksImportGroup( - const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) {} - - virtual void OnFaviconsImportStart(size_t total_favicons_count) {} - virtual void OnFaviconsImportGroup( - const std::vector<history::ImportedFaviconUsage>& favicons_group) {} - - virtual void OnPasswordFormImportReady( - const webkit_glue::PasswordForm& form) {} - - virtual void OnKeywordsImportReady( - const std::vector<TemplateURL>& template_urls, - int default_keyword_index, bool unique_on_host_and_path) {} - - virtual bool OnMessageReceived(const IPC::Message& message); - - protected: - friend class base::RefCountedThreadSafe<ImportProcessClient>; - - virtual ~ImportProcessClient(); - - private: - friend class ProfileImportProcessHost; - - DISALLOW_COPY_AND_ASSIGN(ImportProcessClient); - }; - - // |resource_dispatcher| is used in the base BrowserChildProcessHost class to - // manage IPC requests. - // |import_process_client| implements callbacks which are triggered by - // incoming IPC messages. This client creates an interface between IPC - // messages received by the ProfileImportProcessHost and the internal - // importer_bridge. - // |thread_id| gives the thread where the client lives. The - // ProfileImportProcessHost spawns tasks on this thread for the client. - ProfileImportProcessHost(ResourceDispatcherHost* resource_dispatcher, - ImportProcessClient* import_process_client, - BrowserThread::ID thread_id); - virtual ~ProfileImportProcessHost(); - - // |profile_info|, |items|, and |import_to_bookmark_bar| are all needed by - // the external importer process. - bool StartProfileImportProcess(const importer::ProfileInfo& profile_info, - int items, bool import_to_bookmark_bar); - - // Cancel the external import process. - bool CancelProfileImportProcess(); - - // Report that an item has been successfully imported. We need to make - // sure that all import messages have come across the wire before the - // external import process shuts itself down. - bool ReportImportItemFinished(importer::ImportItem item); - - protected: - // Allow these methods to be overridden for tests. - virtual FilePath GetProfileImportProcessCmd(); - - private: - // Launch the new process. - bool StartProcess(); - - // Called by the external importer process to send messages back to the - // ImportProcessClient. - virtual bool OnMessageReceived(const IPC::Message& message); - - // Overridden from BrowserChildProcessHost: - virtual void OnProcessCrashed(int exit_code); - virtual bool CanShutdown(); - - // Receives messages to be passed back to the importer host. - scoped_refptr<ImportProcessClient> import_process_client_; - - // The thread where the import_process_client_ lives. - BrowserThread::ID thread_id_; - - DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessHost); -}; - -#endif // CHROME_BROWSER_PROFILE_IMPORT_PROCESS_HOST_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 38f26c5..05d2edf 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1204,6 +1204,10 @@ 'browser/importer/nss_decryptor_system_nss.h', 'browser/importer/nss_decryptor_win.cc', 'browser/importer/nss_decryptor_win.h', + 'browser/importer/profile_import_process_client.cc', + 'browser/importer/profile_import_process_client.h', + 'browser/importer/profile_import_process_host.cc', + 'browser/importer/profile_import_process_host.h', 'browser/importer/profile_writer.cc', 'browser/importer/profile_writer.h', 'browser/importer/safari_importer.h', @@ -1626,8 +1630,6 @@ 'browser/process_singleton_linux.cc', 'browser/process_singleton_mac.cc', 'browser/process_singleton_win.cc', - 'browser/profile_import_process_host.cc', - 'browser/profile_import_process_host.h', 'browser/profiles/off_the_record_profile_io_data.cc', 'browser/profiles/off_the_record_profile_io_data.h', 'browser/profiles/profile.cc', |