Chromium Code Reviews| Index: chrome/utility/importer/external_process_importer_bridge.h |
| diff --git a/chrome/utility/importer/external_process_importer_bridge.h b/chrome/utility/importer/external_process_importer_bridge.h |
| index 0a22e7e50f69be187e50467b60547ed4382dd5b5..f728a44a3223ac38f5e62b643eb1c083037dac1f 100644 |
| --- a/chrome/utility/importer/external_process_importer_bridge.h |
| +++ b/chrome/utility/importer/external_process_importer_bridge.h |
| @@ -31,10 +31,15 @@ struct ImporterURLRow; |
| struct SearchEngineInfo; |
| } |
| -namespace IPC { |
| -class Message; |
| -class Sender; |
| -} |
| +namespace chrome { |
| +namespace mojom { |
| +class ProfileImportObserver; |
| +} // namespace mojom |
| +} // namespace chrome |
| + |
| +// TODO(tibell): Now that profile import is a Mojo service perhaps ImportBridge, |
| +// ProfileWriter or something in between should be the actual Mojo interface, |
| +// instead of having the current split. |
| // When the importer is run in an external process, the bridge is effectively |
| // split in half by the IPC infrastructure. The external bridge receives data |
| @@ -43,10 +48,10 @@ class Sender; |
| // profile. |
| class ExternalProcessImporterBridge : public ImporterBridge { |
| public: |
| - ExternalProcessImporterBridge( |
| - const base::DictionaryValue& localized_strings, |
| - IPC::Sender* sender, |
| - base::TaskRunner* task_runner); |
| + // |observer| must outlive this object. |
| + ExternalProcessImporterBridge(const base::DictionaryValue& localized_strings, |
| + scoped_refptr<base::TaskRunner> task_runner, |
| + chrome::mojom::ProfileImportObserver* observer); |
| // Begin ImporterBridge implementation: |
| void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, |
| @@ -87,16 +92,21 @@ class ExternalProcessImporterBridge : public ImporterBridge { |
| private: |
| ~ExternalProcessImporterBridge() override; |
| - void Send(IPC::Message* message); |
| - void SendInternal(IPC::Message* message); |
| + // Helper to send messages through |observer_| on the right thread. First |
| + // argument should be a method on chrome::mojom::ProfileImportObserver and the |
| + // remaining arguments should be the arguments to pass to that method. |
| + template <typename Functor, typename... Args> |
| + void Send(Functor&& functor, Args&&... args); |
|
dcheng
2016/11/11 08:46:50
I'm not a fan of these sorts of helpers.
Dumb que
tibell
2016/11/14 05:35:31
I discussed this with Sam earlier in the review. M
|
| // Holds strings needed by the external importer because the resource |
| // bundle isn't available to the external process. |
| std::unique_ptr<base::DictionaryValue> localized_strings_; |
| - IPC::Sender* sender_; |
| + // The task runner that |observer_| methods must be called on. |
| scoped_refptr<base::TaskRunner> task_runner_; |
| + chrome::mojom::ProfileImportObserver* observer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); |
| }; |