| 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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 else | 137 else |
| 138 return storage_info.Pass(); // Not a supported type. | 138 return storage_info.Pass(); // Not a supported type. |
| 139 | 139 |
| 140 ScopedUdevDeviceObject device( | 140 ScopedUdevDeviceObject device( |
| 141 udev_device_new_from_devnum(udev_obj.get(), device_type, | 141 udev_device_new_from_devnum(udev_obj.get(), device_type, |
| 142 device_stat.st_rdev)); | 142 device_stat.st_rdev)); |
| 143 if (!device.get()) | 143 if (!device.get()) |
| 144 return storage_info.Pass(); | 144 return storage_info.Pass(); |
| 145 | 145 |
| 146 base::string16 volume_label = | 146 base::string16 volume_label = |
| 147 UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kLabel)); | 147 base::UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kLabel)); |
| 148 base::string16 vendor_name = | 148 base::string16 vendor_name = |
| 149 UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kVendor)); | 149 base::UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kVendor)); |
| 150 base::string16 model_name = | 150 base::string16 model_name = |
| 151 UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kModel)); | 151 base::UTF8ToUTF16(GetUdevDevicePropertyValue(device.get(), kModel)); |
| 152 | 152 |
| 153 std::string unique_id = MakeDeviceUniqueId(device.get()); | 153 std::string unique_id = MakeDeviceUniqueId(device.get()); |
| 154 | 154 |
| 155 // Keep track of device info details to see how often we get invalid values. | 155 // Keep track of device info details to see how often we get invalid values. |
| 156 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label); | 156 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label); |
| 157 | 157 |
| 158 const char* value = | 158 const char* value = |
| 159 udev_device_get_sysattr_value(device.get(), kRemovableSysAttr); | 159 udev_device_get_sysattr_value(device.get(), kRemovableSysAttr); |
| 160 if (!value) { | 160 if (!value) { |
| 161 // |parent_device| is owned by |device| and does not need to be cleaned | 161 // |parent_device| is owned by |device| and does not need to be cleaned |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 mount_point_info.storage_info = *storage_info; | 493 mount_point_info.storage_info = *storage_info; |
| 494 mount_info_map_[mount_point] = mount_point_info; | 494 mount_info_map_[mount_point] = mount_point_info; |
| 495 mount_priority_map_[mount_device][mount_point] = removable; | 495 mount_priority_map_[mount_device][mount_point] = removable; |
| 496 receiver()->ProcessAttach(*storage_info); | 496 receiver()->ProcessAttach(*storage_info); |
| 497 } | 497 } |
| 498 | 498 |
| 499 StorageMonitor* StorageMonitor::Create() { | 499 StorageMonitor* StorageMonitor::Create() { |
| 500 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 500 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
| 501 return new StorageMonitorLinux(kDefaultMtabPath); | 501 return new StorageMonitorLinux(kDefaultMtabPath); |
| 502 } | 502 } |
| OLD | NEW |