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

Unified Diff: chrome/browser/image_writer_client.h

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes comment. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/image_writer_client.h
diff --git a/chrome/browser/image_writer_client.h b/chrome/browser/image_writer_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d6aab0401c68f56083b624b13c0a8372e0252d2
--- /dev/null
+++ b/chrome/browser/image_writer_client.h
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_IMAGE_WRITER_CLIENT_H_
+#define CHROME_BROWSER_IMAGE_WRITER_CLIENT_H_
+
+#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/sequenced_worker_pool.h"
+#include "content/public/browser/utility_process_host.h"
+#include "content/public/browser/utility_process_host_client.h"
+
+// Writes a disk image to a device inside the utility process.
+class ImageWriterClient : public content::UtilityProcessHostClient {
+ public:
+ typedef base::Callback<void()> CancelCallback;
Lei Zhang 2014/02/15 00:26:59 Better knowns as base::Closure
Drew Haven 2014/02/15 01:23:58 Done.
+ typedef base::Callback<void()> SuccessCallback;
+ typedef base::Callback<void(int64)> ProgressCallback;
+ typedef base::Callback<void(const std::string&)> ErrorCallback;
+
+ ImageWriterClient();
+
+ // Starts the write.
+ // |progress_callback|: Called periodically with the count of bytes processed.
+ // |success_callback|: Called at successful completion.
+ // |error_callback|: Called with an error message on failure.
+ // |source|: The path to the source file to read data from.
+ // |target|: The path to the target device to write the image file to.
+ void Write(const ProgressCallback& progress_callback,
+ const SuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const base::FilePath& source,
+ const base::FilePath& target);
+
+ // Starts a verification.
+ // |progress_callback|: Called periodically with the count of bytes processed.
+ // |success_callback|: Called at successful completion.
+ // |error_callback|: Called with an error message on failure.
+ // |source|: The path to the source file to read data from.
+ // |target|: The path to the target device to write the image file to.
+ void Verify(const ProgressCallback& progress_callback,
+ const SuccessCallback& success_callback,
+ const ErrorCallback& error_callback,
+ const base::FilePath& source,
+ const base::FilePath& target);
+
+ // Cancels any pending write or verification.
+ // |cancel_callback|: Called when the cancel has actually occurred.
+ void Cancel(const CancelCallback& cancel_callback);
+
+ // Shuts down the Utility thread that may have been created.
+ void Shutdown();
+
+ private:
+ // Ensures the UtilityProcessHost has been created.
+ void StartHost();
+
+ // UtilityProcessHostClient implementation.
+ virtual void OnProcessCrashed(int exit_code) OVERRIDE;
+ virtual void OnProcessLaunchFailed() OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual bool Send(IPC::Message* msg);
Lei Zhang 2014/02/15 00:26:59 Either it needs an OVERRIDE or it's not part of Ut
Drew Haven 2014/02/15 01:23:58 Done.
+
+ // It's a reference-counted object, so destructor is private.
+ virtual ~ImageWriterClient();
+
+ // IPC message handlers.
+ void OnWriteImageSucceeded();
+ void OnWriteImageCancelled();
+ void OnWriteImageFailed(const std::string& message);
+ void OnWriteImageProgress(int64 progress);
+
+ CancelCallback cancel_callback_;
+ ProgressCallback progress_callback_;
+ SuccessCallback success_callback_;
+ ErrorCallback error_callback_;
+
+ base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
+
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageWriterClient);
+};
+
+#endif // CHROME_BROWSER_IMAGE_WRITER_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698