| 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 #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/memory/weak_ptr.h" |
| 14 #include "base/string16.h" | 15 #include "base/string16.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 "chrome/browser/importer/profile_writer.h" |
| 17 #include "content/browser/utility_process_host.h" | |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/utility_process_host_client.h" |
| 19 | 20 |
| 20 class ExternalProcessImporterHost; | 21 class ExternalProcessImporterHost; |
| 21 class InProcessImporterBridge; | 22 class InProcessImporterBridge; |
| 23 |
| 24 namespace content { |
| 22 class UtilityProcessHost; | 25 class UtilityProcessHost; |
| 26 } |
| 23 | 27 |
| 24 namespace history { | 28 namespace history { |
| 25 class URLRow; | 29 class URLRow; |
| 26 struct ImportedFaviconUsage; | 30 struct ImportedFaviconUsage; |
| 27 } | 31 } |
| 28 | 32 |
| 29 // This class is the client for the out of process profile importing. It | 33 // This class is the client for the out of process profile importing. It |
| 30 // collects notifications from this process host and feeds data back to the | 34 // collects notifications from this process host and feeds data back to the |
| 31 // importer host, who actually does the writing. | 35 // importer host, who actually does the writing. |
| 32 class ExternalProcessImporterClient : public UtilityProcessHost::Client { | 36 class ExternalProcessImporterClient : public content::UtilityProcessHostClient { |
| 33 public: | 37 public: |
| 34 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, | 38 ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host, |
| 35 const importer::SourceProfile& source_profile, | 39 const importer::SourceProfile& source_profile, |
| 36 uint16 items, | 40 uint16 items, |
| 37 InProcessImporterBridge* bridge); | 41 InProcessImporterBridge* bridge); |
| 38 virtual ~ExternalProcessImporterClient(); | 42 virtual ~ExternalProcessImporterClient(); |
| 39 | 43 |
| 40 // Cancel import process on IO thread. | 44 // Cancel import process on IO thread. |
| 41 void CancelImportProcessOnIOThread(); | 45 void CancelImportProcessOnIOThread(); |
| 42 | 46 |
| 43 // Report item completely downloaded on IO thread. | 47 // Report item completely downloaded on IO thread. |
| 44 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); | 48 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); |
| 45 | 49 |
| 46 // Notifies the importerhost that import has finished, and calls Release(). | 50 // Notifies the importerhost that import has finished, and calls Release(). |
| 47 void Cleanup(); | 51 void Cleanup(); |
| 48 | 52 |
| 49 // Launches the task to start the external process. | 53 // Launches the task to start the external process. |
| 50 virtual void Start(); | 54 virtual void Start(); |
| 51 | 55 |
| 52 // Creates a new UtilityProcessHost, which launches the import process. | 56 // Creates a new UtilityProcessHost, which launches the import process. |
| 53 virtual void StartProcessOnIOThread(content::BrowserThread::ID thread_id); | 57 virtual void StartProcessOnIOThread(content::BrowserThread::ID thread_id); |
| 54 | 58 |
| 55 // Called by the ExternalProcessImporterHost on import cancel. | 59 // Called by the ExternalProcessImporterHost on import cancel. |
| 56 virtual void Cancel(); | 60 virtual void Cancel(); |
| 57 | 61 |
| 58 // UtilityProcessHost::Client implementation: | 62 // UtilityProcessHostClient implementation: |
| 59 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 63 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 61 | 65 |
| 62 // Message handlers | 66 // Message handlers |
| 63 void OnImportStart(); | 67 void OnImportStart(); |
| 64 void OnImportFinished(bool succeeded, const std::string& error_msg); | 68 void OnImportFinished(bool succeeded, const std::string& error_msg); |
| 65 void OnImportItemStart(int item); | 69 void OnImportItemStart(int item); |
| 66 void OnImportItemFinished(int item); | 70 void OnImportItemFinished(int item); |
| 67 void OnHistoryImportStart(size_t total_history_rows_count); | 71 void OnHistoryImportStart(size_t total_history_rows_count); |
| 68 void OnHistoryImportGroup( | 72 void OnHistoryImportGroup( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 108 |
| 105 // Notifications received from the ProfileImportProcessHost are passed back | 109 // Notifications received from the ProfileImportProcessHost are passed back |
| 106 // to process_importer_host_, which calls the ProfileWriter to record the | 110 // to process_importer_host_, which calls the ProfileWriter to record the |
| 107 // import data. When the import process is done, process_importer_host_ | 111 // import data. When the import process is done, process_importer_host_ |
| 108 // deletes itself. | 112 // deletes itself. |
| 109 ExternalProcessImporterHost* process_importer_host_; | 113 ExternalProcessImporterHost* process_importer_host_; |
| 110 | 114 |
| 111 // Handles sending messages to the external process. Deletes itself when | 115 // Handles sending messages to the external process. Deletes itself when |
| 112 // the external process dies (see | 116 // the external process dies (see |
| 113 // BrowserChildProcessHost::OnChildDisconnected). | 117 // BrowserChildProcessHost::OnChildDisconnected). |
| 114 base::WeakPtr<UtilityProcessHost> utility_process_host_; | 118 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 115 | 119 |
| 116 // Data to be passed from the importer host to the external importer. | 120 // Data to be passed from the importer host to the external importer. |
| 117 const importer::SourceProfile& source_profile_; | 121 const importer::SourceProfile& source_profile_; |
| 118 uint16 items_; | 122 uint16 items_; |
| 119 | 123 |
| 120 // Takes import data coming over IPC and delivers it to be written by the | 124 // Takes import data coming over IPC and delivers it to be written by the |
| 121 // ProfileWriter. Released by ExternalProcessImporterClient in its | 125 // ProfileWriter. Released by ExternalProcessImporterClient in its |
| 122 // destructor. | 126 // destructor. |
| 123 InProcessImporterBridge* bridge_; | 127 InProcessImporterBridge* bridge_; |
| 124 | 128 |
| 125 // True if import process has been cancelled. | 129 // True if import process has been cancelled. |
| 126 bool cancelled_; | 130 bool cancelled_; |
| 127 | 131 |
| 128 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); | 132 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); |
| 129 }; | 133 }; |
| 130 | 134 |
| 131 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 135 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
| OLD | NEW |