Index: chrome/utility/profile_import_handler.cc |
diff --git a/chrome/utility/profile_import_handler.cc b/chrome/utility/profile_import_handler.cc |
index ba2d45b3cb537879ebac240a77c7b098ba1ad92a..7f4f87a0728a085a032a92decdc86e0214b1a7e7 100644 |
--- a/chrome/utility/profile_import_handler.cc |
+++ b/chrome/utility/profile_import_handler.cc |
@@ -11,49 +11,36 @@ |
#include "base/threading/thread.h" |
#include "base/threading/thread_task_runner_handle.h" |
#include "build/build_config.h" |
-#include "chrome/common/importer/profile_import_process_messages.h" |
#include "chrome/utility/importer/external_process_importer_bridge.h" |
#include "chrome/utility/importer/importer.h" |
#include "chrome/utility/importer/importer_creator.h" |
#include "content/public/utility/utility_thread.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
-namespace { |
- |
-bool Send(IPC::Message* message) { |
- return content::UtilityThread::Get()->Send(message); |
+// static |
+void ProfileImportHandler::Create( |
+ mojo::InterfaceRequest<chrome::mojom::ProfileImport> request) { |
+ mojo::MakeStrongBinding(base::MakeUnique<ProfileImportHandler>(), |
+ std::move(request)); |
} |
-} // namespace |
- |
ProfileImportHandler::ProfileImportHandler() : items_to_import_(0) {} |
ProfileImportHandler::~ProfileImportHandler() {} |
-bool ProfileImportHandler::OnMessageReceived(const IPC::Message& message) { |
- bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(ProfileImportHandler, message) |
- IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_StartImport, OnImportStart) |
- IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_CancelImport, OnImportCancel) |
- IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_ReportImportItemFinished, |
- OnImportItemFinished) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
- IPC_END_MESSAGE_MAP() |
- return handled; |
-} |
- |
-void ProfileImportHandler::OnImportStart( |
+void ProfileImportHandler::StartImport( |
const importer::SourceProfile& source_profile, |
uint16_t items, |
- const base::DictionaryValue& localized_strings) { |
+ const base::DictionaryValue& localized_strings, |
+ chrome::mojom::ProfileImportObserverPtr observer) { |
+ observer_ = std::move(observer); |
content::UtilityThread::Get()->EnsureBlinkInitialized(); |
bridge_ = new ExternalProcessImporterBridge( |
- localized_strings, |
- content::UtilityThread::Get(), |
- base::ThreadTaskRunnerHandle::Get().get()); |
+ localized_strings, base::ThreadTaskRunnerHandle::Get().get(), |
+ observer_.get()); |
importer_ = importer::CreateImporterByType(source_profile.importer_type); |
if (!importer_.get()) { |
- Send(new ProfileImportProcessHostMsg_Import_Finished( |
- false, "Importer could not be created.")); |
+ observer_->OnImportFinished(false, "Importer could not be created."); |
return; |
} |
@@ -73,15 +60,15 @@ void ProfileImportHandler::OnImportStart( |
source_profile, items, base::RetainedRef(bridge_))); |
} |
-void ProfileImportHandler::OnImportCancel() { |
+void ProfileImportHandler::CancelImport() { |
ImporterCleanup(); |
} |
-void ProfileImportHandler::OnImportItemFinished(uint16_t item) { |
+void ProfileImportHandler::ReportImportItemFinished(importer::ImportItem item) { |
items_to_import_ ^= item; // Remove finished item from mask. |
// If we've finished with all items, notify the browser process. |
if (items_to_import_ == 0) { |
- Send(new ProfileImportProcessHostMsg_Import_Finished(true, std::string())); |
+ observer_->OnImportFinished(true, std::string()); |
ImporterCleanup(); |
} |
} |