diff options
author | haven@chromium.org <haven@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 02:28:34 +0000 |
---|---|---|
committer | haven@chromium.org <haven@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 02:28:34 +0000 |
commit | a59d125d4be4d031d9d12ee99ddec2235d50816a (patch) | |
tree | aec169035cde187fb2d2575e717a9038d954dfe1 /chrome/browser/extensions/api/image_writer_private/operation.h | |
parent | 19ac792b53e794b18f2ea86cdb96290eb48c7931 (diff) | |
download | chromium_src-a59d125d4be4d031d9d12ee99ddec2235d50816a.zip chromium_src-a59d125d4be4d031d9d12ee99ddec2235d50816a.tar.gz chromium_src-a59d125d4be4d031d9d12ee99ddec2235d50816a.tar.bz2 |
In order to support writing on windows we need to take advantage of the new privileged operation in the utility thread. This code overlaps heavily with the Linux and OS X code, so all the writing for those is moved as well.
BUG=
Review URL: https://codereview.chromium.org/61643015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252466 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/image_writer_private/operation.h')
-rw-r--r-- | chrome/browser/extensions/api/image_writer_private/operation.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/chrome/browser/extensions/api/image_writer_private/operation.h b/chrome/browser/extensions/api/image_writer_private/operation.h index 2a37d41..1c9933f 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); |