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

Side by Side Diff: chrome/browser/importer/importer_host.h

Issue 6679004: importer: Pull ExternalProcessImporterClient out of ImporterHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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_IMPORTER_HOST_H_ 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
6 #define CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_ 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 16 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
17 #include "chrome/browser/importer/importer_data_types.h" 17 #include "chrome/browser/importer/importer_data_types.h"
18 #include "chrome/browser/importer/importer_list.h" 18 #include "chrome/browser/importer/importer_list.h"
19 #include "chrome/browser/importer/profile_writer.h" 19 #include "chrome/browser/importer/profile_writer.h"
20 #include "chrome/browser/profile_import_process_host.h"
21 #include "content/common/notification_observer.h" 20 #include "content/common/notification_observer.h"
22 #include "content/common/notification_registrar.h" 21 #include "content/common/notification_registrar.h"
23 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
24 23
25 class ExternalProcessImporterClient; 24 class ExternalProcessImporterClient;
26 class FirefoxProfileLock; 25 class FirefoxProfileLock;
27 class GURL; 26 class GURL;
28 class Importer; 27 class Importer;
29 class InProcessImporterBridge; 28 class InProcessImporterBridge;
30 class Profile; 29 class Profile;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 214
216 // True if the import process has been launched. This prevents race 215 // True if the import process has been launched. This prevents race
217 // conditions on import cancel. 216 // conditions on import cancel.
218 bool import_process_launched_; 217 bool import_process_launched_;
219 218
220 // End of external importer data -------------------------------------------- 219 // End of external importer data --------------------------------------------
221 220
222 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterHost); 221 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterHost);
223 }; 222 };
224 223
225 // This class is the client for the ProfileImportProcessHost. It collects
226 // notifications from this process host and feeds data back to the importer
227 // host, who actually does the writing.
228 class ExternalProcessImporterClient
229 : public ProfileImportProcessHost::ImportProcessClient {
230 public:
231 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host,
232 const importer::ProfileInfo& profile_info,
233 int items,
234 InProcessImporterBridge* bridge,
235 bool import_to_bookmark_bar);
236
237 ~ExternalProcessImporterClient();
238
239 // Launches the task to start the external process.
240 virtual void Start();
241
242 // Creates a new ProfileImportProcessHost, which launches the import process.
243 virtual void StartProcessOnIOThread(ResourceDispatcherHost* rdh,
244 BrowserThread::ID thread_id);
245
246 // Called by the ExternalProcessImporterHost on import cancel.
247 virtual void Cancel();
248
249 // Cancel import process on IO thread.
250 void CancelImportProcessOnIOThread();
251
252 // Report item completely downloaded on IO thread.
253 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item);
254
255 // Cancel import on process crash.
256 virtual void OnProcessCrashed(int exit_code);
257
258 // Notifies the importerhost that import has finished, and calls Release().
259 void Cleanup();
260
261 // ProfileImportProcessHost messages ----------------------------------------
262 // The following methods are called by ProfileImportProcessHost when the
263 // corresponding message has been received from the import process.
264 virtual void OnImportStart();
265 virtual void OnImportFinished(bool succeeded, std::string error_msg);
266 virtual void OnImportItemStart(int item_data);
267 virtual void OnImportItemFinished(int item_data);
268
269 // Called on first message received when importing history; gives total
270 // number of rows to be imported.
271 virtual void OnHistoryImportStart(size_t total_history_rows_count);
272
273 // Called when a group of URLRows has been received.
274 // The source is passed with history::VisitSource type.
275 virtual void OnHistoryImportGroup(
276 const std::vector<history::URLRow> &history_rows_group,
277 int visit_source);
278
279 // Called when the home page has been received.
280 virtual void OnHomePageImportReady(const GURL& home_page);
281
282 // First message received when importing bookmarks.
283 // |first_folder_name| can be NULL.
284 // |options| is described in ProfileWriter::BookmarkOptions.
285 // |total_bookmarks_count| is the total number of bookmarks to be imported.
286 virtual void OnBookmarksImportStart(
287 const std::wstring first_folder_name,
288 int options, size_t total_bookmarks_count);
289
290 // Called when a group of bookmarks has been received.
291 virtual void OnBookmarksImportGroup(
292 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group);
293
294 // First message received when importing favicons. |total_fav_icons_size|
295 // gives the total number of fav icons to be imported.
296 virtual void OnFavIconsImportStart(size_t total_fav_icons_count);
297
298 // Called when a group of favicons has been received.
299 virtual void OnFavIconsImportGroup(
300 const std::vector<history::ImportedFavIconUsage>& fav_icons_group);
301
302 // Called when the passwordform has been received.
303 virtual void OnPasswordFormImportReady(
304 const webkit_glue::PasswordForm& form);
305
306 // Called when search engines have been received.
307 virtual void OnKeywordsImportReady(
308 const std::vector<TemplateURL>& template_urls,
309 int default_keyword_index, bool unique_on_host_and_path);
310
311 // End ProfileImportProcessHost messages ------------------------------------
312
313 private:
314 // These variables store data being collected from the importer until the
315 // entire group has been collected and is ready to be written to the profile.
316 std::vector<history::URLRow> history_rows_;
317 std::vector<ProfileWriter::BookmarkEntry> bookmarks_;
318 std::vector<history::ImportedFavIconUsage> fav_icons_;
319
320 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder
321 // under which imported bookmarks will be placed.
322 std::wstring bookmarks_first_folder_name_;
323
324 // Determines how bookmarks should be added (ProfileWriter::BookmarkOptions).
325 int bookmarks_options_;
326
327 // Total number of bookmarks to import.
328 size_t total_bookmarks_count_;
329
330 // Total number of history items to import.
331 size_t total_history_rows_count_;
332
333 // Total number of fav icons to import.
334 size_t total_fav_icons_count_;
335
336 // Notifications received from the ProfileImportProcessHost are passed back
337 // to process_importer_host_, which calls the ProfileWriter to record the
338 // import data. When the import process is done, process_importer_host_
339 // deletes itself.
340 ExternalProcessImporterHost* process_importer_host_;
341
342 // Handles sending messages to the external process. Deletes itself when
343 // the external process dies (see ChildProcessHost::OnChildDied).
344 ProfileImportProcessHost* profile_import_process_host_;
345
346 // Data to be passed from the importer host to the external importer.
347 const importer::ProfileInfo& profile_info_;
348 int items_;
349 bool import_to_bookmark_bar_;
350
351 // Takes import data coming over IPC and delivers it to be written by the
352 // ProfileWriter. Released by ExternalProcessImporterClient in its
353 // destructor.
354 InProcessImporterBridge* bridge_;
355
356 // True if import process has been cancelled.
357 bool cancelled_;
358
359 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient);
360 };
361
362 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_ 224 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/importer/external_process_importer_client.cc ('k') | chrome/browser/importer/importer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698