OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/chromeos/imageburner/burn_controller.h" | 5 #include "chrome/browser/chromeos/imageburner/burn_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "chrome/browser/chromeos/imageburner/burn_manager.h" | 10 #include "chrome/browser/chromeos/imageburner/burn_manager.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 state_machine_->AddObserver(this); | 35 state_machine_->AddObserver(this); |
36 } | 36 } |
37 | 37 |
38 virtual ~BurnControllerImpl() { | 38 virtual ~BurnControllerImpl() { |
39 state_machine_->RemoveObserver(this); | 39 state_machine_->RemoveObserver(this); |
40 burn_manager_->RemoveObserver(this); | 40 burn_manager_->RemoveObserver(this); |
41 } | 41 } |
42 | 42 |
43 // BurnManager::Observer override. | 43 // BurnManager::Observer override. |
44 virtual void OnDeviceAdded( | 44 virtual void OnDeviceAdded( |
45 const disks::DiskMountManager::Disk& disk) OVERRIDE { | 45 const disks::DiskMountManager::Disk& disk) override { |
46 delegate_->OnDeviceAdded(disk); | 46 delegate_->OnDeviceAdded(disk); |
47 } | 47 } |
48 | 48 |
49 // BurnManager::Observer override. | 49 // BurnManager::Observer override. |
50 virtual void OnDeviceRemoved( | 50 virtual void OnDeviceRemoved( |
51 const disks::DiskMountManager::Disk& disk) OVERRIDE { | 51 const disks::DiskMountManager::Disk& disk) override { |
52 delegate_->OnDeviceRemoved(disk); | 52 delegate_->OnDeviceRemoved(disk); |
53 } | 53 } |
54 | 54 |
55 // BurnManager::Observer override. | 55 // BurnManager::Observer override. |
56 virtual void OnNetworkDetected() OVERRIDE { | 56 virtual void OnNetworkDetected() override { |
57 delegate_->OnNetworkDetected(); | 57 delegate_->OnNetworkDetected(); |
58 } | 58 } |
59 | 59 |
60 // BurnManager::Observer override. | 60 // BurnManager::Observer override. |
61 virtual void OnSuccess() OVERRIDE { | 61 virtual void OnSuccess() override { |
62 delegate_->OnSuccess(); | 62 delegate_->OnSuccess(); |
63 // TODO(hidehiko): Remove |working_| flag. | 63 // TODO(hidehiko): Remove |working_| flag. |
64 working_ = false; | 64 working_ = false; |
65 } | 65 } |
66 | 66 |
67 // BurnManager::Observer override. | 67 // BurnManager::Observer override. |
68 virtual void OnProgressWithRemainingTime( | 68 virtual void OnProgressWithRemainingTime( |
69 ProgressType progress_type, | 69 ProgressType progress_type, |
70 int64 received_bytes, | 70 int64 received_bytes, |
71 int64 total_bytes, | 71 int64 total_bytes, |
72 const base::TimeDelta& estimated_remaining_time) OVERRIDE { | 72 const base::TimeDelta& estimated_remaining_time) override { |
73 delegate_->OnProgressWithRemainingTime( | 73 delegate_->OnProgressWithRemainingTime( |
74 progress_type, received_bytes, total_bytes, estimated_remaining_time); | 74 progress_type, received_bytes, total_bytes, estimated_remaining_time); |
75 } | 75 } |
76 | 76 |
77 // BurnManager::Observer override. | 77 // BurnManager::Observer override. |
78 virtual void OnProgress(ProgressType progress_type, | 78 virtual void OnProgress(ProgressType progress_type, |
79 int64 received_bytes, | 79 int64 received_bytes, |
80 int64 total_bytes) OVERRIDE { | 80 int64 total_bytes) override { |
81 delegate_->OnProgress(progress_type, received_bytes, total_bytes); | 81 delegate_->OnProgress(progress_type, received_bytes, total_bytes); |
82 } | 82 } |
83 | 83 |
84 // StateMachine::Observer interface. | 84 // StateMachine::Observer interface. |
85 virtual void OnBurnStateChanged(StateMachine::State state) OVERRIDE { | 85 virtual void OnBurnStateChanged(StateMachine::State state) override { |
86 if (state != StateMachine::INITIAL && !working_) { | 86 if (state != StateMachine::INITIAL && !working_) { |
87 // User has started burn process, so let's start observing. | 87 // User has started burn process, so let's start observing. |
88 StartBurnImage(base::FilePath(), base::FilePath()); | 88 StartBurnImage(base::FilePath(), base::FilePath()); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 virtual void OnError(int error_message_id) OVERRIDE { | 92 virtual void OnError(int error_message_id) override { |
93 delegate_->OnFail(error_message_id); | 93 delegate_->OnFail(error_message_id); |
94 working_ = false; | 94 working_ = false; |
95 } | 95 } |
96 | 96 |
97 // BurnController override. | 97 // BurnController override. |
98 virtual void Init() OVERRIDE { | 98 virtual void Init() override { |
99 if (state_machine_->state() == StateMachine::BURNING) { | 99 if (state_machine_->state() == StateMachine::BURNING) { |
100 // There is nothing else left to do but observe burn progress. | 100 // There is nothing else left to do but observe burn progress. |
101 burn_manager_->DoBurn(); | 101 burn_manager_->DoBurn(); |
102 } else if (state_machine_->state() != StateMachine::INITIAL) { | 102 } else if (state_machine_->state() != StateMachine::INITIAL) { |
103 // User has started burn process, so let's start observing. | 103 // User has started burn process, so let's start observing. |
104 StartBurnImage(base::FilePath(), base::FilePath()); | 104 StartBurnImage(base::FilePath(), base::FilePath()); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 // BurnController override. | 108 // BurnController override. |
109 virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices() | 109 virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices() |
110 OVERRIDE { | 110 override { |
111 // Now this is just a proxy to the BurnManager. | 111 // Now this is just a proxy to the BurnManager. |
112 // TODO(hidehiko): Remove this method. | 112 // TODO(hidehiko): Remove this method. |
113 return burn_manager_->GetBurnableDevices(); | 113 return burn_manager_->GetBurnableDevices(); |
114 } | 114 } |
115 | 115 |
116 // BurnController override. | 116 // BurnController override. |
117 virtual void CancelBurnImage() OVERRIDE { | 117 virtual void CancelBurnImage() override { |
118 burn_manager_->Cancel(); | 118 burn_manager_->Cancel(); |
119 } | 119 } |
120 | 120 |
121 // BurnController override. | 121 // BurnController override. |
122 // May be called with empty values if there is a handler that has started | 122 // May be called with empty values if there is a handler that has started |
123 // burning, and thus set the target paths. | 123 // burning, and thus set the target paths. |
124 virtual void StartBurnImage(const base::FilePath& target_device_path, | 124 virtual void StartBurnImage(const base::FilePath& target_device_path, |
125 const base::FilePath& target_file_path) OVERRIDE { | 125 const base::FilePath& target_file_path) override { |
126 if (!target_device_path.empty() && !target_file_path.empty() && | 126 if (!target_device_path.empty() && !target_file_path.empty() && |
127 state_machine_->new_burn_posible()) { | 127 state_machine_->new_burn_posible()) { |
128 if (!NetworkHandler::Get()->network_state_handler()->DefaultNetwork()) { | 128 if (!NetworkHandler::Get()->network_state_handler()->DefaultNetwork()) { |
129 delegate_->OnNoNetwork(); | 129 delegate_->OnNoNetwork(); |
130 return; | 130 return; |
131 } | 131 } |
132 burn_manager_->set_target_device_path(target_device_path); | 132 burn_manager_->set_target_device_path(target_device_path); |
133 burn_manager_->set_target_file_path(target_file_path); | 133 burn_manager_->set_target_file_path(target_file_path); |
134 uint64 device_size = GetDeviceSize( | 134 uint64 device_size = GetDeviceSize( |
135 burn_manager_->target_device_path().value()); | 135 burn_manager_->target_device_path().value()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 // static | 173 // static |
174 BurnController* BurnController::CreateBurnController( | 174 BurnController* BurnController::CreateBurnController( |
175 content::WebContents* web_contents, | 175 content::WebContents* web_contents, |
176 Delegate* delegate) { | 176 Delegate* delegate) { |
177 return new BurnControllerImpl(delegate); | 177 return new BurnControllerImpl(delegate); |
178 } | 178 } |
179 | 179 |
180 } // namespace imageburner | 180 } // namespace imageburner |
181 } // namespace chromeos | 181 } // namespace chromeos |
OLD | NEW |