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

Unified Diff: chrome/browser/extensions/api/image_writer_private/operation.h

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes test cleanup ordering for Chrome OS. 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/extensions/api/image_writer_private/operation.h
diff --git a/chrome/browser/extensions/api/image_writer_private/operation.h b/chrome/browser/extensions/api/image_writer_private/operation.h
index 2a37d41f258a32b2e5c806b71a5cf3026c85f2c9..1c9933f2914f4675d982ca045e7afdece6e6e93c 100644
--- a/chrome/browser/extensions/api/image_writer_private/operation.h
+++ b/chrome/browser/extensions/api/image_writer_private/operation.h
@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/timer/timer.h"
+#include "chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h"
#include "chrome/common/extensions/api/image_writer_private.h"
#include "third_party/zlib/google/zip_reader.h"
@@ -70,6 +71,12 @@ class Operation : public base::RefCountedThreadSafe<Operation> {
int GetProgress();
image_writer_api::Stage GetStage();
+#if !defined(OS_CHROMEOS)
+ // Set an ImageWriterClient to use. Should be called only when testing.
+ void SetUtilityClientForTesting(
+ scoped_refptr<ImageWriterUtilityClient> client);
+#endif
+
protected:
virtual ~Operation();
@@ -110,6 +117,10 @@ class Operation : public base::RefCountedThreadSafe<Operation> {
// functions will be run on the FILE thread.
void AddCleanUpFunction(const base::Closure& callback);
+ // Completes the current operation (progress set to 100) and runs the
+ // continuation.
+ void CompleteAndContinue(const base::Closure& continuation);
+
// If |file_size| is non-zero, only |file_size| bytes will be read from file,
// otherwise the entire file will be read.
// |progress_scale| is a percentage to which the progress will be scale, e.g.
@@ -135,20 +146,20 @@ class Operation : public base::RefCountedThreadSafe<Operation> {
private:
friend class base::RefCountedThreadSafe<Operation>;
- // TODO(haven): Clean up these switches. http://crbug.com/292956
-#if defined(OS_LINUX) && !defined(CHROMEOS)
- void WriteChunk(const int64& bytes_written,
- const int64& total_size,
- const base::Closure& continuation);
- void WriteComplete(const base::Closure& continuation);
+#if !defined(OS_CHROMEOS)
+ // Ensures the client is started. This may be called many times but will only
+ // instantiate one client which should exist for the lifetime of the
+ // Operation.
+ void StartUtilityClient();
+
+ // Stops the client. This must be called to ensure the utility process can
+ // shutdown.
+ void StopUtilityClient();
- void VerifyWriteChunk(const int64& bytes_written,
- const int64& total_size,
- const base::Closure& continuation);
- void VerifyWriteComplete(const base::Closure& continuation);
+ // Reports progress from the client, transforming from bytes to percentage.
+ virtual void WriteImageProgress(int64 total_bytes, int64 curr_bytes);
- base::PlatformFile image_file_;
- base::PlatformFile device_file_;
+ scoped_refptr<ImageWriterUtilityClient> image_writer_client_;
#endif
#if defined(OS_CHROMEOS)
@@ -173,7 +184,6 @@ class Operation : public base::RefCountedThreadSafe<Operation> {
const base::Callback<void(const std::string&)>& callback);
// Callbacks for zip::ZipReader.
- void OnUnzipSuccess(const base::Closure& continuation);
void OnUnzipFailure();
void OnUnzipProgress(int64 total_bytes, int64 progress_bytes);

Powered by Google App Engine
This is Rietveld 408576698