OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this image code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_H_ |
| 6 #define CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_H_ |
| 7 |
| 8 #include "base/bind.h" |
| 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 |
| 13 namespace chrome { |
| 14 namespace image_writer { |
| 15 |
| 16 class ImageWriterHandler; |
| 17 |
| 18 class ImageWriter : public base::RefCountedThreadSafe<ImageWriter> { |
| 19 public: |
| 20 explicit ImageWriter(base::WeakPtr<ImageWriterHandler> handler); |
| 21 |
| 22 void Write(const base::FilePath& image_path, |
| 23 const base::FilePath& device_path); |
| 24 void Verify(const base::FilePath& image_path, |
| 25 const base::FilePath& device_path); |
| 26 void Cancel(); |
| 27 |
| 28 private: |
| 29 virtual ~ImageWriter(); |
| 30 friend class base::RefCountedThreadSafe<ImageWriter>; |
| 31 |
| 32 void PostTask(const base::Closure& task); |
| 33 void PostProgress(int progress); |
| 34 void Error(const std::string& message); |
| 35 |
| 36 void WriteChunk(); |
| 37 void WriteComplete(); |
| 38 |
| 39 void VerifyChunk(); |
| 40 void VerifyComplete(); |
| 41 |
| 42 bool SetUp(); |
| 43 bool CleanUp(); |
| 44 |
| 45 base::FilePath image_path_; |
| 46 base::FilePath device_path_; |
| 47 |
| 48 base::PlatformFile image_file_; |
| 49 base::PlatformFile device_file_; |
| 50 int64 total_bytes_; |
| 51 |
| 52 bool cancelled_; |
| 53 |
| 54 base::WeakPtr<ImageWriterHandler> handler_; |
| 55 }; |
| 56 |
| 57 } // namespace image_writer |
| 58 } // namespace chrome |
| 59 |
| 60 #endif // CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_H_ |
OLD | NEW |