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

Side by Side Diff: chrome/utility/importer/external_process_importer_bridge.h

Issue 2470283002: Convert profile import IPCs to Mojo (Closed)
Patch Set: Address review comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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
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
39
40 // TODO(tibell): Now when profile import is a Mojo service perhaps ImportBride,
gab 2016/11/08 13:34:25 s/when/that/ ?
Sam McNally 2016/11/09 22:31:27 ImportBride?
tibell 2016/11/09 23:08:41 Done.
tibell 2016/11/09 23:08:41 Done.
41 // ProfileWriter or something in between should be the actual Mojo interface,
42 // instead of having the current split.
38 43
39 // When the importer is run in an external process, the bridge is effectively 44 // 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 45 // split in half by the IPC infrastructure. The external bridge receives data
41 // and notifications from the importer, and sends it across IPC. The 46 // 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 47 // internal bridge gathers the data from the IPC host and writes it to the
43 // profile. 48 // profile.
44 class ExternalProcessImporterBridge : public ImporterBridge { 49 class ExternalProcessImporterBridge : public ImporterBridge {
45 public: 50 public:
46 ExternalProcessImporterBridge( 51 // |observer| must outlive this object.
gab 2016/11/08 13:34:25 |observer| and |task_runner| must outlive this obj
Sam McNally 2016/11/09 22:31:27 |task_runner| ends up in a scoped_refptr field so
tibell 2016/11/09 23:08:41 Done.
tibell 2016/11/09 23:08:41 I went with Sam's suggestion and instead changed t
47 const base::DictionaryValue& localized_strings, 52 ExternalProcessImporterBridge(const base::DictionaryValue& localized_strings,
48 IPC::Sender* sender, 53 base::TaskRunner* task_runner,
49 base::TaskRunner* task_runner); 54 chrome::mojom::ProfileImportObserver* observer);
50 55
51 // Begin ImporterBridge implementation: 56 // Begin ImporterBridge implementation:
52 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, 57 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
53 const base::string16& first_folder_name) override; 58 const base::string16& first_folder_name) override;
54 59
55 void AddHomePage(const GURL& home_page) override; 60 void AddHomePage(const GURL& home_page) override;
56 61
57 #if defined(OS_WIN) 62 #if defined(OS_WIN)
58 void AddIE7PasswordInfo( 63 void AddIE7PasswordInfo(
59 const importer::ImporterIE7PasswordInfo& password_info) override; 64 const importer::ImporterIE7PasswordInfo& password_info) override;
(...skipping 20 matching lines...) Expand all
80 void NotifyItemStarted(importer::ImportItem item) override; 85 void NotifyItemStarted(importer::ImportItem item) override;
81 void NotifyItemEnded(importer::ImportItem item) override; 86 void NotifyItemEnded(importer::ImportItem item) override;
82 void NotifyEnded() override; 87 void NotifyEnded() override;
83 88
84 base::string16 GetLocalizedString(int message_id) override; 89 base::string16 GetLocalizedString(int message_id) override;
85 // End ImporterBridge implementation. 90 // End ImporterBridge implementation.
86 91
87 private: 92 private:
88 ~ExternalProcessImporterBridge() override; 93 ~ExternalProcessImporterBridge() override;
89 94
90 void Send(IPC::Message* message); 95 // Helper to send messages through |observer_| on the right thread. First
91 void SendInternal(IPC::Message* message); 96 // argument should be a method on chrome::mojom::ProfileImportObserver and the
97 // remaining arguments should be the arguments to pass to that method.
98 template <typename Functor, typename... Args>
99 void Send(Functor&& functor, Args&&... args);
92 100
93 // Holds strings needed by the external importer because the resource 101 // Holds strings needed by the external importer because the resource
94 // bundle isn't available to the external process. 102 // bundle isn't available to the external process.
95 std::unique_ptr<base::DictionaryValue> localized_strings_; 103 std::unique_ptr<base::DictionaryValue> localized_strings_;
96 104
97 IPC::Sender* sender_; 105 // The task runner that |observer_| methods must be called on.
98 scoped_refptr<base::TaskRunner> task_runner_; 106 scoped_refptr<base::TaskRunner> task_runner_;
99 107
108 chrome::mojom::ProfileImportObserver* observer_;
109
100 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); 110 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge);
101 }; 111 };
102 112
103 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ 113 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698