| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #ifndef CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ | 6 #ifndef CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ |
| 7 #define CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ | 7 #define CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" |
| 12 | 16 |
| 13 namespace chromeos { | 17 namespace chromeos { |
| 14 | 18 |
| 15 enum BurnEvent { | 19 enum BurnEvent { |
| 16 UNZIP_STARTED, | 20 UNZIP_STARTED, |
| 17 UNZIP_COMPLETE, | 21 UNZIP_COMPLETE, |
| 18 UNZIP_FAIL, | 22 UNZIP_FAIL, |
| 19 BURN_UPDATE, | 23 BURN_UPDATE, |
| 20 BURN_SUCCESS, | 24 BURN_SUCCESS, |
| 21 BURN_FAIL, | 25 BURN_FAIL, |
| 22 UNKNOWN | 26 UNKNOWN |
| 23 }; | 27 }; |
| 24 | 28 |
| 25 struct ImageBurnStatus { | 29 struct ImageBurnStatus { |
| 26 ImageBurnStatus() : amount_burnt(0), total_size(0) { | 30 ImageBurnStatus() : amount_burnt(0), total_size(0) { |
| 27 } | 31 } |
| 28 | 32 |
| 29 ImageBurnStatus(int64 burnt, int64 total) | 33 ImageBurnStatus(int64 burnt, int64 total) |
| 30 : amount_burnt(burnt), total_size(total) { | 34 : amount_burnt(burnt), total_size(total) { |
| 31 } | 35 } |
| 32 | 36 |
| 33 int64 amount_burnt; | 37 int64 amount_burnt; |
| 34 int64 total_size; | 38 int64 total_size; |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 class BurnLibrary { | 41 class BurnLibrary { |
| 38 public: | 42 public: |
| 39 class Observer { | 43 class Observer { |
| 40 public: | 44 public: |
| 41 virtual void BurnProgressUpdated(BurnLibrary* object, | 45 virtual void BurnProgressUpdated(BurnLibrary* object, BurnEvent evt, |
| 42 BurnEvent evt, | 46 const ImageBurnStatus& status) = 0; |
| 43 const ImageBurnStatus& status) = 0; | |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 virtual ~BurnLibrary() {} | 49 virtual ~BurnLibrary() {} |
| 47 | 50 |
| 48 virtual void Init() = 0; | 51 virtual void Init() = 0; |
| 49 | 52 |
| 50 virtual void AddObserver(Observer* observer) = 0; | 53 virtual void AddObserver(Observer* observer) = 0; |
| 51 virtual void RemoveObserver(Observer* observer) = 0; | 54 virtual void RemoveObserver(Observer* observer) = 0; |
| 52 // Example values: | 55 // Example values: |
| 53 // DoBurn(image.bin.zip, image.bin, /dev/sdb, /sys/devices/pci..../block.sdb). | 56 // DoBurn(image.bin.zip, image.bin, /dev/sdb, /sys/devices/pci..../block.sdb). |
| 54 virtual void DoBurn(const FilePath& source_path, | 57 virtual void DoBurn(const FilePath& source_path, |
| 55 const std::string& image_name, | 58 const std::string& image_name, |
| 56 const FilePath& target_file_path, | 59 const FilePath& target_file_path, |
| 57 const FilePath& target_device_path) = 0; | 60 const FilePath& target_device_path) = 0; |
| 58 virtual void CancelBurnImage() = 0; | 61 virtual void CancelBurnImage() = 0; |
| 59 | 62 |
| 60 // Factory function, creates a new instance and returns ownership. | 63 // Factory function, creates a new instance and returns ownership. |
| 61 // For normal usage, access the singleton via CrosLibrary::Get(). | 64 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 62 static BurnLibrary* GetImpl(bool stub); | 65 static BurnLibrary* GetImpl(bool stub); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 } // namespace chromeos | 68 } // namespace chromeos |
| 66 | 69 |
| 67 #endif // CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ | 70 #endif // CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_ |
| OLD | NEW |