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 "chromeos/disks/mock_disk_mount_manager.h" | 5 #include "chromeos/disks/mock_disk_mount_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 false); // is_hidden | 203 false); // is_hidden |
204 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); | 204 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); |
205 if (it == disks_.end()) { | 205 if (it == disks_.end()) { |
206 disks_.insert(std::make_pair(std::string(mount_info.source_path), disk)); | 206 disks_.insert(std::make_pair(std::string(mount_info.source_path), disk)); |
207 } else { | 207 } else { |
208 delete it->second; | 208 delete it->second; |
209 it->second = disk; | 209 it->second = disk; |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
| 213 void MockDiskMountManager::AddDiskEntry(Disk* disk) { |
| 214 DiskMountManager::DiskMap::iterator it = disks_.find(disk->device_path()); |
| 215 if (it == disks_.end()) { |
| 216 disks_.insert(std::make_pair(std::string(disk->device_path()), disk)); |
| 217 } else { |
| 218 delete it->second; |
| 219 it->second = disk; |
| 220 } |
| 221 } |
| 222 |
| 223 void MockDiskMountManager::RemoveDiskEntry(Disk* disk) { |
| 224 DiskMountManager::DiskMap::iterator it = disks_.find(disk->device_path()); |
| 225 if (it != disks_.end()) { |
| 226 delete it->second; |
| 227 disks_.erase(it); |
| 228 } |
| 229 } |
| 230 |
213 void MockDiskMountManager::RemoveDiskEntryForMountDevice( | 231 void MockDiskMountManager::RemoveDiskEntryForMountDevice( |
214 const DiskMountManager::MountPointInfo& mount_info) { | 232 const DiskMountManager::MountPointInfo& mount_info) { |
215 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); | 233 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); |
216 if (it != disks_.end()) { | 234 if (it != disks_.end()) { |
217 delete it->second; | 235 delete it->second; |
218 disks_.erase(it); | 236 disks_.erase(it); |
219 } | 237 } |
220 } | 238 } |
221 | 239 |
222 const DiskMountManager::MountPointMap& | 240 const DiskMountManager::MountPointMap& |
(...skipping 14 matching lines...) Expand all Loading... |
237 FOR_EACH_OBSERVER(Observer, observers_, OnDiskEvent(event, disk)); | 255 FOR_EACH_OBSERVER(Observer, observers_, OnDiskEvent(event, disk)); |
238 } | 256 } |
239 | 257 |
240 void MockDiskMountManager::NotifyDeviceChanged(DeviceEvent event, | 258 void MockDiskMountManager::NotifyDeviceChanged(DeviceEvent event, |
241 const std::string& path) { | 259 const std::string& path) { |
242 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceEvent(event, path)); | 260 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceEvent(event, path)); |
243 } | 261 } |
244 | 262 |
245 } // namespace disks | 263 } // namespace disks |
246 } // namespace chromeos | 264 } // namespace chromeos |
OLD | NEW |