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