OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 // This class is the client for the ProfileImportProcessHost. It collects | 29 // This class is the client for the ProfileImportProcessHost. It collects |
30 // notifications from this process host and feeds data back to the importer | 30 // notifications from this process host and feeds data back to the importer |
31 // host, who actually does the writing. | 31 // host, who actually does the writing. |
32 class ExternalProcessImporterClient : public ProfileImportProcessClient { | 32 class ExternalProcessImporterClient : public ProfileImportProcessClient { |
33 public: | 33 public: |
34 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, | 34 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, |
35 const importer::SourceProfile& source_profile, | 35 const importer::SourceProfile& source_profile, |
36 uint16 items, | 36 uint16 items, |
37 InProcessImporterBridge* bridge, | 37 InProcessImporterBridge* bridge); |
38 bool import_to_bookmark_bar); | |
39 virtual ~ExternalProcessImporterClient(); | 38 virtual ~ExternalProcessImporterClient(); |
40 | 39 |
41 // Cancel import process on IO thread. | 40 // Cancel import process on IO thread. |
42 void CancelImportProcessOnIOThread(); | 41 void CancelImportProcessOnIOThread(); |
43 | 42 |
44 // Report item completely downloaded on IO thread. | 43 // Report item completely downloaded on IO thread. |
45 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); | 44 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); |
46 | 45 |
47 // Notifies the importerhost that import has finished, and calls Release(). | 46 // Notifies the importerhost that import has finished, and calls Release(). |
48 void Cleanup(); | 47 void Cleanup(); |
(...skipping 22 matching lines...) Expand all Loading... |
71 // Called when a group of URLRows has been received. | 70 // Called when a group of URLRows has been received. |
72 virtual void OnHistoryImportGroup( | 71 virtual void OnHistoryImportGroup( |
73 const std::vector<history::URLRow>& history_rows_group, | 72 const std::vector<history::URLRow>& history_rows_group, |
74 int visit_source) OVERRIDE; | 73 int visit_source) OVERRIDE; |
75 | 74 |
76 // Called when the home page has been received. | 75 // Called when the home page has been received. |
77 virtual void OnHomePageImportReady(const GURL& home_page) OVERRIDE; | 76 virtual void OnHomePageImportReady(const GURL& home_page) OVERRIDE; |
78 | 77 |
79 // First message received when importing bookmarks. | 78 // First message received when importing bookmarks. |
80 // |first_folder_name| can be NULL. | 79 // |first_folder_name| can be NULL. |
81 // |options| is described in ProfileWriter::BookmarkOptions. | |
82 // |total_bookmarks_count| is the total number of bookmarks to be imported. | 80 // |total_bookmarks_count| is the total number of bookmarks to be imported. |
83 virtual void OnBookmarksImportStart(const string16& first_folder_name, | 81 virtual void OnBookmarksImportStart(const string16& first_folder_name, |
84 int options, | |
85 size_t total_bookmarks_count) OVERRIDE; | 82 size_t total_bookmarks_count) OVERRIDE; |
86 | 83 |
87 // Called when a group of bookmarks has been received. | 84 // Called when a group of bookmarks has been received. |
88 virtual void OnBookmarksImportGroup( | 85 virtual void OnBookmarksImportGroup( |
89 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group) | 86 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group) |
90 OVERRIDE; | 87 OVERRIDE; |
91 | 88 |
92 // First message received when importing favicons. |total_favicons_size| | 89 // First message received when importing favicons. |total_favicons_size| |
93 // gives the total number of favicons to be imported. | 90 // gives the total number of favicons to be imported. |
94 virtual void OnFaviconsImportStart(size_t total_favicons_count) OVERRIDE; | 91 virtual void OnFaviconsImportStart(size_t total_favicons_count) OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... |
114 // These variables store data being collected from the importer until the | 111 // These variables store data being collected from the importer until the |
115 // entire group has been collected and is ready to be written to the profile. | 112 // entire group has been collected and is ready to be written to the profile. |
116 std::vector<history::URLRow> history_rows_; | 113 std::vector<history::URLRow> history_rows_; |
117 std::vector<ProfileWriter::BookmarkEntry> bookmarks_; | 114 std::vector<ProfileWriter::BookmarkEntry> bookmarks_; |
118 std::vector<history::ImportedFaviconUsage> favicons_; | 115 std::vector<history::ImportedFaviconUsage> favicons_; |
119 | 116 |
120 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder | 117 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder |
121 // under which imported bookmarks will be placed. | 118 // under which imported bookmarks will be placed. |
122 string16 bookmarks_first_folder_name_; | 119 string16 bookmarks_first_folder_name_; |
123 | 120 |
124 // Determines how bookmarks should be added (ProfileWriter::BookmarkOptions). | |
125 int bookmarks_options_; | |
126 | |
127 // Total number of bookmarks to import. | 121 // Total number of bookmarks to import. |
128 size_t total_bookmarks_count_; | 122 size_t total_bookmarks_count_; |
129 | 123 |
130 // Total number of history items to import. | 124 // Total number of history items to import. |
131 size_t total_history_rows_count_; | 125 size_t total_history_rows_count_; |
132 | 126 |
133 // Total number of favicons to import. | 127 // Total number of favicons to import. |
134 size_t total_favicons_count_; | 128 size_t total_favicons_count_; |
135 | 129 |
136 // Notifications received from the ProfileImportProcessHost are passed back | 130 // Notifications received from the ProfileImportProcessHost are passed back |
137 // to process_importer_host_, which calls the ProfileWriter to record the | 131 // to process_importer_host_, which calls the ProfileWriter to record the |
138 // import data. When the import process is done, process_importer_host_ | 132 // import data. When the import process is done, process_importer_host_ |
139 // deletes itself. | 133 // deletes itself. |
140 ExternalProcessImporterHost* process_importer_host_; | 134 ExternalProcessImporterHost* process_importer_host_; |
141 | 135 |
142 // Handles sending messages to the external process. Deletes itself when | 136 // Handles sending messages to the external process. Deletes itself when |
143 // the external process dies (see ChildProcessHost::OnChildDied). | 137 // the external process dies (see ChildProcessHost::OnChildDied). |
144 ProfileImportProcessHost* profile_import_process_host_; | 138 ProfileImportProcessHost* profile_import_process_host_; |
145 | 139 |
146 // Data to be passed from the importer host to the external importer. | 140 // Data to be passed from the importer host to the external importer. |
147 const importer::SourceProfile& source_profile_; | 141 const importer::SourceProfile& source_profile_; |
148 uint16 items_; | 142 uint16 items_; |
149 bool import_to_bookmark_bar_; | |
150 | 143 |
151 // Takes import data coming over IPC and delivers it to be written by the | 144 // Takes import data coming over IPC and delivers it to be written by the |
152 // ProfileWriter. Released by ExternalProcessImporterClient in its | 145 // ProfileWriter. Released by ExternalProcessImporterClient in its |
153 // destructor. | 146 // destructor. |
154 InProcessImporterBridge* bridge_; | 147 InProcessImporterBridge* bridge_; |
155 | 148 |
156 // True if import process has been cancelled. | 149 // True if import process has been cancelled. |
157 bool cancelled_; | 150 bool cancelled_; |
158 | 151 |
159 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); | 152 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); |
160 }; | 153 }; |
161 | 154 |
162 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 155 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
OLD | NEW |