Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| 6 #define CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 6 #define CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace importer { | 26 namespace importer { |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 struct ImporterIE7PasswordInfo; | 28 struct ImporterIE7PasswordInfo; |
| 29 #endif | 29 #endif |
| 30 struct ImporterURLRow; | 30 struct ImporterURLRow; |
| 31 struct SearchEngineInfo; | 31 struct SearchEngineInfo; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace IPC { | 34 namespace chrome { |
| 35 class Message; | 35 namespace mojom { |
| 36 class Sender; | 36 class ProfileImportObserver; |
| 37 } | 37 } // namespace mojom |
| 38 } // namespace chrome | |
| 38 | 39 |
| 39 // When the importer is run in an external process, the bridge is effectively | 40 // When the importer is run in an external process, the bridge is effectively |
| 40 // split in half by the IPC infrastructure. The external bridge receives data | 41 // split in half by the IPC infrastructure. The external bridge receives data |
| 41 // and notifications from the importer, and sends it across IPC. The | 42 // and notifications from the importer, and sends it across IPC. The |
| 42 // internal bridge gathers the data from the IPC host and writes it to the | 43 // internal bridge gathers the data from the IPC host and writes it to the |
| 43 // profile. | 44 // profile. |
| 44 class ExternalProcessImporterBridge : public ImporterBridge { | 45 class ExternalProcessImporterBridge : public ImporterBridge { |
|
Sam McNally
2016/11/07 06:31:07
It feels like ImporterBridge, ProfileWriter or som
tibell
2016/11/07 23:34:24
Done.
| |
| 45 public: | 46 public: |
| 46 ExternalProcessImporterBridge( | 47 // |observer| must outlive this object. |
| 47 const base::DictionaryValue& localized_strings, | 48 ExternalProcessImporterBridge(const base::DictionaryValue& localized_strings, |
| 48 IPC::Sender* sender, | 49 base::TaskRunner* task_runner, |
| 49 base::TaskRunner* task_runner); | 50 chrome::mojom::ProfileImportObserver* observer); |
| 50 | 51 |
| 51 // Begin ImporterBridge implementation: | 52 // Begin ImporterBridge implementation: |
| 52 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, | 53 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, |
| 53 const base::string16& first_folder_name) override; | 54 const base::string16& first_folder_name) override; |
| 54 | 55 |
| 55 void AddHomePage(const GURL& home_page) override; | 56 void AddHomePage(const GURL& home_page) override; |
| 56 | 57 |
| 57 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 58 void AddIE7PasswordInfo( | 59 void AddIE7PasswordInfo( |
| 59 const importer::ImporterIE7PasswordInfo& password_info) override; | 60 const importer::ImporterIE7PasswordInfo& password_info) override; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 80 void NotifyItemStarted(importer::ImportItem item) override; | 81 void NotifyItemStarted(importer::ImportItem item) override; |
| 81 void NotifyItemEnded(importer::ImportItem item) override; | 82 void NotifyItemEnded(importer::ImportItem item) override; |
| 82 void NotifyEnded() override; | 83 void NotifyEnded() override; |
| 83 | 84 |
| 84 base::string16 GetLocalizedString(int message_id) override; | 85 base::string16 GetLocalizedString(int message_id) override; |
| 85 // End ImporterBridge implementation. | 86 // End ImporterBridge implementation. |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 ~ExternalProcessImporterBridge() override; | 89 ~ExternalProcessImporterBridge() override; |
| 89 | 90 |
| 90 void Send(IPC::Message* message); | 91 // Helper to send messages through |observer_| on the right thread. First |
| 91 void SendInternal(IPC::Message* message); | 92 // argument should be a method on chrome::mojom::ProfileImportObserver and the |
| 93 // remaining arguments should be the arguments to pass to that method. | |
| 94 template <typename Functor, typename... Args> | |
| 95 void Send(Functor&& functor, Args&&... args); | |
| 92 | 96 |
| 93 // Holds strings needed by the external importer because the resource | 97 // Holds strings needed by the external importer because the resource |
| 94 // bundle isn't available to the external process. | 98 // bundle isn't available to the external process. |
| 95 std::unique_ptr<base::DictionaryValue> localized_strings_; | 99 std::unique_ptr<base::DictionaryValue> localized_strings_; |
| 96 | 100 |
| 97 IPC::Sender* sender_; | 101 // The task runner that |observer_| methods must be called on. |
| 98 scoped_refptr<base::TaskRunner> task_runner_; | 102 scoped_refptr<base::TaskRunner> task_runner_; |
| 99 | 103 |
| 104 chrome::mojom::ProfileImportObserver* observer_; | |
| 105 | |
| 100 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); | 106 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 109 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| OLD | NEW |