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

Unified Diff: chrome/utility/profile_import_handler.cc

Issue 2470283002: Convert profile import IPCs to Mojo (Closed)
Patch Set: Merge Created 4 years 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
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..3ec913dca319ac607f6ee468f8eec7e8580adeb1 100644
--- a/chrome/utility/profile_import_handler.cc
+++ b/chrome/utility/profile_import_handler.cc
@@ -11,49 +11,34 @@
#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);
-}
-
-} // namespace
+using chrome::mojom::ThreadSafeProfileImportObserverPtr;
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;
+// static
+void ProfileImportHandler::Create(
+ mojo::InterfaceRequest<chrome::mojom::ProfileImport> request) {
+ mojo::MakeStrongBinding(base::MakeUnique<ProfileImportHandler>(),
+ std::move(request));
}
-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) {
content::UtilityThread::Get()->EnsureBlinkInitialized();
- bridge_ = new ExternalProcessImporterBridge(
- localized_strings,
- content::UtilityThread::Get(),
- base::ThreadTaskRunnerHandle::Get().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;
}
@@ -68,20 +53,21 @@ void ProfileImportHandler::OnImportStart(
NOTREACHED();
ImporterCleanup();
}
+ bridge_ = new ExternalProcessImporterBridge(
+ localized_strings,
+ ThreadSafeProfileImportObserverPtr::Create(std::move(observer)));
import_thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&Importer::StartImport, importer_,
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()));
ImporterCleanup();
}
}
« no previous file with comments | « chrome/utility/profile_import_handler.h ('k') | mojo/public/tools/bindings/chromium_bindings_configuration.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698