1// Copyright (c) 2012 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#ifndef CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_CONTROLLER_H_
6#define CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_CONTROLLER_H_
7
8#include <vector>
9
10#include "base/basictypes.h"
11#include "chrome/browser/chromeos/imageburner/burn_manager.h"
12#include "chromeos/disks/disk_mount_manager.h"
13
14namespace base {
15class FilePath;
16class TimeDelta;
17}
18
19namespace content {
20class WebContents;
21}
22
23namespace chromeos {
24namespace imageburner {
25
26// A class to control recovery media creating process.
27class BurnController {
28 public:
29  class Delegate {
30   public:
31    // Called when recovery image is successfully burnt.
32    virtual void OnSuccess() = 0;
33    // Called when something goes wrong.
34    virtual void OnFail(int error_message_id) = 0;
35    // Called when a burnable device is added.
36    virtual void OnDeviceAdded(const disks::DiskMountManager::Disk& disk) = 0;
37    // Called when a burnable device is removed.
38    virtual void OnDeviceRemoved(const disks::DiskMountManager::Disk& disk) = 0;
39    // Called when device is too small.
40    virtual void OnDeviceTooSmall(int64 device_size) = 0;
41    // Called when some progress is made.
42    virtual void OnProgress(ProgressType progress_type,
43                            int64 amount_finished,
44                            int64 amount_total) = 0;
45    // Called when some progress is made and remaining time estimation is
46    // available.
47    virtual void OnProgressWithRemainingTime(
48        ProgressType progress_type,
49        int64 amount_finished,
50        int64 amount_total,
51        const base::TimeDelta& time_remaining) = 0;
52    // Called when network is connected.
53    virtual void OnNetworkDetected() = 0;
54    // Called when an error occurs because there is no network connection.
55    virtual void OnNoNetwork() = 0;
56  };
57
58  virtual ~BurnController() {}
59
60  // Initializes the instance.
61  virtual void Init() = 0;
62  // Returns devices on which we can burn recovery image.
63  virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices() = 0;
64  // Starts burning process.
65  virtual void StartBurnImage(const base::FilePath& target_device_path,
66                              const base::FilePath& target_file_path) = 0;
67  // Cancels burning process.
68  virtual void CancelBurnImage() = 0;
69  // Creates a new instance of BurnController.
70  static BurnController* CreateBurnController(
71      content::WebContents* web_contents, Delegate* delegate);
72
73 protected:
74  BurnController() {}
75
76 private:
77  DISALLOW_COPY_AND_ASSIGN(BurnController);
78};
79
80}  // namespace imageburner
81}  // namespace chromeos
82
83#endif  // CHROME_BROWSER_CHROMEOS_IMAGEBURNER_BURN_CONTROLLER_H_
84