#ifndef CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_H_
#define CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_H_
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
namespace image_writer {
class ImageWriterHandler;
class ImageWriter : public base::SupportsWeakPtr<ImageWriter> {
 public:
  explicit ImageWriter(ImageWriterHandler* handler);
  virtual ~ImageWriter();
  
  void Write(const base::FilePath& image_path,
             const base::FilePath& device_path);
  
  
  void Verify(const base::FilePath& image_path,
              const base::FilePath& device_path);
  
  void Cancel();
  
  bool IsRunning() const;
 private:
  
  void PostTask(const base::Closure& task);
  void PostProgress(int64 progress);
  void Error(const std::string& message);
  
  void WriteChunk();
  void VerifyChunk();
  
  void CleanUp();
  base::FilePath image_path_;
  base::FilePath device_path_;
  base::File image_file_;
  base::File device_file_;
  int64 bytes_processed_;
  ImageWriterHandler* handler_;
};
}  
#endif