| 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 // RemovableDeviceNotificationsLinux implementation. | 5 // RemovableDeviceNotificationsLinux implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // |mount_point|. | 344 // |mount_point|. |
| 345 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) { | 345 if (new_iter == new_mtab.end() || (new_iter->second != mount_device)) { |
| 346 MountPriorityMap::iterator priority = | 346 MountPriorityMap::iterator priority = |
| 347 mount_priority_map_.find(mount_device); | 347 mount_priority_map_.find(mount_device); |
| 348 DCHECK(priority != mount_priority_map_.end()); | 348 DCHECK(priority != mount_priority_map_.end()); |
| 349 ReferencedMountPoint::const_iterator has_priority = | 349 ReferencedMountPoint::const_iterator has_priority = |
| 350 priority->second.find(mount_point); | 350 priority->second.find(mount_point); |
| 351 if (MediaStorageUtil::IsRemovableDevice(old_iter->second.device_id)) { | 351 if (MediaStorageUtil::IsRemovableDevice(old_iter->second.device_id)) { |
| 352 DCHECK(has_priority != priority->second.end()); | 352 DCHECK(has_priority != priority->second.end()); |
| 353 if (has_priority->second) { | 353 if (has_priority->second) { |
| 354 ProcessDetach(old_iter->second.device_id); | 354 receiver_->ProcessDetach(old_iter->second.device_id); |
| 355 } | 355 } |
| 356 if (priority->second.size() > 1) | 356 if (priority->second.size() > 1) |
| 357 multiple_mounted_devices_needing_reattachment.push_back(mount_device); | 357 multiple_mounted_devices_needing_reattachment.push_back(mount_device); |
| 358 } | 358 } |
| 359 priority->second.erase(mount_point); | 359 priority->second.erase(mount_point); |
| 360 if (priority->second.empty()) | 360 if (priority->second.empty()) |
| 361 mount_priority_map_.erase(mount_device); | 361 mount_priority_map_.erase(mount_device); |
| 362 mount_points_to_erase.push_back(mount_point); | 362 mount_points_to_erase.push_back(mount_point); |
| 363 } | 363 } |
| 364 } | 364 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 380 it != multiple_mounted_devices_needing_reattachment.end(); | 380 it != multiple_mounted_devices_needing_reattachment.end(); |
| 381 ++it) { | 381 ++it) { |
| 382 ReferencedMountPoint::iterator first_mount_point_info = | 382 ReferencedMountPoint::iterator first_mount_point_info = |
| 383 mount_priority_map_.find(*it)->second.begin(); | 383 mount_priority_map_.find(*it)->second.begin(); |
| 384 const FilePath& mount_point = first_mount_point_info->first; | 384 const FilePath& mount_point = first_mount_point_info->first; |
| 385 first_mount_point_info->second = true; | 385 first_mount_point_info->second = true; |
| 386 | 386 |
| 387 const MountPointInfo& mount_info = | 387 const MountPointInfo& mount_info = |
| 388 mount_info_map_.find(mount_point)->second; | 388 mount_info_map_.find(mount_point)->second; |
| 389 DCHECK(MediaStorageUtil::IsRemovableDevice(mount_info.device_id)); | 389 DCHECK(MediaStorageUtil::IsRemovableDevice(mount_info.device_id)); |
| 390 ProcessAttach( | 390 receiver_->ProcessAttach(StorageInfo( |
| 391 mount_info.device_id, mount_info.device_name, mount_point.value()); | 391 mount_info.device_id, mount_info.device_name, mount_point.value())); |
| 392 } | 392 } |
| 393 | 393 |
| 394 // Check new mtab entries against existing ones. | 394 // Check new mtab entries against existing ones. |
| 395 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin(); | 395 for (MountPointDeviceMap::iterator new_iter = new_mtab.begin(); |
| 396 new_iter != new_mtab.end(); ++new_iter) { | 396 new_iter != new_mtab.end(); ++new_iter) { |
| 397 const FilePath& mount_point = new_iter->first; | 397 const FilePath& mount_point = new_iter->first; |
| 398 const FilePath& mount_device = new_iter->second; | 398 const FilePath& mount_device = new_iter->second; |
| 399 MountMap::iterator old_iter = mount_info_map_.find(mount_point); | 399 MountMap::iterator old_iter = mount_info_map_.find(mount_point); |
| 400 if (old_iter == mount_info_map_.end() || | 400 if (old_iter == mount_info_map_.end() || |
| 401 old_iter->second.mount_device != mount_device) { | 401 old_iter->second.mount_device != mount_device) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 MountPointInfo mount_point_info; | 446 MountPointInfo mount_point_info; |
| 447 mount_point_info.mount_device = mount_device; | 447 mount_point_info.mount_device = mount_device; |
| 448 mount_point_info.device_id = device_id; | 448 mount_point_info.device_id = device_id; |
| 449 mount_point_info.device_name = name; | 449 mount_point_info.device_name = name; |
| 450 mount_point_info.partition_size_in_bytes = partition_size_in_bytes; | 450 mount_point_info.partition_size_in_bytes = partition_size_in_bytes; |
| 451 | 451 |
| 452 mount_info_map_[mount_point] = mount_point_info; | 452 mount_info_map_[mount_point] = mount_point_info; |
| 453 mount_priority_map_[mount_device][mount_point] = removable; | 453 mount_priority_map_[mount_device][mount_point] = removable; |
| 454 | 454 |
| 455 if (removable) { | 455 if (removable) { |
| 456 ProcessAttach( | 456 receiver_->ProcessAttach(StorageInfo( |
| 457 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name), | 457 device_id, GetDisplayNameForDevice(partition_size_in_bytes, name), |
| 458 mount_point.value()); | 458 mount_point.value())); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace chrome | 462 } // namespace chrome |
| OLD | NEW |