OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_device_handler.h" | 5 #include "chrome/browser/chromeos/imageburner/burn_device_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // a Chrome OS). | 52 // a Chrome OS). |
53 void EmulateRemoveDisk(const std::string& source_path) { | 53 void EmulateRemoveDisk(const std::string& source_path) { |
54 scoped_ptr<Disk> disk(RemoveDisk(source_path)); | 54 scoped_ptr<Disk> disk(RemoveDisk(source_path)); |
55 if (disk.get()) { | 55 if (disk.get()) { |
56 FOR_EACH_OBSERVER( | 56 FOR_EACH_OBSERVER( |
57 Observer, observers_, OnDiskEvent(DISK_REMOVED, disk.get())); | 57 Observer, observers_, OnDiskEvent(DISK_REMOVED, disk.get())); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 // DiskMountManager overrides. | 61 // DiskMountManager overrides. |
62 virtual void AddObserver(Observer* observer) OVERRIDE { | 62 virtual void AddObserver(Observer* observer) override { |
63 observers_.AddObserver(observer); | 63 observers_.AddObserver(observer); |
64 } | 64 } |
65 | 65 |
66 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 66 virtual void RemoveObserver(Observer* observer) override { |
67 observers_.RemoveObserver(observer); | 67 observers_.RemoveObserver(observer); |
68 } | 68 } |
69 | 69 |
70 virtual const DiskMap& disks() const OVERRIDE { | 70 virtual const DiskMap& disks() const override { |
71 return disks_; | 71 return disks_; |
72 } | 72 } |
73 | 73 |
74 // Following methods are not implemented. | 74 // Following methods are not implemented. |
75 virtual const Disk* FindDiskBySourcePath( | 75 virtual const Disk* FindDiskBySourcePath( |
76 const std::string& source_path) const OVERRIDE { | 76 const std::string& source_path) const override { |
77 return NULL; | 77 return NULL; |
78 } | 78 } |
79 virtual const MountPointMap& mount_points() const OVERRIDE { | 79 virtual const MountPointMap& mount_points() const override { |
80 // Note: mount_points_ will always be empty, now. | 80 // Note: mount_points_ will always be empty, now. |
81 return mount_points_; | 81 return mount_points_; |
82 } | 82 } |
83 virtual void EnsureMountInfoRefreshed( | 83 virtual void EnsureMountInfoRefreshed( |
84 const EnsureMountInfoRefreshedCallback& callback) OVERRIDE {} | 84 const EnsureMountInfoRefreshedCallback& callback) override {} |
85 virtual void MountPath(const std::string& source_path, | 85 virtual void MountPath(const std::string& source_path, |
86 const std::string& source_format, | 86 const std::string& source_format, |
87 const std::string& mount_label, | 87 const std::string& mount_label, |
88 MountType type) OVERRIDE {} | 88 MountType type) override {} |
89 virtual void UnmountPath(const std::string& mount_path, | 89 virtual void UnmountPath(const std::string& mount_path, |
90 UnmountOptions options, | 90 UnmountOptions options, |
91 const UnmountPathCallback& callback) OVERRIDE {} | 91 const UnmountPathCallback& callback) override {} |
92 virtual void FormatMountedDevice(const std::string& mount_path) OVERRIDE {} | 92 virtual void FormatMountedDevice(const std::string& mount_path) override {} |
93 virtual void UnmountDeviceRecursively( | 93 virtual void UnmountDeviceRecursively( |
94 const std::string& device_path, | 94 const std::string& device_path, |
95 const UnmountDeviceRecursivelyCallbackType& callback) OVERRIDE {} | 95 const UnmountDeviceRecursivelyCallbackType& callback) override {} |
96 virtual bool AddDiskForTest(Disk* disk) OVERRIDE { return false; } | 96 virtual bool AddDiskForTest(Disk* disk) override { return false; } |
97 virtual bool AddMountPointForTest( | 97 virtual bool AddMountPointForTest( |
98 const MountPointInfo& mount_point) OVERRIDE { | 98 const MountPointInfo& mount_point) override { |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 private: | 102 private: |
103 bool InsertDisk(const std::string& path, scoped_ptr<Disk> disk) { | 103 bool InsertDisk(const std::string& path, scoped_ptr<Disk> disk) { |
104 std::pair<DiskMap::iterator, bool> insert_result = | 104 std::pair<DiskMap::iterator, bool> insert_result = |
105 disks_.insert(std::pair<std::string, Disk*>(path, NULL)); | 105 disks_.insert(std::pair<std::string, Disk*>(path, NULL)); |
106 if (!insert_result.second) { | 106 if (!insert_result.second) { |
107 // There is already an entry. Delete it before replacing. | 107 // There is already an entry. Delete it before replacing. |
108 delete insert_result.first->second; | 108 delete insert_result.first->second; |
(...skipping 22 matching lines...) Expand all Loading... |
131 | 131 |
132 void CopyDevicePathCallback( | 132 void CopyDevicePathCallback( |
133 std::string* out_path, const disks::DiskMountManager::Disk& disk) { | 133 std::string* out_path, const disks::DiskMountManager::Disk& disk) { |
134 *out_path = disk.device_path(); | 134 *out_path = disk.device_path(); |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 | 138 |
139 class BurnDeviceHandlerTest : public testing::Test { | 139 class BurnDeviceHandlerTest : public testing::Test { |
140 protected: | 140 protected: |
141 virtual void SetUp() OVERRIDE { | 141 virtual void SetUp() override { |
142 disk_mount_manager_.reset(new FakeDiskMountManager); | 142 disk_mount_manager_.reset(new FakeDiskMountManager); |
143 } | 143 } |
144 | 144 |
145 virtual void TearDown() OVERRIDE { | 145 virtual void TearDown() override { |
146 disk_mount_manager_.reset(); | 146 disk_mount_manager_.reset(); |
147 } | 147 } |
148 | 148 |
149 static scoped_ptr<disks::DiskMountManager::Disk> CreateMockDisk( | 149 static scoped_ptr<disks::DiskMountManager::Disk> CreateMockDisk( |
150 const std::string& device_path, | 150 const std::string& device_path, |
151 bool is_parent, | 151 bool is_parent, |
152 bool on_boot_device, | 152 bool on_boot_device, |
153 bool has_media, | 153 bool has_media, |
154 DeviceType device_type) { | 154 DeviceType device_type) { |
155 return scoped_ptr<disks::DiskMountManager::Disk>( | 155 return scoped_ptr<disks::DiskMountManager::Disk>( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 added_device.clear(); | 278 added_device.clear(); |
279 removed_device.clear(); | 279 removed_device.clear(); |
280 disk_mount_manager_->EmulateRemoveDisk("/dev/unburnable"); | 280 disk_mount_manager_->EmulateRemoveDisk("/dev/unburnable"); |
281 EXPECT_TRUE(added_device.empty()); | 281 EXPECT_TRUE(added_device.empty()); |
282 EXPECT_TRUE(removed_device.empty()); | 282 EXPECT_TRUE(removed_device.empty()); |
283 } | 283 } |
284 | 284 |
285 } // namespace imageburner | 285 } // namespace imageburner |
286 } // namespace chromeos | 286 } // namespace chromeos |
OLD | NEW |