• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 
6 #ifndef CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_
7 #define CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_
8 
9 #include <string>
10 #include <vector>
11 
12 #include "base/file_path.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "third_party/cros/chromeos_imageburn.h"
16 
17 struct ImageBurnStatus {
ImageBurnStatusImageBurnStatus18   explicit ImageBurnStatus(const chromeos::BurnStatus& status)
19       : amount_burnt(status.amount_burnt),
20         total_size(status.total_size) {
21     if (status.target_path)
22       target_path = status.target_path;
23     if (status.error)
24       error = status.error;
25   }
26   std::string target_path;
27   int64 amount_burnt;
28   int64 total_size;
29   std::string error;
30 };
31 
32 namespace chromeos {
33 class BurnLibrary {
34  public:
35   class Observer {
36    public:
37     virtual void ProgressUpdated(BurnLibrary* object, BurnEventType evt,
38                                  const ImageBurnStatus& status) = 0;
39   };
40 
~BurnLibrary()41   virtual ~BurnLibrary() {}
42 
43   virtual void AddObserver(Observer* observer) = 0;
44   virtual void RemoveObserver(Observer* observer) = 0;
45   virtual bool DoBurn(const FilePath& from_path, const FilePath& to_path) = 0;
46 
47   // Factory function, creates a new instance and returns ownership.
48   // For normal usage, access the singleton via CrosLibrary::Get().
49   static BurnLibrary* GetImpl(bool stub);
50 };
51 
52 }  // namespace chromeos
53 
54 #endif  // CHROME_BROWSER_CHROMEOS_CROS_BURN_LIBRARY_H_
55