Chromium Code Reviews| 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 // chromeos::RemovableDeviceNotificationsCros implementation. | 5 // chromeos::RemovableDeviceNotificationsCros implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" | 7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 for (disks::DiskMountManager::MountPointMap::const_iterator it = | 113 for (disks::DiskMountManager::MountPointMap::const_iterator it = |
| 114 mount_point_map.begin(); it != mount_point_map.end(); ++it) { | 114 mount_point_map.begin(); it != mount_point_map.end(); ++it) { |
| 115 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
| 116 BrowserThread::FILE, FROM_HERE, | 116 BrowserThread::FILE, FROM_HERE, |
| 117 base::Bind( | 117 base::Bind( |
| 118 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread, | 118 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread, |
| 119 this, it->second)); | 119 this, it->second)); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 void RemovableDeviceNotificationsCros::DiskChanged( | 123 void RemovableDeviceNotificationsCros::OnDiskEvent( |
| 124 disks::DiskMountManagerEventType event, | 124 disks::DiskMountManager::DiskEvent event, |
| 125 const disks::DiskMountManager::Disk* disk) { | 125 const disks::DiskMountManager::Disk* disk) { |
| 126 } | 126 } |
| 127 | 127 |
| 128 void RemovableDeviceNotificationsCros::DeviceChanged( | 128 void RemovableDeviceNotificationsCros::OnDeviceEvent( |
| 129 disks::DiskMountManagerEventType event, | 129 disks::DiskMountManager::DeviceEvent event, |
| 130 const std::string& device_path) { | 130 const std::string& device_path) { |
| 131 } | 131 } |
| 132 | 132 |
| 133 void RemovableDeviceNotificationsCros::MountCompleted( | 133 void RemovableDeviceNotificationsCros::OnMountEvent( |
| 134 disks::DiskMountManager::MountEvent event_type, | 134 disks::DiskMountManager::MountEvent event, |
| 135 MountError error_code, | 135 MountError error_code, |
| 136 const disks::DiskMountManager::MountPointInfo& mount_info) { | 136 const disks::DiskMountManager::MountPointInfo& mount_info) { |
| 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 138 | 138 |
| 139 // Ignore mount points that are not devices. | 139 // Ignore mount points that are not devices. |
| 140 if (mount_info.mount_type != MOUNT_TYPE_DEVICE) | 140 if (mount_info.mount_type != MOUNT_TYPE_DEVICE) |
| 141 return; | 141 return; |
| 142 // Ignore errors. | 142 // Ignore errors. |
| 143 if (error_code != MOUNT_ERROR_NONE) | 143 if (error_code != MOUNT_ERROR_NONE) |
| 144 return; | 144 return; |
| 145 if (mount_info.mount_condition != disks::MOUNT_CONDITION_NONE) | 145 if (mount_info.mount_condition != disks::MOUNT_CONDITION_NONE) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 switch (event_type) { | 148 switch (event) { |
| 149 case disks::DiskMountManager::MOUNTING: { | 149 case disks::DiskMountManager::MOUNTING: { |
| 150 if (ContainsKey(mount_map_, mount_info.mount_path)) { | 150 if (ContainsKey(mount_map_, mount_info.mount_path)) { |
| 151 NOTREACHED(); | 151 NOTREACHED(); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 BrowserThread::PostTask( | 155 BrowserThread::PostTask( |
| 156 BrowserThread::FILE, FROM_HERE, | 156 BrowserThread::FILE, FROM_HERE, |
| 157 base::Bind( | 157 base::Bind( |
| 158 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread, | 158 &RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread, |
| 159 this, mount_info)); | 159 this, mount_info)); |
| 160 break; | 160 break; |
| 161 } | 161 } |
| 162 case disks::DiskMountManager::UNMOUNTING: { | 162 case disks::DiskMountManager::UNMOUNTING: { |
| 163 MountMap::iterator it = mount_map_.find(mount_info.mount_path); | 163 MountMap::iterator it = mount_map_.find(mount_info.mount_path); |
| 164 if (it == mount_map_.end()) | 164 if (it == mount_map_.end()) |
| 165 return; | 165 return; |
| 166 SystemMonitor::Get()->ProcessRemovableStorageDetached( | 166 SystemMonitor::Get()->ProcessRemovableStorageDetached( |
| 167 it->second.device_id); | 167 it->second.device_id); |
| 168 mount_map_.erase(it); | 168 mount_map_.erase(it); |
| 169 break; | 169 break; |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void RemovableDeviceNotificationsCros::OnFormatEvent( | |
| 175 disks::DiskMountManager::FormatEvent event, | |
| 176 FormatError error_code, | |
| 177 const std::string& device_path) { | |
|
Ben Chan
2012/11/12 23:10:50
missing a TODO / NOTIMPLEMENT?
tbarzic
2012/11/12 23:14:39
not really. RemovableDeviceNotificationsCros is no
| |
| 178 } | |
| 179 | |
| 174 bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath( | 180 bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath( |
| 175 const FilePath& path, | 181 const FilePath& path, |
| 176 SystemMonitor::RemovableStorageInfo* device_info) const { | 182 SystemMonitor::RemovableStorageInfo* device_info) const { |
| 177 if (!path.IsAbsolute()) | 183 if (!path.IsAbsolute()) |
| 178 return false; | 184 return false; |
| 179 | 185 |
| 180 FilePath current = path; | 186 FilePath current = path; |
| 181 while (!ContainsKey(mount_map_, current.value()) && | 187 while (!ContainsKey(mount_map_, current.value()) && |
| 182 current != current.DirName()) { | 188 current != current.DirName()) { |
| 183 current = current.DirName(); | 189 current = current.DirName(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 SystemMonitor::RemovableStorageInfo info(device_id, device_label, | 242 SystemMonitor::RemovableStorageInfo info(device_id, device_label, |
| 237 mount_info.mount_path); | 243 mount_info.mount_path); |
| 238 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); | 244 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); |
| 239 SystemMonitor::Get()->ProcessRemovableStorageAttached( | 245 SystemMonitor::Get()->ProcessRemovableStorageAttached( |
| 240 device_id, | 246 device_id, |
| 241 device_label, | 247 device_label, |
| 242 mount_info.mount_path); | 248 mount_info.mount_path); |
| 243 } | 249 } |
| 244 | 250 |
| 245 } // namespace chrome | 251 } // namespace chrome |
| OLD | NEW |