Index: chrome/browser/chromeos/file_manager/zip_file_creator.h |
diff --git a/chrome/browser/chromeos/file_manager/zip_file_creator.h b/chrome/browser/chromeos/file_manager/zip_file_creator.h |
index 5b07e69da70366eaf6fae56b513685733937d891..f23e38ce68ba9729fc4dfc0d924dd3dd5a98fd72 100644 |
--- a/chrome/browser/chromeos/file_manager/zip_file_creator.h |
+++ b/chrome/browser/chromeos/file_manager/zip_file_creator.h |
@@ -8,19 +8,17 @@ |
#include "base/callback.h" |
#include "base/files/file.h" |
#include "base/files/file_path.h" |
-#include "content/public/browser/utility_process_host_client.h" |
+#include "base/memory/ref_counted.h" |
+#include "chrome/common/zip_file_creator.mojom.h" |
+#include "content/public/browser/utility_process_mojo_client.h" |
namespace file_manager { |
// ZipFileCreator creates a ZIP file from a specified list of files and |
// directories under a common parent directory. This is done in a sandboxed |
-// subprocess to protect the browser process from handling arbitrary input data |
-// from untrusted sources. |
-// |
-// The class is ref-counted and its ownership is passed around internal callback |
-// objects and finally to UtilityProcessHost. After the job finishes, the host |
-// releases the ref-pointer and then ZipFileCreator is automatically deleted. |
-class ZipFileCreator : public content::UtilityProcessHostClient { |
+// utility process to protect the browser process from handling arbitrary |
+// input data from untrusted sources. |
+class ZipFileCreator : public base::RefCountedThreadSafe<ZipFileCreator> { |
public: |
typedef base::Callback<void(bool)> ResultCallback; |
@@ -31,28 +29,18 @@ class ZipFileCreator : public content::UtilityProcessHostClient { |
const base::FilePath& dest_file); |
// Starts creating the zip file. Must be called from the UI thread. |
- // The result will be passed to |callback|. After the task is finished and |
- // |callback| is run, ZipFileCreator instance is deleted. |
+ // The result will be passed to |callback|. After the task is finished |
+ // and |callback| is run, ZipFileCreator instance is deleted. |
void Start(); |
private: |
- friend class ProcessHostClient; |
+ friend class base::RefCountedThreadSafe<ZipFileCreator>; |
- ~ZipFileCreator() override; |
+ ~ZipFileCreator(); |
- // Called after the file handle is opened on blocking pool. |
- void OnOpenFileHandle(base::File file); |
- |
- // Starts the utility process that creates the zip file. |
- void StartProcessOnIOThread(base::File dest_file); |
- |
- // UtilityProcessHostClient |
- bool OnMessageReceived(const IPC::Message& message) override; |
- void OnProcessCrashed(int exit_code) override; |
- |
- // IPC message handlers. |
- void OnCreateZipFileSucceeded(); |
- void OnCreateZipFileFailed(); |
+ // Called after the dest_file |file| is opened on the blocking pool to |
+ // create the zip file in it using a sandboxed utility process. |
+ void CreateZipFile(base::File file); |
void ReportDone(bool success); |
@@ -68,6 +56,11 @@ class ZipFileCreator : public content::UtilityProcessHostClient { |
// The output zip file. |
base::FilePath dest_file_; |
+ |
+ // Utility process used to create the zip file. |
+ std::unique_ptr< |
+ content::UtilityProcessMojoClient<chrome::mojom::ZipFileCreator>> |
+ utility_process_mojo_client_; |
}; |
} // namespace file_manager |