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

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

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 7 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) 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_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 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/history/history_types.h"
15 #include "chrome/browser/importer/importer_data_types.h" 16 #include "chrome/browser/importer/importer_data_types.h"
16 #include "chrome/browser/importer/profile_writer.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/utility_process_host_client.h" 18 #include "content/public/browser/utility_process_host_client.h"
19 19
20 class ExternalProcessImporterHost; 20 class ExternalProcessImporterHost;
21 struct ImportedBookmarkEntry;
21 class InProcessImporterBridge; 22 class InProcessImporterBridge;
23 class TemplateURL;
22 24
23 namespace content { 25 namespace content {
26 struct PasswordForm;
24 class UtilityProcessHost; 27 class UtilityProcessHost;
25 } 28 }
26 29
27 namespace history { 30 namespace history {
28 class URLRow;
29 struct ImportedFaviconUsage; 31 struct ImportedFaviconUsage;
30 } 32 }
31 33
32 // This class is the client for the out of process profile importing. It 34 // This class is the client for the out of process profile importing. It
33 // collects notifications from this process host and feeds data back to the 35 // collects notifications from this process host and feeds data back to the
34 // importer host, who actually does the writing. 36 // importer host, who actually does the writing.
35 class ExternalProcessImporterClient : public content::UtilityProcessHostClient { 37 class ExternalProcessImporterClient : public content::UtilityProcessHostClient {
36 public: 38 public:
37 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, 39 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host,
38 const importer::SourceProfile& source_profile, 40 const importer::SourceProfile& source_profile,
(...skipping 15 matching lines...) Expand all
54 void OnImportFinished(bool succeeded, const std::string& error_msg); 56 void OnImportFinished(bool succeeded, const std::string& error_msg);
55 void OnImportItemStart(int item); 57 void OnImportItemStart(int item);
56 void OnImportItemFinished(int item); 58 void OnImportItemFinished(int item);
57 void OnHistoryImportStart(size_t total_history_rows_count); 59 void OnHistoryImportStart(size_t total_history_rows_count);
58 void OnHistoryImportGroup(const history::URLRows& history_rows_group, 60 void OnHistoryImportGroup(const history::URLRows& history_rows_group,
59 int visit_source); 61 int visit_source);
60 void OnHomePageImportReady(const GURL& home_page); 62 void OnHomePageImportReady(const GURL& home_page);
61 void OnBookmarksImportStart(const string16& first_folder_name, 63 void OnBookmarksImportStart(const string16& first_folder_name,
62 size_t total_bookmarks_count); 64 size_t total_bookmarks_count);
63 void OnBookmarksImportGroup( 65 void OnBookmarksImportGroup(
64 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group); 66 const std::vector<ImportedBookmarkEntry>& bookmarks_group);
65 void OnFaviconsImportStart(size_t total_favicons_count); 67 void OnFaviconsImportStart(size_t total_favicons_count);
66 void OnFaviconsImportGroup( 68 void OnFaviconsImportGroup(
67 const std::vector<history::ImportedFaviconUsage>& favicons_group); 69 const std::vector<history::ImportedFaviconUsage>& favicons_group);
68 void OnPasswordFormImportReady(const content::PasswordForm& form); 70 void OnPasswordFormImportReady(const content::PasswordForm& form);
69 // WARNING: This function takes ownership of (and deletes) the pointers in 71 // WARNING: This function takes ownership of (and deletes) the pointers in
70 // |template_urls|! 72 // |template_urls|!
71 void OnKeywordsImportReady(const std::vector<TemplateURL*>& template_urls, 73 void OnKeywordsImportReady(const std::vector<TemplateURL*>& template_urls,
72 bool unique_on_host_and_path); 74 bool unique_on_host_and_path);
73 75
74 protected: 76 protected:
75 virtual ~ExternalProcessImporterClient(); 77 virtual ~ExternalProcessImporterClient();
76 78
77 private: 79 private:
78 // Notifies the importerhost that import has finished, and calls Release(). 80 // Notifies the importerhost that import has finished, and calls Release().
79 void Cleanup(); 81 void Cleanup();
80 82
81 // Cancel import process on IO thread. 83 // Cancel import process on IO thread.
82 void CancelImportProcessOnIOThread(); 84 void CancelImportProcessOnIOThread();
83 85
84 // Report item completely downloaded on IO thread. 86 // Report item completely downloaded on IO thread.
85 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); 87 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item);
86 88
87 // Creates a new UtilityProcessHost, which launches the import process. 89 // Creates a new UtilityProcessHost, which launches the import process.
88 void StartProcessOnIOThread(content::BrowserThread::ID thread_id); 90 void StartProcessOnIOThread(content::BrowserThread::ID thread_id);
89 91
90 // These variables store data being collected from the importer until the 92 // These variables store data being collected from the importer until the
91 // entire group has been collected and is ready to be written to the profile. 93 // entire group has been collected and is ready to be written to the profile.
92 history::URLRows history_rows_; 94 history::URLRows history_rows_;
93 std::vector<ProfileWriter::BookmarkEntry> bookmarks_; 95 std::vector<ImportedBookmarkEntry> bookmarks_;
94 std::vector<history::ImportedFaviconUsage> favicons_; 96 std::vector<history::ImportedFaviconUsage> favicons_;
95 97
96 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder 98 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder
97 // under which imported bookmarks will be placed. 99 // under which imported bookmarks will be placed.
98 string16 bookmarks_first_folder_name_; 100 string16 bookmarks_first_folder_name_;
99 101
100 // Total number of bookmarks to import. 102 // Total number of bookmarks to import.
101 size_t total_bookmarks_count_; 103 size_t total_bookmarks_count_;
102 104
103 // Total number of history items to import. 105 // Total number of history items to import.
(...skipping 21 matching lines...) Expand all
125 // ProfileWriter. 127 // ProfileWriter.
126 scoped_refptr<InProcessImporterBridge> bridge_; 128 scoped_refptr<InProcessImporterBridge> bridge_;
127 129
128 // True if import process has been cancelled. 130 // True if import process has been cancelled.
129 bool cancelled_; 131 bool cancelled_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); 133 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient);
132 }; 134 };
133 135
134 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ 136 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698